Passed
Push — master ( 222e44...208bd5 )
by Alxarafe
31:22
created
dolibarr/htdocs/core/modules/product/mod_codeproduct_leopard.php 3 patches
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -32,112 +32,112 @@
 block discarded – undo
32 32
  */
33 33
 class mod_codeproduct_leopard extends ModeleProductCode
34 34
 {
35
-	/*
35
+    /*
36 36
 	 * Attention ce module est utilise par defaut si aucun module n'a
37 37
 	 * ete definit dans la configuration
38 38
 	 *
39 39
 	 * Le fonctionnement de celui-ci doit donc rester le plus ouvert possible
40 40
 	 */
41 41
 
42
-	/**
43
-	 * @var string Nom du modele
44
-	 * @deprecated
45
-	 * @see name
46
-	 */
47
-	public $nom='Leopard';
42
+    /**
43
+     * @var string Nom du modele
44
+     * @deprecated
45
+     * @see name
46
+     */
47
+    public $nom='Leopard';
48 48
 
49
-	/**
50
-	 * @var string model name
51
-	 */
52
-	public $name='Leopard';
49
+    /**
50
+     * @var string model name
51
+     */
52
+    public $name='Leopard';
53 53
 
54
-	public $code_modifiable;				// Code modifiable
54
+    public $code_modifiable;				// Code modifiable
55 55
 
56
-	public $code_modifiable_invalide;		// Code modifiable si il est invalide
56
+    public $code_modifiable_invalide;		// Code modifiable si il est invalide
57 57
 
58
-	public $code_modifiable_null;			// Code modifiables si il est null
58
+    public $code_modifiable_null;			// Code modifiables si il est null
59 59
 
60
-	public $code_null;						// Code facultatif
60
+    public $code_null;						// Code facultatif
61 61
 
62
-	/**
62
+    /**
63 63
      * Dolibarr version of the loaded document
64 64
      * @public string
65 65
      */
66
-	public $version = 'dolibarr';    		// 'development', 'experimental', 'dolibarr'
67
-
68
-	public $code_auto; 	                // Numerotation automatique
69
-
66
+    public $version = 'dolibarr';    		// 'development', 'experimental', 'dolibarr'
70 67
 
71
-	/**
72
-	 *	Constructor
73
-	 */
74
-	function __construct()
75
-	{
76
-		$this->code_null = 1;
77
-		$this->code_modifiable = 1;
78
-		$this->code_modifiable_invalide = 1;
79
-		$this->code_modifiable_null = 1;
80
-		$this->code_auto = 0;
81
-	}
82
-
83
-
84
-	/**		Return description of module
85
-	 *
86
-	 * 		@param	Translate	$langs	Object langs
87
-	 * 		@return string      		Description of module
88
-	 */
89
-	function info($langs)
90
-	{
91
-		$langs->load("companies");
92
-		return $langs->trans("LeopardNumRefModelDesc");
93
-	}
68
+    public $code_auto; 	                // Numerotation automatique
94 69
 
95 70
 
96
-	/**
97
-	 * Return an example of result returned by getNextValue
98
-	 *
99
-	 * @param	product		$objproduct		Object product
100
-	 * @param	int			$type		Type of third party (1:customer, 2:supplier, -1:autodetect)
101
-	 * @return	string					Return next value
102
-	 */
103
-	function getNextValue($objproduct=0,$type=-1)
104
-	{
105
-		global $langs;
106
-		return '';
107
-	}
108
-
109
-
110
-	/**
111
-	 * 	Check validity of code according to its rules
112
-	 *
113
-	 *	@param	DoliDB		$db		Database handler
114
-	 *	@param	string		$code	Code to check/correct
115
-	 *	@param	Product		$product	Object product
116
-	 *  @param  int		  	$type   0 = product , 1 = service
117
-	 *  @return int					0 if OK
118
-	 * 								-1 ErrorBadProductCodeSyntax
119
-	 * 								-2 ErrorProductCodeRequired
120
-	 * 								-3 ErrorProductCodeAlreadyUsed
121
-	 * 								-4 ErrorPrefixRequired
122
-	 */
123
-	function verif($db, &$code, $product, $type)
124
-	{
125
-		global $conf;
126
-
127
-		$result=0;
128
-		$code = strtoupper(trim($code));
129
-
130
-		if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
131
-		{
132
-			$result=0;
133
-		}
134
-		else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) )
135
-		{
136
-			$result=-2;
137
-		}
138
-
139
-		dol_syslog("mod_codeproduct_leopard::verif type=".$type." result=".$result);
140
-		return $result;
141
-	}
71
+    /**
72
+     *	Constructor
73
+     */
74
+    function __construct()
75
+    {
76
+        $this->code_null = 1;
77
+        $this->code_modifiable = 1;
78
+        $this->code_modifiable_invalide = 1;
79
+        $this->code_modifiable_null = 1;
80
+        $this->code_auto = 0;
81
+    }
82
+
83
+
84
+    /**		Return description of module
85
+     *
86
+     * 		@param	Translate	$langs	Object langs
87
+     * 		@return string      		Description of module
88
+     */
89
+    function info($langs)
90
+    {
91
+        $langs->load("companies");
92
+        return $langs->trans("LeopardNumRefModelDesc");
93
+    }
94
+
95
+
96
+    /**
97
+     * Return an example of result returned by getNextValue
98
+     *
99
+     * @param	product		$objproduct		Object product
100
+     * @param	int			$type		Type of third party (1:customer, 2:supplier, -1:autodetect)
101
+     * @return	string					Return next value
102
+     */
103
+    function getNextValue($objproduct=0,$type=-1)
104
+    {
105
+        global $langs;
106
+        return '';
107
+    }
108
+
109
+
110
+    /**
111
+     * 	Check validity of code according to its rules
112
+     *
113
+     *	@param	DoliDB		$db		Database handler
114
+     *	@param	string		$code	Code to check/correct
115
+     *	@param	Product		$product	Object product
116
+     *  @param  int		  	$type   0 = product , 1 = service
117
+     *  @return int					0 if OK
118
+     * 								-1 ErrorBadProductCodeSyntax
119
+     * 								-2 ErrorProductCodeRequired
120
+     * 								-3 ErrorProductCodeAlreadyUsed
121
+     * 								-4 ErrorPrefixRequired
122
+     */
123
+    function verif($db, &$code, $product, $type)
124
+    {
125
+        global $conf;
126
+
127
+        $result=0;
128
+        $code = strtoupper(trim($code));
129
+
130
+        if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
131
+        {
132
+            $result=0;
133
+        }
134
+        else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) )
135
+        {
136
+            $result=-2;
137
+        }
138
+
139
+        dol_syslog("mod_codeproduct_leopard::verif type=".$type." result=".$result);
140
+        return $result;
141
+    }
142 142
 }
143 143
 
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -44,28 +44,28 @@  discard block
 block discarded – undo
44 44
 	 * @deprecated
45 45
 	 * @see name
46 46
 	 */
47
-	public $nom='Leopard';
47
+	public $nom = 'Leopard';
48 48
 
49 49
 	/**
50 50
 	 * @var string model name
51 51
 	 */
52
-	public $name='Leopard';
52
+	public $name = 'Leopard';
53 53
 
54
-	public $code_modifiable;				// Code modifiable
54
+	public $code_modifiable; // Code modifiable
55 55
 
56
-	public $code_modifiable_invalide;		// Code modifiable si il est invalide
56
+	public $code_modifiable_invalide; // Code modifiable si il est invalide
57 57
 
58
-	public $code_modifiable_null;			// Code modifiables si il est null
58
+	public $code_modifiable_null; // Code modifiables si il est null
59 59
 
60
-	public $code_null;						// Code facultatif
60
+	public $code_null; // Code facultatif
61 61
 
62 62
 	/**
63 63
      * Dolibarr version of the loaded document
64 64
      * @public string
65 65
      */
66
-	public $version = 'dolibarr';    		// 'development', 'experimental', 'dolibarr'
66
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
67 67
 
68
-	public $code_auto; 	                // Numerotation automatique
68
+	public $code_auto; // Numerotation automatique
69 69
 
70 70
 
71 71
 	/**
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 * @param	int			$type		Type of third party (1:customer, 2:supplier, -1:autodetect)
101 101
 	 * @return	string					Return next value
102 102
 	 */
103
-	function getNextValue($objproduct=0,$type=-1)
103
+	function getNextValue($objproduct = 0, $type = -1)
104 104
 	{
105 105
 		global $langs;
106 106
 		return '';
@@ -124,16 +124,16 @@  discard block
 block discarded – undo
124 124
 	{
125 125
 		global $conf;
126 126
 
127
-		$result=0;
127
+		$result = 0;
128 128
 		$code = strtoupper(trim($code));
129 129
 
130 130
 		if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
131 131
 		{
132
-			$result=0;
132
+			$result = 0;
133 133
 		}
134
-		else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) )
134
+		else if (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)))
135 135
 		{
136
-			$result=-2;
136
+			$result = -2;
137 137
 		}
138 138
 
139 139
 		dol_syslog("mod_codeproduct_leopard::verif type=".$type." result=".$result);
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -129,8 +129,7 @@
 block discarded – undo
129 129
 		if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
130 130
 		{
131 131
 			$result=0;
132
-		}
133
-		else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) )
132
+		} else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) )
134 133
 		{
135 134
 			$result=-2;
136 135
 		}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/product/modules_product.class.php 3 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -26,17 +26,17 @@  discard block
 block discarded – undo
26 26
  *  \brief      File with parent class for generating products to PDF and File of class to manage product numbering
27 27
  */
28 28
 
29
- require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
29
+    require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
30 30
 
31 31
 /**
32 32
  *	Parent class to manage intervention document templates
33 33
  */
34 34
 abstract class ModelePDFProduct extends CommonDocGenerator
35 35
 {
36
-	/**
37
-	 * @var string Error code (or message)
38
-	 */
39
-	public $error='';
36
+    /**
37
+     * @var string Error code (or message)
38
+     */
39
+    public $error='';
40 40
 
41 41
 
42 42
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -47,26 +47,26 @@  discard block
 block discarded – undo
47 47
      *  @param  integer	$maxfilenamelength  Max length of value to show
48 48
      *  @return	array						List of templates
49 49
      */
50
-	static function liste_modeles($db,$maxfilenamelength=0)
51
-	{
50
+    static function liste_modeles($db,$maxfilenamelength=0)
51
+    {
52 52
         // phpcs:enable
53
-		global $conf;
53
+        global $conf;
54 54
 
55
-		$type='product';
56
-		$liste=array();
55
+        $type='product';
56
+        $liste=array();
57 57
 
58
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
59
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
60
-		return $liste;
61
-	}
58
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
59
+        $liste=getListOfModels($db,$type,$maxfilenamelength);
60
+        return $liste;
61
+    }
62 62
 }
63 63
 
64 64
 abstract class ModeleProductCode
65 65
 {
66 66
     /**
67
-	 * @var string Error code (or message)
68
-	 */
69
-	public $error='';
67
+     * @var string Error code (or message)
68
+     */
69
+    public $error='';
70 70
 
71 71
     /**     Renvoi la description par defaut du modele de numerotation
72 72
      *
@@ -243,10 +243,10 @@  discard block
 block discarded – undo
243 243
 
244 244
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
245 245
     /**
246
-	 *   Check if mask/numbering use prefix
247
-	 *
248
-	 *   @return	int		0=no, 1=yes
249
-	 */
246
+     *   Check if mask/numbering use prefix
247
+     *
248
+     *   @return	int		0=no, 1=yes
249
+     */
250 250
     function verif_prefixIsUsed()
251 251
     {
252 252
         // phpcs:enable
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	/**
37 37
 	 * @var string Error code (or message)
38 38
 	 */
39
-	public $error='';
39
+	public $error = '';
40 40
 
41 41
 
42 42
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -47,16 +47,16 @@  discard block
 block discarded – undo
47 47
      *  @param  integer	$maxfilenamelength  Max length of value to show
48 48
      *  @return	array						List of templates
49 49
      */
50
-	static function liste_modeles($db,$maxfilenamelength=0)
50
+	static function liste_modeles($db, $maxfilenamelength = 0)
51 51
 	{
52 52
         // phpcs:enable
53 53
 		global $conf;
54 54
 
55
-		$type='product';
56
-		$liste=array();
55
+		$type = 'product';
56
+		$liste = array();
57 57
 
58 58
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
59
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
59
+		$liste = getListOfModels($db, $type, $maxfilenamelength);
60 60
 		return $liste;
61 61
 	}
62 62
 }
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     /**
67 67
 	 * @var string Error code (or message)
68 68
 	 */
69
-	public $error='';
69
+	public $error = '';
70 70
 
71 71
     /**     Renvoi la description par defaut du modele de numerotation
72 72
      *
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     function getNom($langs)
88 88
     {
89
-        return empty($this->name)?$this->nom:$this->name;
89
+        return empty($this->name) ? $this->nom : $this->name;
90 90
     }
91 91
 
92 92
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
      *	@param	int			$type		Type
119 119
      *  @return string      			Value
120 120
      */
121
-    function getNextValue($objproduct=0,$type=-1)
121
+    function getNextValue($objproduct = 0, $type = -1)
122 122
     {
123 123
         global $langs;
124 124
         return $langs->trans("Function_getNextValue_InModuleNotWorking");
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
      *  @param  integer	$maxfilenamelength  Max length of value to show
150 150
      *  @return	array						List of numbers
151 151
      */
152
-    static function liste_modeles($db,$maxfilenamelength=0)
152
+    static function liste_modeles($db, $maxfilenamelength = 0)
153 153
     {
154 154
         // phpcs:enable
155
-        $liste=array();
156
-        $sql ="";
155
+        $liste = array();
156
+        $sql = "";
157 157
 
158 158
         $resql = $db->query($sql);
159 159
         if ($resql)
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
             while ($i < $num)
164 164
             {
165 165
                 $row = $db->fetch_row($resql);
166
-                $liste[$row[0]]=$row[1];
166
+                $liste[$row[0]] = $row[1];
167 167
                 $i++;
168 168
             }
169 169
         }
@@ -182,61 +182,61 @@  discard block
 block discarded – undo
182 182
      *		@param	int			$type		-1=Nothing, 0=Customer, 1=Supplier
183 183
      *		@return	string					HTML translated description
184 184
      */
185
-    function getToolTip($langs,$product,$type)
185
+    function getToolTip($langs, $product, $type)
186 186
     {
187 187
         global $conf;
188 188
 
189 189
         $langs->load("admin");
190 190
 
191
-        $s='';
192
-        if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
193
-        if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
194
-        if ($type == 0)  $s.=$langs->trans("ProductCodeDesc").'<br>';
195
-        if ($type == 1)  $s.=$langs->trans("ServiceCodeDesc").'<br>';
196
-        if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
197
-        $s.='<br>';
198
-        $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
191
+        $s = '';
192
+        if ($type == -1) $s .= $langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
193
+        if ($type == -1) $s .= $langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
194
+        if ($type == 0)  $s .= $langs->trans("ProductCodeDesc").'<br>';
195
+        if ($type == 1)  $s .= $langs->trans("ServiceCodeDesc").'<br>';
196
+        if ($type != -1) $s .= $langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
197
+        $s .= '<br>';
198
+        $s .= '<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
199 199
         if ($type == 0)
200 200
         {
201
-            $s.=$langs->trans("RequiredIfProduct").': ';
202
-            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
203
-            $s.=yn(!$this->code_null,1,2);
204
-            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
205
-            $s.='<br>';
201
+            $s .= $langs->trans("RequiredIfProduct").': ';
202
+            if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>';
203
+            $s .= yn(!$this->code_null, 1, 2);
204
+            if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
205
+            $s .= '<br>';
206 206
         }
207 207
         elseif ($type == 1)
208 208
         {
209
-            $s.=$langs->trans("RequiredIfService").': ';
210
-            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
211
-            $s.=yn(!$this->code_null,1,2);
212
-            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
213
-            $s.='<br>';
209
+            $s .= $langs->trans("RequiredIfService").': ';
210
+            if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>';
211
+            $s .= yn(!$this->code_null, 1, 2);
212
+            if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
213
+            $s .= '<br>';
214 214
         }
215 215
         elseif ($type == -1)
216 216
         {
217
-            $s.=$langs->trans("Required").': ';
218
-            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
219
-            $s.=yn(!$this->code_null,1,2);
220
-            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
221
-            $s.='<br>';
217
+            $s .= $langs->trans("Required").': ';
218
+            if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '<strike>';
219
+            $s .= yn(!$this->code_null, 1, 2);
220
+            if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
221
+            $s .= '<br>';
222 222
         }
223
-        $s.=$langs->trans("CanBeModifiedIfOk").': ';
224
-        $s.=yn($this->code_modifiable,1,2);
225
-        $s.='<br>';
226
-        $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'<br>';
227
-        $s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto,1,2).'<br>';
228
-        $s.='<br>';
223
+        $s .= $langs->trans("CanBeModifiedIfOk").': ';
224
+        $s .= yn($this->code_modifiable, 1, 2);
225
+        $s .= '<br>';
226
+        $s .= $langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
227
+        $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
228
+        $s .= '<br>';
229 229
         if ($type == 0 || $type == -1)
230 230
         {
231
-            $nextval=$this->getNextValue($product,0);
232
-            if (empty($nextval)) $nextval=$langs->trans("Undefined");
233
-            $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Product").')':'').': <b>'.$nextval.'</b><br>';
231
+            $nextval = $this->getNextValue($product, 0);
232
+            if (empty($nextval)) $nextval = $langs->trans("Undefined");
233
+            $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Product").')' : '').': <b>'.$nextval.'</b><br>';
234 234
         }
235 235
         if ($type == 1 || $type == -1)
236 236
         {
237
-            $nextval=$this->getNextValue($product,1);
238
-            if (empty($nextval)) $nextval=$langs->trans("Undefined");
239
-            $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Service").')':'').': <b>'.$nextval.'</b>';
237
+            $nextval = $this->getNextValue($product, 1);
238
+            if (empty($nextval)) $nextval = $langs->trans("Undefined");
239
+            $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Service").')' : '').': <b>'.$nextval.'</b>';
240 240
         }
241 241
         return $s;
242 242
     }
Please login to merge, or discard this patch.
Braces   +54 added lines, -23 removed lines patch added patch discarded remove patch
@@ -134,10 +134,18 @@  discard block
 block discarded – undo
134 134
         global $langs;
135 135
         $langs->load("admin");
136 136
 
137
-        if ($this->version == 'development') return $langs->trans("VersionDevelopment");
138
-        if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
139
-        if ($this->version == 'dolibarr') return DOL_VERSION;
140
-        if ($this->version) return $this->version;
137
+        if ($this->version == 'development') {
138
+            return $langs->trans("VersionDevelopment");
139
+        }
140
+        if ($this->version == 'experimental') {
141
+            return $langs->trans("VersionExperimental");
142
+        }
143
+        if ($this->version == 'dolibarr') {
144
+            return DOL_VERSION;
145
+        }
146
+        if ($this->version) {
147
+            return $this->version;
148
+        }
141 149
         return $langs->trans("NotAvailable");
142 150
     }
143 151
 
@@ -166,8 +174,7 @@  discard block
 block discarded – undo
166 174
                 $liste[$row[0]]=$row[1];
167 175
                 $i++;
168 176
             }
169
-        }
170
-        else
177
+        } else
171 178
         {
172 179
             return -1;
173 180
         }
@@ -189,35 +196,55 @@  discard block
 block discarded – undo
189 196
         $langs->load("admin");
190 197
 
191 198
         $s='';
192
-        if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
193
-        if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
194
-        if ($type == 0)  $s.=$langs->trans("ProductCodeDesc").'<br>';
195
-        if ($type == 1)  $s.=$langs->trans("ServiceCodeDesc").'<br>';
196
-        if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
199
+        if ($type == -1) {
200
+            $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
201
+        }
202
+        if ($type == -1) {
203
+            $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
204
+        }
205
+        if ($type == 0) {
206
+            $s.=$langs->trans("ProductCodeDesc").'<br>';
207
+        }
208
+        if ($type == 1) {
209
+            $s.=$langs->trans("ServiceCodeDesc").'<br>';
210
+        }
211
+        if ($type != -1) {
212
+            $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
213
+        }
197 214
         $s.='<br>';
198 215
         $s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
199 216
         if ($type == 0)
200 217
         {
201 218
             $s.=$langs->trans("RequiredIfProduct").': ';
202
-            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
219
+            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) {
220
+                $s.='<strike>';
221
+            }
203 222
             $s.=yn(!$this->code_null,1,2);
204
-            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
223
+            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) {
224
+                $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
225
+            }
205 226
             $s.='<br>';
206
-        }
207
-        elseif ($type == 1)
227
+        } elseif ($type == 1)
208 228
         {
209 229
             $s.=$langs->trans("RequiredIfService").': ';
210
-            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
230
+            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) {
231
+                $s.='<strike>';
232
+            }
211 233
             $s.=yn(!$this->code_null,1,2);
212
-            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
234
+            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) {
235
+                $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
236
+            }
213 237
             $s.='<br>';
214
-        }
215
-        elseif ($type == -1)
238
+        } elseif ($type == -1)
216 239
         {
217 240
             $s.=$langs->trans("Required").': ';
218
-            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
241
+            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) {
242
+                $s.='<strike>';
243
+            }
219 244
             $s.=yn(!$this->code_null,1,2);
220
-            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
245
+            if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) {
246
+                $s.='</strike> '.yn(1,1,2).' ('.$langs->trans("ForcedToByAModule",$langs->transnoentities("yes")).')';
247
+            }
221 248
             $s.='<br>';
222 249
         }
223 250
         $s.=$langs->trans("CanBeModifiedIfOk").': ';
@@ -229,13 +256,17 @@  discard block
 block discarded – undo
229 256
         if ($type == 0 || $type == -1)
230 257
         {
231 258
             $nextval=$this->getNextValue($product,0);
232
-            if (empty($nextval)) $nextval=$langs->trans("Undefined");
259
+            if (empty($nextval)) {
260
+                $nextval=$langs->trans("Undefined");
261
+            }
233 262
             $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Product").')':'').': <b>'.$nextval.'</b><br>';
234 263
         }
235 264
         if ($type == 1 || $type == -1)
236 265
         {
237 266
             $nextval=$this->getNextValue($product,1);
238
-            if (empty($nextval)) $nextval=$langs->trans("Undefined");
267
+            if (empty($nextval)) {
268
+                $nextval=$langs->trans("Undefined");
269
+            }
239 270
             $s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Service").')':'').': <b>'.$nextval.'</b>';
240 271
         }
241 272
         return $s;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php 3 patches
Indentation   +324 added lines, -324 removed lines patch added patch discarded remove patch
@@ -33,259 +33,259 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class pdf_tcpdflabel extends CommonStickerGenerator
35 35
 {
36
-	// define 1d barcode style
37
-	private $_style1d = array(
38
-					'position' => '',
39
-					'align' => 'C',
40
-					'stretch' => false,
41
-					'fitwidth' => true,
42
-					'cellfitalign' => '',
43
-					'border' => false,
44
-					'hpadding' => 'auto',
45
-					'vpadding' => 'auto',
46
-					'fgcolor' => array(0,0,0),
47
-					'bgcolor' => false,
48
-					'text' => true,
49
-					'font' => 'helvetica',
50
-					'fontsize' => 8,
51
-					'stretchtext' => 4
52
-	);
53
-
54
-	// set style for 2d barcode
55
-	private $_style2d = array(
56
-					'border' => false,
57
-					'vpadding' => 'auto',
58
-					'hpadding' => 'auto',
59
-					'fgcolor' => array(0,0,0),
60
-					'bgcolor' => false,
61
-					'module_width' => 1, // width of a single module in points
62
-					'module_height' => 1 // height of a single module in points
63
-	);
64
-
65
-	private $_align2d = 'N';
66
-
67
-	private $_xres = 0.4;
68
-
69
-	/**
70
-	 * write barcode to pdf
71
-	 *
72
-	 * @param PDF	  $pdf		  PDF reference
73
-	 * @param string  $code		   code to print
74
-	 * @param string  $encoding	   type of barcode
75
-	 * @param boolean $is2d		   true if 2d barcode
76
-	 * @param int	  $x		   x position in user units
77
-	 * @param int	  $y		   y position in user units
78
-	 * @param int	  $w		   width in user units
79
-	 * @param int	  $h		   height in user units
80
-	 * @return void
81
-	 */
82
-	private function writeBarcode(&$pdf, $code, $encoding, $is2d, $x, $y, $w, $h)
83
-	{
84
-		if ($is2d) {
85
-			$pdf->write2DBarcode($code, $encoding, $x, $y, $w, $h, $this->_style2d, $this->_align2d);
86
-		} else {
87
-			$pdf->write1DBarcode($code, $encoding, $x, $y, $w, $h, $this->_xres, $this->_style1d);
88
-		}
89
-	}
90
-
91
-	/**
92
-	 * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
93
-	 *
94
-	 * @param	PDF			$pdf			PDF reference
95
-	 * @param	Translate	$outputlangs	Output langs
96
-	 * @param	array		$param			Associative array containing label content and optional parameters
97
-	 * @return	void
98
-	 */
99
-	function addSticker(&$pdf,$outputlangs,$param)
100
-	{
101
-		global $mysoc,$conf;
102
-
103
-		$textleft = $param['textleft'];
104
-		$header = $param['textheader'];
105
-		$footer = $param['textfooter'];
106
-		$textright = $param['textright'];
107
-		$code = $param['code'];
108
-		$encoding = $param['encoding'];
109
-		$is2d = $param['is2d'];
110
-
111
-
112
-
113
-		// We are in a new page, then we must add a page
114
-		if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) {
115
-			$pdf->AddPage();
116
-		}
117
-		$this->_First=0;
118
-		$_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space));
119
-		$_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space));
120
-
121
-		// Define logo
122
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
123
-		if (! is_readable($logo))
124
-		{
125
-			$logo='';
126
-			if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
127
-			{
128
-				$logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
129
-			}
130
-			elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
131
-			{
132
-				$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
133
-			}
134
-		}
135
-
136
-		$xleft = 2;
137
-		$ytop = 2;
138
-
139
-		// Top
140
-		if ($header!='')
141
-		{
142
-			$pdf->SetXY($_PosX+$xleft, $_PosY+1); // Only 1 mm and not ytop for top text
143
-			$pdf->Cell($this->_Width-2*$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C');
144
-		}
145
-
146
-		$ytop += (empty($header)?0:(1+$this->_Line_Height));
147
-
148
-		// Define widthtouse and heighttouse
149
-		$pageMargins = $pdf->getMargins();
150
-		$maxwidthtouse = round($this->_Width - 2*$xleft);
151
-		$maxheighttouse = round($this->_Height - 2*$ytop);
152
-		$maxheighttouse -= (empty($footer)?0:(1+$this->_Line_Height));
153
-		$defaultratio = ($maxwidthtouse/$maxheighttouse);
154
-		$widthtouse = $maxwidthtouse;
155
-		$heighttouse = $maxheighttouse;
156
-		$logoHeight = $heighttouse;
157
-		$logoWidth = $heighttouse;
158
-
159
-		//var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit;
160
-
161
-		// Center
162
-		if ($textright=='')	// Only a left part
163
-		{
164
-			// Output left area
165
-			if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, 0, $logoHeight);
166
-			else if ($code && !empty($encoding))
167
-			{
168
-				$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse, $heighttouse);
169
-			}
170
-			else
171
-			{
172
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
173
-				$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
174
-			}
175
-		}
176
-		else if ($textleft!='' && $textright!='')	// left and right part
177
-		{
178
-			if (($textleft == '%LOGO%' || $textleft == '%PHOTO%' || $textleft == '%BARCODE%') && !strstr($textright, '%') )	 // left part logo/barcode right part text
179
-			{
180
-				if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, $widthtouse/2, 0);
181
-				else if ($code && !empty($encoding))
182
-				{
183
-					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse/2, $heighttouse);
184
-				}
185
-				$pdf->SetXY($_PosX+($widthtouse/2), $_PosY+$ytop);
186
-				$pdf->MultiCell($widthtouse/2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
187
-			}
188
-			else if (($textright == '%LOGO%' || $textright == '%PHOTO%' || $textright == '%BARCODE%') && !strstr($textleft, '%')) // right part logo/barcode left part text
189
-			{
190
-				if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+($widthtouse/2), $_PosY+$ytop, $widthtouse/2, 0);
191
-				else if ($code && !empty($encoding))
192
-				{
193
-					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+($widthtouse/2), $_PosY+$ytop, $widthtouse/2, $heighttouse);
194
-				}
195
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
196
-				$pdf->MultiCell($widthtouse/2, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
197
-			}
198
-			else if ($textleft == '%LOGO%')	 // left part logo right part text/barcode
199
-			{
200
-				if ($logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, 0, $logoHeight);
201
-				if ($code && !empty($encoding))
202
-				{
203
-					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft+$logoWidth+1, $_PosY+$ytop, $widthtouse-$logoWidth-1, $heighttouse);
204
-				} else {
205
-					$pdf->SetXY($_PosX+$xleft+$logoWidth+1, $_PosY+$ytop);
206
-					$pdf->MultiCell($widthtouse-$logoWidth1-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
207
-				}
208
-			}
209
-			else if ($textright == '%LOGO%')  // right part logo left part text/barcode
210
-			{
211
-				if ($logo) $pdf->Image($logo, $_PosX+$xleft+$widthtouse-$logoWidth+1, $_PosY+$ytop, 0, $logoHeight);
212
-				if ($code && !empty($encoding))
213
-				{
214
-					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse-$logoWidth-1, $heighttouse);
215
-				} else {
216
-					$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
217
-					$pdf->MultiCell($widthtouse-$logoWidth-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
218
-				}
219
-			}
220
-			else	// text on halft left and text on half right
221
-			{
222
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
223
-				$pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
224
-				$pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop);
225
-				$pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
226
-			}
227
-		}
228
-		else	// Only a right part
229
-		{
230
-			// Output right area
231
-			if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$this->_Width-$widthtouse-$xleft, $_PosY+$ytop, 0, $logoHeight);
232
-			else if ($code && !empty($encoding))
233
-			{
234
-				$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$this->_Width-$widthtouse-$xleft, $_PosY+$ytop, $widthtouse, $heighttouse);
235
-			}
236
-			else
237
-			{
238
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
239
-				$pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
240
-			}
241
-		}
242
-
243
-		// Bottom
244
-		if ($footer!='')
245
-		{
246
-			$pdf->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1);
247
-			$pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C');
248
-		}
249
-		//print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n";
250
-
251
-		$this->_COUNTY++;
252
-
253
-		if ($this->_COUNTY == $this->_Y_Number) {
254
-			// Si on est en bas de page, on remonte le 'curseur' de position
255
-			$this->_COUNTX++;
256
-			$this->_COUNTY=0;
257
-		}
258
-
259
-		if ($this->_COUNTX == $this->_X_Number) {
260
-			// Si on est en bout de page, alors on repart sur une nouvelle page
261
-			$this->_COUNTX=0;
262
-			$this->_COUNTY=0;
263
-		}
264
-	}
36
+    // define 1d barcode style
37
+    private $_style1d = array(
38
+                    'position' => '',
39
+                    'align' => 'C',
40
+                    'stretch' => false,
41
+                    'fitwidth' => true,
42
+                    'cellfitalign' => '',
43
+                    'border' => false,
44
+                    'hpadding' => 'auto',
45
+                    'vpadding' => 'auto',
46
+                    'fgcolor' => array(0,0,0),
47
+                    'bgcolor' => false,
48
+                    'text' => true,
49
+                    'font' => 'helvetica',
50
+                    'fontsize' => 8,
51
+                    'stretchtext' => 4
52
+    );
53
+
54
+    // set style for 2d barcode
55
+    private $_style2d = array(
56
+                    'border' => false,
57
+                    'vpadding' => 'auto',
58
+                    'hpadding' => 'auto',
59
+                    'fgcolor' => array(0,0,0),
60
+                    'bgcolor' => false,
61
+                    'module_width' => 1, // width of a single module in points
62
+                    'module_height' => 1 // height of a single module in points
63
+    );
64
+
65
+    private $_align2d = 'N';
66
+
67
+    private $_xres = 0.4;
68
+
69
+    /**
70
+     * write barcode to pdf
71
+     *
72
+     * @param PDF	  $pdf		  PDF reference
73
+     * @param string  $code		   code to print
74
+     * @param string  $encoding	   type of barcode
75
+     * @param boolean $is2d		   true if 2d barcode
76
+     * @param int	  $x		   x position in user units
77
+     * @param int	  $y		   y position in user units
78
+     * @param int	  $w		   width in user units
79
+     * @param int	  $h		   height in user units
80
+     * @return void
81
+     */
82
+    private function writeBarcode(&$pdf, $code, $encoding, $is2d, $x, $y, $w, $h)
83
+    {
84
+        if ($is2d) {
85
+            $pdf->write2DBarcode($code, $encoding, $x, $y, $w, $h, $this->_style2d, $this->_align2d);
86
+        } else {
87
+            $pdf->write1DBarcode($code, $encoding, $x, $y, $w, $h, $this->_xres, $this->_style1d);
88
+        }
89
+    }
90
+
91
+    /**
92
+     * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
93
+     *
94
+     * @param	PDF			$pdf			PDF reference
95
+     * @param	Translate	$outputlangs	Output langs
96
+     * @param	array		$param			Associative array containing label content and optional parameters
97
+     * @return	void
98
+     */
99
+    function addSticker(&$pdf,$outputlangs,$param)
100
+    {
101
+        global $mysoc,$conf;
102
+
103
+        $textleft = $param['textleft'];
104
+        $header = $param['textheader'];
105
+        $footer = $param['textfooter'];
106
+        $textright = $param['textright'];
107
+        $code = $param['code'];
108
+        $encoding = $param['encoding'];
109
+        $is2d = $param['is2d'];
110
+
111
+
112
+
113
+        // We are in a new page, then we must add a page
114
+        if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) {
115
+            $pdf->AddPage();
116
+        }
117
+        $this->_First=0;
118
+        $_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space));
119
+        $_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space));
120
+
121
+        // Define logo
122
+        $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
123
+        if (! is_readable($logo))
124
+        {
125
+            $logo='';
126
+            if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
127
+            {
128
+                $logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
129
+            }
130
+            elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
131
+            {
132
+                $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
133
+            }
134
+        }
135
+
136
+        $xleft = 2;
137
+        $ytop = 2;
138
+
139
+        // Top
140
+        if ($header!='')
141
+        {
142
+            $pdf->SetXY($_PosX+$xleft, $_PosY+1); // Only 1 mm and not ytop for top text
143
+            $pdf->Cell($this->_Width-2*$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C');
144
+        }
145
+
146
+        $ytop += (empty($header)?0:(1+$this->_Line_Height));
147
+
148
+        // Define widthtouse and heighttouse
149
+        $pageMargins = $pdf->getMargins();
150
+        $maxwidthtouse = round($this->_Width - 2*$xleft);
151
+        $maxheighttouse = round($this->_Height - 2*$ytop);
152
+        $maxheighttouse -= (empty($footer)?0:(1+$this->_Line_Height));
153
+        $defaultratio = ($maxwidthtouse/$maxheighttouse);
154
+        $widthtouse = $maxwidthtouse;
155
+        $heighttouse = $maxheighttouse;
156
+        $logoHeight = $heighttouse;
157
+        $logoWidth = $heighttouse;
158
+
159
+        //var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit;
160
+
161
+        // Center
162
+        if ($textright=='')	// Only a left part
163
+        {
164
+            // Output left area
165
+            if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, 0, $logoHeight);
166
+            else if ($code && !empty($encoding))
167
+            {
168
+                $this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse, $heighttouse);
169
+            }
170
+            else
171
+            {
172
+                $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
173
+                $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
174
+            }
175
+        }
176
+        else if ($textleft!='' && $textright!='')	// left and right part
177
+        {
178
+            if (($textleft == '%LOGO%' || $textleft == '%PHOTO%' || $textleft == '%BARCODE%') && !strstr($textright, '%') )	 // left part logo/barcode right part text
179
+            {
180
+                if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, $widthtouse/2, 0);
181
+                else if ($code && !empty($encoding))
182
+                {
183
+                    $this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse/2, $heighttouse);
184
+                }
185
+                $pdf->SetXY($_PosX+($widthtouse/2), $_PosY+$ytop);
186
+                $pdf->MultiCell($widthtouse/2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
187
+            }
188
+            else if (($textright == '%LOGO%' || $textright == '%PHOTO%' || $textright == '%BARCODE%') && !strstr($textleft, '%')) // right part logo/barcode left part text
189
+            {
190
+                if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+($widthtouse/2), $_PosY+$ytop, $widthtouse/2, 0);
191
+                else if ($code && !empty($encoding))
192
+                {
193
+                    $this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+($widthtouse/2), $_PosY+$ytop, $widthtouse/2, $heighttouse);
194
+                }
195
+                $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
196
+                $pdf->MultiCell($widthtouse/2, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
197
+            }
198
+            else if ($textleft == '%LOGO%')	 // left part logo right part text/barcode
199
+            {
200
+                if ($logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, 0, $logoHeight);
201
+                if ($code && !empty($encoding))
202
+                {
203
+                    $this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft+$logoWidth+1, $_PosY+$ytop, $widthtouse-$logoWidth-1, $heighttouse);
204
+                } else {
205
+                    $pdf->SetXY($_PosX+$xleft+$logoWidth+1, $_PosY+$ytop);
206
+                    $pdf->MultiCell($widthtouse-$logoWidth1-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
207
+                }
208
+            }
209
+            else if ($textright == '%LOGO%')  // right part logo left part text/barcode
210
+            {
211
+                if ($logo) $pdf->Image($logo, $_PosX+$xleft+$widthtouse-$logoWidth+1, $_PosY+$ytop, 0, $logoHeight);
212
+                if ($code && !empty($encoding))
213
+                {
214
+                    $this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse-$logoWidth-1, $heighttouse);
215
+                } else {
216
+                    $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
217
+                    $pdf->MultiCell($widthtouse-$logoWidth-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
218
+                }
219
+            }
220
+            else	// text on halft left and text on half right
221
+            {
222
+                $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
223
+                $pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
224
+                $pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop);
225
+                $pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
226
+            }
227
+        }
228
+        else	// Only a right part
229
+        {
230
+            // Output right area
231
+            if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$this->_Width-$widthtouse-$xleft, $_PosY+$ytop, 0, $logoHeight);
232
+            else if ($code && !empty($encoding))
233
+            {
234
+                $this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$this->_Width-$widthtouse-$xleft, $_PosY+$ytop, $widthtouse, $heighttouse);
235
+            }
236
+            else
237
+            {
238
+                $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
239
+                $pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
240
+            }
241
+        }
242
+
243
+        // Bottom
244
+        if ($footer!='')
245
+        {
246
+            $pdf->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1);
247
+            $pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C');
248
+        }
249
+        //print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n";
250
+
251
+        $this->_COUNTY++;
252
+
253
+        if ($this->_COUNTY == $this->_Y_Number) {
254
+            // Si on est en bas de page, on remonte le 'curseur' de position
255
+            $this->_COUNTX++;
256
+            $this->_COUNTY=0;
257
+        }
258
+
259
+        if ($this->_COUNTX == $this->_X_Number) {
260
+            // Si on est en bout de page, alors on repart sur une nouvelle page
261
+            $this->_COUNTX=0;
262
+            $this->_COUNTY=0;
263
+        }
264
+    }
265 265
 
266 266
 
267 267
 
268 268
 
269 269
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
270
-	/**
271
-	 *	Function to build PDF on disk, then output on HTTP strem.
272
-	 *
273
-	 *	@param	array		$arrayofrecords		Array of record informations (array('textleft'=>,'textheader'=>, ..., 'id'=>,'photo'=>)
274
-	 *	@param	Translate	$outputlangs		Lang object for output language
275
-	 *	@param	string		$srctemplatepath	Full path of source filename for generator using a template file
276
-	 *	@param	string		$outputdir			Output directory for pdf file
277
-	 *  @param  string      $filename           Short file name of PDF output file
278
-	 *	@return int								1=OK, 0=KO
279
-	 */
280
-	function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$outputdir='',$filename='tmp_address_sheet.pdf')
281
-	{
270
+    /**
271
+     *	Function to build PDF on disk, then output on HTTP strem.
272
+     *
273
+     *	@param	array		$arrayofrecords		Array of record informations (array('textleft'=>,'textheader'=>, ..., 'id'=>,'photo'=>)
274
+     *	@param	Translate	$outputlangs		Lang object for output language
275
+     *	@param	string		$srctemplatepath	Full path of source filename for generator using a template file
276
+     *	@param	string		$outputdir			Output directory for pdf file
277
+     *  @param  string      $filename           Short file name of PDF output file
278
+     *	@return int								1=OK, 0=KO
279
+     */
280
+    function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$outputdir='',$filename='tmp_address_sheet.pdf')
281
+    {
282 282
         // phpcs:enable
283
-		global $user,$conf,$langs,$mysoc,$_Avery_Labels;
283
+        global $user,$conf,$langs,$mysoc,$_Avery_Labels;
284 284
 
285
-		$this->code=$srctemplatepath;
286
-		$this->Tformat = $_Avery_Labels[$this->code];
287
-		if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
288
-		$this->type = 'pdf';
285
+        $this->code=$srctemplatepath;
286
+        $this->Tformat = $_Avery_Labels[$this->code];
287
+        if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
288
+        $this->type = 'pdf';
289 289
         // standard format or custom
290 290
         if ($this->Tformat['paper-size']!='custom') {
291 291
             $this->format = $this->Tformat['paper-size'];
@@ -295,99 +295,99 @@  discard block
 block discarded – undo
295 295
             $this->format = $resolution;
296 296
         }
297 297
 
298
-		if (! is_object($outputlangs)) $outputlangs=$langs;
299
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
300
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
301
-
302
-		// Load traductions files requiredby by page
303
-		$outputlangs->loadLangs(array("main", "dict", "companies", "admin"));
304
-
305
-		$title=$outputlangs->transnoentities('Labels');
306
-		$keywords=$title." ".$outputlangs->convToOutputCharset($mysoc->name);
307
-
308
-		$dir = (empty($outputdir)?$conf->adherent->dir_temp:$outputdir);
309
-		$file = $dir."/".$filename;
298
+        if (! is_object($outputlangs)) $outputlangs=$langs;
299
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
300
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
310 301
 
311
-		if (! file_exists($dir))
312
-		{
313
-			if (dol_mkdir($dir) < 0)
314
-			{
315
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
316
-				return 0;
317
-			}
318
-		}
302
+        // Load traductions files requiredby by page
303
+        $outputlangs->loadLangs(array("main", "dict", "companies", "admin"));
319 304
 
320
-		$pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']);
305
+        $title=$outputlangs->transnoentities('Labels');
306
+        $keywords=$title." ".$outputlangs->convToOutputCharset($mysoc->name);
321 307
 
322
-		if (class_exists('TCPDF'))
323
-		{
324
-			$pdf->setPrintHeader(false);
325
-			$pdf->setPrintFooter(false);
326
-		}
327
-		$pdf->SetFont(pdf_getPDFFont($outputlangs));
308
+        $dir = (empty($outputdir)?$conf->adherent->dir_temp:$outputdir);
309
+        $file = $dir."/".$filename;
328 310
 
329
-		$pdf->SetTitle($title);
330
-		$pdf->SetSubject($title);
331
-		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
332
-		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
333
-		$pdf->SetKeyWords($keywords);
334
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
335
-
336
-		$pdf->SetMargins(0,0);
337
-		$pdf->SetAutoPageBreak(false);
338
-
339
-		$this->_Metric_Doc = $this->Tformat['metric'];
340
-		// Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
341
-		$posX=1;
342
-		$posY=1;
343
-		if ($posX > 0) $posX--; else $posX=0;
344
-		if ($posY > 0) $posY--; else $posY=0;
345
-		$this->_COUNTX = $posX;
346
-		$this->_COUNTY = $posY;
347
-		$this->_Set_Format($pdf, $this->Tformat);
348
-
349
-
350
-		$pdf->Open();
351
-		$pdf->AddPage();
311
+        if (! file_exists($dir))
312
+        {
313
+            if (dol_mkdir($dir) < 0)
314
+            {
315
+                $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
316
+                return 0;
317
+            }
318
+        }
352 319
 
320
+        $pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']);
353 321
 
354
-		// Add each record
355
-		foreach($arrayofrecords as $val)
356
-		{
357
-			// imprime le texte specifique sur la carte
358
-			$this->addSticker($pdf, $outputlangs, $val);
359
-		}
322
+        if (class_exists('TCPDF'))
323
+        {
324
+            $pdf->setPrintHeader(false);
325
+            $pdf->setPrintFooter(false);
326
+        }
327
+        $pdf->SetFont(pdf_getPDFFont($outputlangs));
328
+
329
+        $pdf->SetTitle($title);
330
+        $pdf->SetSubject($title);
331
+        $pdf->SetCreator("Dolibarr ".DOL_VERSION);
332
+        $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
333
+        $pdf->SetKeyWords($keywords);
334
+        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
335
+
336
+        $pdf->SetMargins(0,0);
337
+        $pdf->SetAutoPageBreak(false);
338
+
339
+        $this->_Metric_Doc = $this->Tformat['metric'];
340
+        // Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
341
+        $posX=1;
342
+        $posY=1;
343
+        if ($posX > 0) $posX--; else $posX=0;
344
+        if ($posY > 0) $posY--; else $posY=0;
345
+        $this->_COUNTX = $posX;
346
+        $this->_COUNTY = $posY;
347
+        $this->_Set_Format($pdf, $this->Tformat);
348
+
349
+
350
+        $pdf->Open();
351
+        $pdf->AddPage();
352
+
353
+
354
+        // Add each record
355
+        foreach($arrayofrecords as $val)
356
+        {
357
+            // imprime le texte specifique sur la carte
358
+            $this->addSticker($pdf, $outputlangs, $val);
359
+        }
360 360
 
361
-		//$pdf->SetXY(10, 295);
362
-		//$pdf->Cell($this->_Width, $this->_Line_Height, 'XXX',0,1,'C');
361
+        //$pdf->SetXY(10, 295);
362
+        //$pdf->Cell($this->_Width, $this->_Line_Height, 'XXX',0,1,'C');
363 363
 
364 364
 
365
-		// Output to file
366
-		$pdf->Output($file,'F');
365
+        // Output to file
366
+        $pdf->Output($file,'F');
367 367
 
368
-		if (! empty($conf->global->MAIN_UMASK))
369
-			@chmod($file, octdec($conf->global->MAIN_UMASK));
368
+        if (! empty($conf->global->MAIN_UMASK))
369
+            @chmod($file, octdec($conf->global->MAIN_UMASK));
370 370
 
371
-		// Output to http stream
372
-		clearstatcache();
371
+        // Output to http stream
372
+        clearstatcache();
373 373
 
374
-		$attachment=true;
375
-		if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
376
-		$type=dol_mimetype($filename);
374
+        $attachment=true;
375
+        if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
376
+        $type=dol_mimetype($filename);
377 377
 
378
-		//if ($encoding)   header('Content-Encoding: '.$encoding);
379
-		if ($type)		 header('Content-Type: '.$type);
380
-		if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
381
-		else header('Content-Disposition: inline; filename="'.$filename.'"');
378
+        //if ($encoding)   header('Content-Encoding: '.$encoding);
379
+        if ($type)		 header('Content-Type: '.$type);
380
+        if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
381
+        else header('Content-Disposition: inline; filename="'.$filename.'"');
382 382
 
383
-		// Ajout directives pour resoudre bug IE
384
-		header('Cache-Control: Public, must-revalidate');
385
-		header('Pragma: public');
383
+        // Ajout directives pour resoudre bug IE
384
+        header('Cache-Control: Public, must-revalidate');
385
+        header('Pragma: public');
386 386
 
387
-		readfile($file);
387
+        readfile($file);
388 388
 
389
-		$this->result = array('fullpath'=>$file);
389
+        $this->result = array('fullpath'=>$file);
390 390
 
391
-		return 1;
392
-	}
391
+        return 1;
392
+    }
393 393
 }
Please login to merge, or discard this patch.
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 					'border' => false,
44 44
 					'hpadding' => 'auto',
45 45
 					'vpadding' => 'auto',
46
-					'fgcolor' => array(0,0,0),
46
+					'fgcolor' => array(0, 0, 0),
47 47
 					'bgcolor' => false,
48 48
 					'text' => true,
49 49
 					'font' => 'helvetica',
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 					'border' => false,
57 57
 					'vpadding' => 'auto',
58 58
 					'hpadding' => 'auto',
59
-					'fgcolor' => array(0,0,0),
59
+					'fgcolor' => array(0, 0, 0),
60 60
 					'bgcolor' => false,
61 61
 					'module_width' => 1, // width of a single module in points
62 62
 					'module_height' => 1 // height of a single module in points
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
 	 * @param	array		$param			Associative array containing label content and optional parameters
97 97
 	 * @return	void
98 98
 	 */
99
-	function addSticker(&$pdf,$outputlangs,$param)
99
+	function addSticker(&$pdf, $outputlangs, $param)
100 100
 	{
101
-		global $mysoc,$conf;
101
+		global $mysoc, $conf;
102 102
 
103 103
 		$textleft = $param['textleft'];
104 104
 		$header = $param['textheader'];
@@ -111,25 +111,25 @@  discard block
 block discarded – undo
111 111
 
112 112
 
113 113
 		// We are in a new page, then we must add a page
114
-		if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) {
114
+		if (($this->_COUNTX == 0) && ($this->_COUNTY == 0) and (!$this->_First == 1)) {
115 115
 			$pdf->AddPage();
116 116
 		}
117
-		$this->_First=0;
118
-		$_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space));
119
-		$_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space));
117
+		$this->_First = 0;
118
+		$_PosX = $this->_Margin_Left + ($this->_COUNTX * ($this->_Width + $this->_X_Space));
119
+		$_PosY = $this->_Margin_Top + ($this->_COUNTY * ($this->_Height + $this->_Y_Space));
120 120
 
121 121
 		// Define logo
122
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
123
-		if (! is_readable($logo))
122
+		$logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
123
+		if (!is_readable($logo))
124 124
 		{
125
-			$logo='';
126
-			if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
125
+			$logo = '';
126
+			if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
127 127
 			{
128
-				$logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
128
+				$logo = $conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
129 129
 			}
130
-			elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
130
+			elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
131 131
 			{
132
-				$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
132
+				$logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
133 133
 			}
134 134
 		}
135 135
 
@@ -137,20 +137,20 @@  discard block
 block discarded – undo
137 137
 		$ytop = 2;
138 138
 
139 139
 		// Top
140
-		if ($header!='')
140
+		if ($header != '')
141 141
 		{
142
-			$pdf->SetXY($_PosX+$xleft, $_PosY+1); // Only 1 mm and not ytop for top text
143
-			$pdf->Cell($this->_Width-2*$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C');
142
+			$pdf->SetXY($_PosX + $xleft, $_PosY + 1); // Only 1 mm and not ytop for top text
143
+			$pdf->Cell($this->_Width - 2 * $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header), 0, 1, 'C');
144 144
 		}
145 145
 
146
-		$ytop += (empty($header)?0:(1+$this->_Line_Height));
146
+		$ytop += (empty($header) ? 0 : (1 + $this->_Line_Height));
147 147
 
148 148
 		// Define widthtouse and heighttouse
149 149
 		$pageMargins = $pdf->getMargins();
150
-		$maxwidthtouse = round($this->_Width - 2*$xleft);
151
-		$maxheighttouse = round($this->_Height - 2*$ytop);
152
-		$maxheighttouse -= (empty($footer)?0:(1+$this->_Line_Height));
153
-		$defaultratio = ($maxwidthtouse/$maxheighttouse);
150
+		$maxwidthtouse = round($this->_Width - 2 * $xleft);
151
+		$maxheighttouse = round($this->_Height - 2 * $ytop);
152
+		$maxheighttouse -= (empty($footer) ? 0 : (1 + $this->_Line_Height));
153
+		$defaultratio = ($maxwidthtouse / $maxheighttouse);
154 154
 		$widthtouse = $maxwidthtouse;
155 155
 		$heighttouse = $maxheighttouse;
156 156
 		$logoHeight = $heighttouse;
@@ -159,92 +159,92 @@  discard block
 block discarded – undo
159 159
 		//var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit;
160 160
 
161 161
 		// Center
162
-		if ($textright=='')	// Only a left part
162
+		if ($textright == '')	// Only a left part
163 163
 		{
164 164
 			// Output left area
165
-			if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, 0, $logoHeight);
165
+			if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, 0, $logoHeight);
166 166
 			else if ($code && !empty($encoding))
167 167
 			{
168
-				$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse, $heighttouse);
168
+				$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
169 169
 			}
170 170
 			else
171 171
 			{
172
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
173
-				$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
172
+				$pdf->SetXY($_PosX + $xleft, $_PosY + $ytop);
173
+				$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L');
174 174
 			}
175 175
 		}
176
-		else if ($textleft!='' && $textright!='')	// left and right part
176
+		else if ($textleft != '' && $textright != '')	// left and right part
177 177
 		{
178
-			if (($textleft == '%LOGO%' || $textleft == '%PHOTO%' || $textleft == '%BARCODE%') && !strstr($textright, '%') )	 // left part logo/barcode right part text
178
+			if (($textleft == '%LOGO%' || $textleft == '%PHOTO%' || $textleft == '%BARCODE%') && !strstr($textright, '%'))	 // left part logo/barcode right part text
179 179
 			{
180
-				if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, $widthtouse/2, 0);
180
+				if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse / 2, 0);
181 181
 				else if ($code && !empty($encoding))
182 182
 				{
183
-					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse/2, $heighttouse);
183
+					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX + $xleft, $_PosY + $ytop, $widthtouse / 2, $heighttouse);
184 184
 				}
185
-				$pdf->SetXY($_PosX+($widthtouse/2), $_PosY+$ytop);
186
-				$pdf->MultiCell($widthtouse/2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
185
+				$pdf->SetXY($_PosX + ($widthtouse / 2), $_PosY + $ytop);
186
+				$pdf->MultiCell($widthtouse / 2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
187 187
 			}
188 188
 			else if (($textright == '%LOGO%' || $textright == '%PHOTO%' || $textright == '%BARCODE%') && !strstr($textleft, '%')) // right part logo/barcode left part text
189 189
 			{
190
-				if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+($widthtouse/2), $_PosY+$ytop, $widthtouse/2, 0);
190
+				if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + ($widthtouse / 2), $_PosY + $ytop, $widthtouse / 2, 0);
191 191
 				else if ($code && !empty($encoding))
192 192
 				{
193
-					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+($widthtouse/2), $_PosY+$ytop, $widthtouse/2, $heighttouse);
193
+					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX + ($widthtouse / 2), $_PosY + $ytop, $widthtouse / 2, $heighttouse);
194 194
 				}
195
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
196
-				$pdf->MultiCell($widthtouse/2, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
195
+				$pdf->SetXY($_PosX + $xleft, $_PosY + $ytop);
196
+				$pdf->MultiCell($widthtouse / 2, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L');
197 197
 			}
198 198
 			else if ($textleft == '%LOGO%')	 // left part logo right part text/barcode
199 199
 			{
200
-				if ($logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, 0, $logoHeight);
200
+				if ($logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, 0, $logoHeight);
201 201
 				if ($code && !empty($encoding))
202 202
 				{
203
-					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft+$logoWidth+1, $_PosY+$ytop, $widthtouse-$logoWidth-1, $heighttouse);
203
+					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX + $xleft + $logoWidth + 1, $_PosY + $ytop, $widthtouse - $logoWidth - 1, $heighttouse);
204 204
 				} else {
205
-					$pdf->SetXY($_PosX+$xleft+$logoWidth+1, $_PosY+$ytop);
206
-					$pdf->MultiCell($widthtouse-$logoWidth1-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
205
+					$pdf->SetXY($_PosX + $xleft + $logoWidth + 1, $_PosY + $ytop);
206
+					$pdf->MultiCell($widthtouse - $logoWidth1 - 1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
207 207
 				}
208 208
 			}
209 209
 			else if ($textright == '%LOGO%')  // right part logo left part text/barcode
210 210
 			{
211
-				if ($logo) $pdf->Image($logo, $_PosX+$xleft+$widthtouse-$logoWidth+1, $_PosY+$ytop, 0, $logoHeight);
211
+				if ($logo) $pdf->Image($logo, $_PosX + $xleft + $widthtouse - $logoWidth + 1, $_PosY + $ytop, 0, $logoHeight);
212 212
 				if ($code && !empty($encoding))
213 213
 				{
214
-					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse-$logoWidth-1, $heighttouse);
214
+					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX + $xleft, $_PosY + $ytop, $widthtouse - $logoWidth - 1, $heighttouse);
215 215
 				} else {
216
-					$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
217
-					$pdf->MultiCell($widthtouse-$logoWidth-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
216
+					$pdf->SetXY($_PosX + $xleft, $_PosY + $ytop);
217
+					$pdf->MultiCell($widthtouse - $logoWidth - 1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L');
218 218
 				}
219 219
 			}
220 220
 			else	// text on halft left and text on half right
221 221
 			{
222
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
223
-				$pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
224
-				$pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop);
225
-				$pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
222
+				$pdf->SetXY($_PosX + $xleft, $_PosY + $ytop);
223
+				$pdf->MultiCell(round($this->_Width / 2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L');
224
+				$pdf->SetXY($_PosX + round($this->_Width / 2), $_PosY + $ytop);
225
+				$pdf->MultiCell(round($this->_Width / 2) - 2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
226 226
 			}
227 227
 		}
228 228
 		else	// Only a right part
229 229
 		{
230 230
 			// Output right area
231
-			if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$this->_Width-$widthtouse-$xleft, $_PosY+$ytop, 0, $logoHeight);
231
+			if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, 0, $logoHeight);
232 232
 			else if ($code && !empty($encoding))
233 233
 			{
234
-				$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$this->_Width-$widthtouse-$xleft, $_PosY+$ytop, $widthtouse, $heighttouse);
234
+				$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
235 235
 			}
236 236
 			else
237 237
 			{
238
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
239
-				$pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
238
+				$pdf->SetXY($_PosX + $xleft, $_PosY + $ytop);
239
+				$pdf->MultiCell($this->_Width - $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
240 240
 			}
241 241
 		}
242 242
 
243 243
 		// Bottom
244
-		if ($footer!='')
244
+		if ($footer != '')
245 245
 		{
246
-			$pdf->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1);
247
-			$pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C');
246
+			$pdf->SetXY($_PosX, $_PosY + $this->_Height - $this->_Line_Height - 1);
247
+			$pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer), 0, 1, 'C');
248 248
 		}
249 249
 		//print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n";
250 250
 
@@ -253,13 +253,13 @@  discard block
 block discarded – undo
253 253
 		if ($this->_COUNTY == $this->_Y_Number) {
254 254
 			// Si on est en bas de page, on remonte le 'curseur' de position
255 255
 			$this->_COUNTX++;
256
-			$this->_COUNTY=0;
256
+			$this->_COUNTY = 0;
257 257
 		}
258 258
 
259 259
 		if ($this->_COUNTX == $this->_X_Number) {
260 260
 			// Si on est en bout de page, alors on repart sur une nouvelle page
261
-			$this->_COUNTX=0;
262
-			$this->_COUNTY=0;
261
+			$this->_COUNTX = 0;
262
+			$this->_COUNTY = 0;
263 263
 		}
264 264
 	}
265 265
 
@@ -277,47 +277,47 @@  discard block
 block discarded – undo
277 277
 	 *  @param  string      $filename           Short file name of PDF output file
278 278
 	 *	@return int								1=OK, 0=KO
279 279
 	 */
280
-	function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$outputdir='',$filename='tmp_address_sheet.pdf')
280
+	function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = '', $filename = 'tmp_address_sheet.pdf')
281 281
 	{
282 282
         // phpcs:enable
283
-		global $user,$conf,$langs,$mysoc,$_Avery_Labels;
283
+		global $user, $conf, $langs, $mysoc, $_Avery_Labels;
284 284
 
285
-		$this->code=$srctemplatepath;
285
+		$this->code = $srctemplatepath;
286 286
 		$this->Tformat = $_Avery_Labels[$this->code];
287
-		if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
287
+		if (empty($this->Tformat)) { dol_print_error('', 'ErrorBadTypeForCard'.$this->code); exit; }
288 288
 		$this->type = 'pdf';
289 289
         // standard format or custom
290
-        if ($this->Tformat['paper-size']!='custom') {
290
+        if ($this->Tformat['paper-size'] != 'custom') {
291 291
             $this->format = $this->Tformat['paper-size'];
292 292
         } else {
293 293
             //custom
294
-            $resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']);
294
+            $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']);
295 295
             $this->format = $resolution;
296 296
         }
297 297
 
298
-		if (! is_object($outputlangs)) $outputlangs=$langs;
298
+		if (!is_object($outputlangs)) $outputlangs = $langs;
299 299
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
300
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
300
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
301 301
 
302 302
 		// Load traductions files requiredby by page
303 303
 		$outputlangs->loadLangs(array("main", "dict", "companies", "admin"));
304 304
 
305
-		$title=$outputlangs->transnoentities('Labels');
306
-		$keywords=$title." ".$outputlangs->convToOutputCharset($mysoc->name);
305
+		$title = $outputlangs->transnoentities('Labels');
306
+		$keywords = $title." ".$outputlangs->convToOutputCharset($mysoc->name);
307 307
 
308
-		$dir = (empty($outputdir)?$conf->adherent->dir_temp:$outputdir);
308
+		$dir = (empty($outputdir) ? $conf->adherent->dir_temp : $outputdir);
309 309
 		$file = $dir."/".$filename;
310 310
 
311
-		if (! file_exists($dir))
311
+		if (!file_exists($dir))
312 312
 		{
313 313
 			if (dol_mkdir($dir) < 0)
314 314
 			{
315
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
315
+				$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
316 316
 				return 0;
317 317
 			}
318 318
 		}
319 319
 
320
-		$pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']);
320
+		$pdf = pdf_getInstance($this->format, $this->Tformat['metric'], $this->Tformat['orientation']);
321 321
 
322 322
 		if (class_exists('TCPDF'))
323 323
 		{
@@ -331,17 +331,17 @@  discard block
 block discarded – undo
331 331
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
332 332
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
333 333
 		$pdf->SetKeyWords($keywords);
334
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
334
+		if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
335 335
 
336
-		$pdf->SetMargins(0,0);
336
+		$pdf->SetMargins(0, 0);
337 337
 		$pdf->SetAutoPageBreak(false);
338 338
 
339 339
 		$this->_Metric_Doc = $this->Tformat['metric'];
340 340
 		// Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
341
-		$posX=1;
342
-		$posY=1;
343
-		if ($posX > 0) $posX--; else $posX=0;
344
-		if ($posY > 0) $posY--; else $posY=0;
341
+		$posX = 1;
342
+		$posY = 1;
343
+		if ($posX > 0) $posX--; else $posX = 0;
344
+		if ($posY > 0) $posY--; else $posY = 0;
345 345
 		$this->_COUNTX = $posX;
346 346
 		$this->_COUNTY = $posY;
347 347
 		$this->_Set_Format($pdf, $this->Tformat);
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 
353 353
 
354 354
 		// Add each record
355
-		foreach($arrayofrecords as $val)
355
+		foreach ($arrayofrecords as $val)
356 356
 		{
357 357
 			// imprime le texte specifique sur la carte
358 358
 			$this->addSticker($pdf, $outputlangs, $val);
@@ -363,17 +363,17 @@  discard block
 block discarded – undo
363 363
 
364 364
 
365 365
 		// Output to file
366
-		$pdf->Output($file,'F');
366
+		$pdf->Output($file, 'F');
367 367
 
368
-		if (! empty($conf->global->MAIN_UMASK))
368
+		if (!empty($conf->global->MAIN_UMASK))
369 369
 			@chmod($file, octdec($conf->global->MAIN_UMASK));
370 370
 
371 371
 		// Output to http stream
372 372
 		clearstatcache();
373 373
 
374
-		$attachment=true;
375
-		if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
376
-		$type=dol_mimetype($filename);
374
+		$attachment = true;
375
+		if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false;
376
+		$type = dol_mimetype($filename);
377 377
 
378 378
 		//if ($encoding)   header('Content-Encoding: '.$encoding);
379 379
 		if ($type)		 header('Content-Type: '.$type);
Please login to merge, or discard this patch.
Braces   +56 added lines, -35 removed lines patch added patch discarded remove patch
@@ -126,8 +126,7 @@  discard block
 block discarded – undo
126 126
 			if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
127 127
 			{
128 128
 				$logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
129
-			}
130
-			elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
129
+			} elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
131 130
 			{
132 131
 				$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
133 132
 			}
@@ -159,45 +158,46 @@  discard block
 block discarded – undo
159 158
 		//var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit;
160 159
 
161 160
 		// Center
162
-		if ($textright=='')	// Only a left part
161
+		if ($textright=='') {
162
+		    // Only a left part
163 163
 		{
164 164
 			// Output left area
165 165
 			if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, 0, $logoHeight);
166
-			else if ($code && !empty($encoding))
166
+		} else if ($code && !empty($encoding))
167 167
 			{
168 168
 				$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse, $heighttouse);
169
-			}
170
-			else
169
+			} else
171 170
 			{
172 171
 				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
173 172
 				$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
174 173
 			}
175
-		}
176
-		else if ($textleft!='' && $textright!='')	// left and right part
174
+		} else if ($textleft!='' && $textright!='') {
175
+		    // left and right part
177 176
 		{
178 177
 			if (($textleft == '%LOGO%' || $textleft == '%PHOTO%' || $textleft == '%BARCODE%') && !strstr($textright, '%') )	 // left part logo/barcode right part text
179 178
 			{
180 179
 				if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, $widthtouse/2, 0);
181
-				else if ($code && !empty($encoding))
180
+		} else if ($code && !empty($encoding))
182 181
 				{
183 182
 					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse/2, $heighttouse);
184 183
 				}
185 184
 				$pdf->SetXY($_PosX+($widthtouse/2), $_PosY+$ytop);
186 185
 				$pdf->MultiCell($widthtouse/2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
187
-			}
188
-			else if (($textright == '%LOGO%' || $textright == '%PHOTO%' || $textright == '%BARCODE%') && !strstr($textleft, '%')) // right part logo/barcode left part text
186
+			} else if (($textright == '%LOGO%' || $textright == '%PHOTO%' || $textright == '%BARCODE%') && !strstr($textleft, '%')) {
187
+			    // right part logo/barcode left part text
189 188
 			{
190 189
 				if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+($widthtouse/2), $_PosY+$ytop, $widthtouse/2, 0);
191
-				else if ($code && !empty($encoding))
190
+			} else if ($code && !empty($encoding))
192 191
 				{
193 192
 					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+($widthtouse/2), $_PosY+$ytop, $widthtouse/2, $heighttouse);
194 193
 				}
195 194
 				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
196 195
 				$pdf->MultiCell($widthtouse/2, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
197
-			}
198
-			else if ($textleft == '%LOGO%')	 // left part logo right part text/barcode
196
+			} else if ($textleft == '%LOGO%') {
197
+			    // left part logo right part text/barcode
199 198
 			{
200 199
 				if ($logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, 0, $logoHeight);
200
+			}
201 201
 				if ($code && !empty($encoding))
202 202
 				{
203 203
 					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft+$logoWidth+1, $_PosY+$ytop, $widthtouse-$logoWidth-1, $heighttouse);
@@ -205,10 +205,11 @@  discard block
 block discarded – undo
205 205
 					$pdf->SetXY($_PosX+$xleft+$logoWidth+1, $_PosY+$ytop);
206 206
 					$pdf->MultiCell($widthtouse-$logoWidth1-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
207 207
 				}
208
-			}
209
-			else if ($textright == '%LOGO%')  // right part logo left part text/barcode
208
+			} else if ($textright == '%LOGO%') {
209
+			    // right part logo left part text/barcode
210 210
 			{
211 211
 				if ($logo) $pdf->Image($logo, $_PosX+$xleft+$widthtouse-$logoWidth+1, $_PosY+$ytop, 0, $logoHeight);
212
+			}
212 213
 				if ($code && !empty($encoding))
213 214
 				{
214 215
 					$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse-$logoWidth-1, $heighttouse);
@@ -216,24 +217,22 @@  discard block
 block discarded – undo
216 217
 					$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
217 218
 					$pdf->MultiCell($widthtouse-$logoWidth-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
218 219
 				}
219
-			}
220
-			else	// text on halft left and text on half right
220
+			} else	// text on halft left and text on half right
221 221
 			{
222 222
 				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
223 223
 				$pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
224 224
 				$pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop);
225 225
 				$pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
226 226
 			}
227
-		}
228
-		else	// Only a right part
227
+		} else	// Only a right part
229 228
 		{
230 229
 			// Output right area
231
-			if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$this->_Width-$widthtouse-$xleft, $_PosY+$ytop, 0, $logoHeight);
232
-			else if ($code && !empty($encoding))
230
+			if ($textright == '%LOGO%' && $logo) {
231
+			    $pdf->Image($logo, $_PosX+$this->_Width-$widthtouse-$xleft, $_PosY+$ytop, 0, $logoHeight);
232
+			} else if ($code && !empty($encoding))
233 233
 			{
234 234
 				$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$this->_Width-$widthtouse-$xleft, $_PosY+$ytop, $widthtouse, $heighttouse);
235
-			}
236
-			else
235
+			} else
237 236
 			{
238 237
 				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
239 238
 				$pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
@@ -295,9 +294,13 @@  discard block
 block discarded – undo
295 294
             $this->format = $resolution;
296 295
         }
297 296
 
298
-		if (! is_object($outputlangs)) $outputlangs=$langs;
297
+		if (! is_object($outputlangs)) {
298
+		    $outputlangs=$langs;
299
+		}
299 300
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
300
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
301
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
302
+		    $outputlangs->charset_output='ISO-8859-1';
303
+		}
301 304
 
302 305
 		// Load traductions files requiredby by page
303 306
 		$outputlangs->loadLangs(array("main", "dict", "companies", "admin"));
@@ -331,7 +334,9 @@  discard block
 block discarded – undo
331 334
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
332 335
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
333 336
 		$pdf->SetKeyWords($keywords);
334
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
337
+		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
338
+		    $pdf->SetCompression(false);
339
+		}
335 340
 
336 341
 		$pdf->SetMargins(0,0);
337 342
 		$pdf->SetAutoPageBreak(false);
@@ -340,8 +345,16 @@  discard block
 block discarded – undo
340 345
 		// Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
341 346
 		$posX=1;
342 347
 		$posY=1;
343
-		if ($posX > 0) $posX--; else $posX=0;
344
-		if ($posY > 0) $posY--; else $posY=0;
348
+		if ($posX > 0) {
349
+		    $posX--;
350
+		} else {
351
+		    $posX=0;
352
+		}
353
+		if ($posY > 0) {
354
+		    $posY--;
355
+		} else {
356
+		    $posY=0;
357
+		}
345 358
 		$this->_COUNTX = $posX;
346 359
 		$this->_COUNTY = $posY;
347 360
 		$this->_Set_Format($pdf, $this->Tformat);
@@ -365,20 +378,28 @@  discard block
 block discarded – undo
365 378
 		// Output to file
366 379
 		$pdf->Output($file,'F');
367 380
 
368
-		if (! empty($conf->global->MAIN_UMASK))
369
-			@chmod($file, octdec($conf->global->MAIN_UMASK));
381
+		if (! empty($conf->global->MAIN_UMASK)) {
382
+					@chmod($file, octdec($conf->global->MAIN_UMASK));
383
+		}
370 384
 
371 385
 		// Output to http stream
372 386
 		clearstatcache();
373 387
 
374 388
 		$attachment=true;
375
-		if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
389
+		if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) {
390
+		    $attachment=false;
391
+		}
376 392
 		$type=dol_mimetype($filename);
377 393
 
378 394
 		//if ($encoding)   header('Content-Encoding: '.$encoding);
379
-		if ($type)		 header('Content-Type: '.$type);
380
-		if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
381
-		else header('Content-Disposition: inline; filename="'.$filename.'"');
395
+		if ($type) {
396
+		    header('Content-Type: '.$type);
397
+		}
398
+		if ($attachment) {
399
+		    header('Content-Disposition: attachment; filename="'.$filename.'"');
400
+		} else {
401
+		    header('Content-Disposition: inline; filename="'.$filename.'"');
402
+		}
382 403
 
383 404
 		// Ajout directives pour resoudre bug IE
384 405
 		header('Cache-Control: Public, must-revalidate');
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php 3 patches
Indentation   +280 added lines, -280 removed lines patch added patch discarded remove patch
@@ -33,220 +33,220 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class pdf_standardlabel extends CommonStickerGenerator
35 35
 {
36
-	/**
37
-	 * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
38
-	 *
39
-	 * @param	PDF			$pdf			PDF reference
40
-	 * @param	Translate	$outputlangs	Output langs
41
-	 * @param	array		$param			Associative array containing label content and optional parameters
42
-	 * @return	void
43
-	 */
36
+    /**
37
+     * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
38
+     *
39
+     * @param	PDF			$pdf			PDF reference
40
+     * @param	Translate	$outputlangs	Output langs
41
+     * @param	array		$param			Associative array containing label content and optional parameters
42
+     * @return	void
43
+     */
44 44
     function addSticker(&$pdf,$outputlangs,$param)
45 45
     {
46
-		// use this method in future refactoring
47
-	}
46
+        // use this method in future refactoring
47
+    }
48 48
 
49 49
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
50
-	/**
51
-	 * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
52
-	 * - %LOGO% is replace with company logo
53
-	 * - %PHOTO% is replace with photo provided as parameter
54
-	 *
55
-	 * @param	PDF			$pdf			PDF reference
56
-	 * @param	string		$textleft		Text left
57
-	 * @param	string		$header			Header
58
-	 * @param	string		$footer			Footer
59
-	 * @param	Translate	$outputlangs	Output langs
60
-	 * @param	string		$textright		Text right
61
-	 * @param	string		$photo			Photo (full path to image file used as replacement for key %PHOTOS% into left, right, header or footer text)
62
-	 * @return	void
63
-	 */
64
-	function Add_PDF_label(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$photo='')
65
-	{
50
+    /**
51
+     * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
52
+     * - %LOGO% is replace with company logo
53
+     * - %PHOTO% is replace with photo provided as parameter
54
+     *
55
+     * @param	PDF			$pdf			PDF reference
56
+     * @param	string		$textleft		Text left
57
+     * @param	string		$header			Header
58
+     * @param	string		$footer			Footer
59
+     * @param	Translate	$outputlangs	Output langs
60
+     * @param	string		$textright		Text right
61
+     * @param	string		$photo			Photo (full path to image file used as replacement for key %PHOTOS% into left, right, header or footer text)
62
+     * @return	void
63
+     */
64
+    function Add_PDF_label(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$photo='')
65
+    {
66 66
         // phpcs:enable
67
-		global $mysoc, $conf, $langs;
68
-		global $forceimgscalewidth, $forceimgscaleheight;
69
-
70
-		$imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth);	// Scale of image for width (1=Full width of sticker)
71
-		$imgscaleheight=(empty($forceimgscaleheight)?0.5:$forceimgscaleheight);	// Scale of image for height (1=Full height of sticker)
72
-
73
-		// We are in a new page, then we must add a page
74
-		if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) {
75
-			$pdf->AddPage();
76
-		}
77
-		$this->_First=0;
78
-		$_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space));
79
-		$_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space));
80
-
81
-		// Define logo
82
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
83
-		if (! is_readable($logo))
84
-		{
85
-			$logo='';
86
-			if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
87
-			{
88
-				$logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
89
-			}
90
-			elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
91
-			{
92
-				$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
93
-			}
94
-		}
95
-
96
-		// Define photo
97
-		if (! empty($photo))
98
-		{
99
-			if (! is_readable($photo)) $photo='';
100
-		}
101
-
102
-		// Define background image
103
-		$backgroundimage='';
104
-
105
-		// Print lines
106
-		if ($this->code == "CARD")
107
-		{
108
-			$this->Tformat=$this->_Avery_Labels["CARD"];
109
-			//$this->_Pointille($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.3,25);
110
-			$this->_Croix($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.1,10);
111
-		}
112
-
113
-		// Background
114
-		if ($backgroundimage)
115
-		{
116
-			$pdf->image($backgroundimage,$_PosX,$_PosY,$this->_Width,$this->_Height);
117
-		}
118
-
119
-		$xleft=2; $ytop=2;
120
-
121
-		// Top
122
-		if ($header!='')
123
-		{
124
-			if ($this->code == "CARD")
125
-			{
126
-				$pdf->SetDrawColor(128,128,128);
127
-				$pdf->Line($_PosX, $_PosY+$this->_Line_Height+1, $_PosX+$this->_Width, $_PosY+$this->_Line_Height+1); // Only 1 mm and not ytop for top text
128
-				$pdf->SetDrawColor(0,0,0);
129
-			}
130
-			$pdf->SetXY($_PosX+$xleft, $_PosY+1); // Only 1 mm and not ytop for top text
131
-			$pdf->Cell($this->_Width-2*$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C');
132
-		}
133
-
134
-
135
-		$ytop+=(empty($header)?0:(1+$this->_Line_Height));
136
-
137
-		// Define widthtouse and heighttouse
138
-		$maxwidthtouse=round(($this->_Width - 2*$xleft)*$imgscalewidth); $maxheighttouse=round(($this->_Height - 2*$ytop)*$imgscaleheight);
139
-		$defaultratio=($maxwidthtouse/$maxheighttouse);
140
-		$widthtouse=$maxwidthtouse; $heighttouse=0;		// old value for image
141
-		$tmp=dol_getImageSize($photo, false);
142
-		if ($tmp['height'])
143
-		{
144
-			$imgratio=$tmp['width']/$tmp['height'];
145
-			if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); }
146
-			else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); }
147
-		}
148
-		//var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit;
149
-
150
-		// Center
151
-		if ($textright=='')	// Only a left part
152
-		{
153
-			// Output left area
154
-			if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
155
-			else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
156
-			else
157
-			{
158
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
159
-				$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
160
-			}
161
-		}
162
-		else if ($textleft!='' && $textright!='')	//
163
-		{
164
-			if ($textleft == '%LOGO%' || $textleft == '%PHOTO%')
165
-			{
166
-				if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
167
-				else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
168
-				$pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop);
169
-				$pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
170
-			}
171
-			else if ($textright == '%LOGO%' || $textright == '%PHOTO%')
172
-			{
173
-				if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
174
-				else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
175
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
176
-				$pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
177
-			}
178
-			else	// text on halft left and text on half right
179
-			{
180
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
181
-				$pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
182
-				$pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop);
183
-				$pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
184
-			}
185
-		}
186
-		else	// Only a right part
187
-		{
188
-			// Output right area
189
-			if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
190
-			else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
191
-			else
192
-			{
193
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
194
-				$pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
195
-			}
196
-		}
197
-
198
-		// Bottom
199
-		if ($footer!='')
200
-		{
201
-			if ($this->code == "CARD")
202
-			{
203
-				$pdf->SetDrawColor(128,128,128);
204
-				$pdf->Line($_PosX, $_PosY+$this->_Height-$this->_Line_Height-2, $_PosX+$this->_Width, $_PosY+$this->_Height-$this->_Line_Height-2);
205
-				$pdf->SetDrawColor(0,0,0);
206
-			}
207
-			$pdf->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1);
208
-			$pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C');
209
-		}
210
-		//print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n";
211
-
212
-		$this->_COUNTY++;
213
-
214
-		if ($this->_COUNTY == $this->_Y_Number) {
215
-			// Si on est en bas de page, on remonte le 'curseur' de position
216
-			$this->_COUNTX++;
217
-			$this->_COUNTY=0;
218
-		}
219
-
220
-		if ($this->_COUNTX == $this->_X_Number) {
221
-			// Si on est en bout de page, alors on repart sur une nouvelle page
222
-			$this->_COUNTX=0;
223
-			$this->_COUNTY=0;
224
-		}
225
-	}
67
+        global $mysoc, $conf, $langs;
68
+        global $forceimgscalewidth, $forceimgscaleheight;
69
+
70
+        $imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth);	// Scale of image for width (1=Full width of sticker)
71
+        $imgscaleheight=(empty($forceimgscaleheight)?0.5:$forceimgscaleheight);	// Scale of image for height (1=Full height of sticker)
72
+
73
+        // We are in a new page, then we must add a page
74
+        if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) {
75
+            $pdf->AddPage();
76
+        }
77
+        $this->_First=0;
78
+        $_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space));
79
+        $_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space));
80
+
81
+        // Define logo
82
+        $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
83
+        if (! is_readable($logo))
84
+        {
85
+            $logo='';
86
+            if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
87
+            {
88
+                $logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
89
+            }
90
+            elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
91
+            {
92
+                $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
93
+            }
94
+        }
95
+
96
+        // Define photo
97
+        if (! empty($photo))
98
+        {
99
+            if (! is_readable($photo)) $photo='';
100
+        }
101
+
102
+        // Define background image
103
+        $backgroundimage='';
104
+
105
+        // Print lines
106
+        if ($this->code == "CARD")
107
+        {
108
+            $this->Tformat=$this->_Avery_Labels["CARD"];
109
+            //$this->_Pointille($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.3,25);
110
+            $this->_Croix($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.1,10);
111
+        }
112
+
113
+        // Background
114
+        if ($backgroundimage)
115
+        {
116
+            $pdf->image($backgroundimage,$_PosX,$_PosY,$this->_Width,$this->_Height);
117
+        }
118
+
119
+        $xleft=2; $ytop=2;
120
+
121
+        // Top
122
+        if ($header!='')
123
+        {
124
+            if ($this->code == "CARD")
125
+            {
126
+                $pdf->SetDrawColor(128,128,128);
127
+                $pdf->Line($_PosX, $_PosY+$this->_Line_Height+1, $_PosX+$this->_Width, $_PosY+$this->_Line_Height+1); // Only 1 mm and not ytop for top text
128
+                $pdf->SetDrawColor(0,0,0);
129
+            }
130
+            $pdf->SetXY($_PosX+$xleft, $_PosY+1); // Only 1 mm and not ytop for top text
131
+            $pdf->Cell($this->_Width-2*$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C');
132
+        }
133
+
134
+
135
+        $ytop+=(empty($header)?0:(1+$this->_Line_Height));
136
+
137
+        // Define widthtouse and heighttouse
138
+        $maxwidthtouse=round(($this->_Width - 2*$xleft)*$imgscalewidth); $maxheighttouse=round(($this->_Height - 2*$ytop)*$imgscaleheight);
139
+        $defaultratio=($maxwidthtouse/$maxheighttouse);
140
+        $widthtouse=$maxwidthtouse; $heighttouse=0;		// old value for image
141
+        $tmp=dol_getImageSize($photo, false);
142
+        if ($tmp['height'])
143
+        {
144
+            $imgratio=$tmp['width']/$tmp['height'];
145
+            if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); }
146
+            else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); }
147
+        }
148
+        //var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit;
149
+
150
+        // Center
151
+        if ($textright=='')	// Only a left part
152
+        {
153
+            // Output left area
154
+            if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
155
+            else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
156
+            else
157
+            {
158
+                $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
159
+                $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
160
+            }
161
+        }
162
+        else if ($textleft!='' && $textright!='')	//
163
+        {
164
+            if ($textleft == '%LOGO%' || $textleft == '%PHOTO%')
165
+            {
166
+                if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
167
+                else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
168
+                $pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop);
169
+                $pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
170
+            }
171
+            else if ($textright == '%LOGO%' || $textright == '%PHOTO%')
172
+            {
173
+                if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
174
+                else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
175
+                $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
176
+                $pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
177
+            }
178
+            else	// text on halft left and text on half right
179
+            {
180
+                $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
181
+                $pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
182
+                $pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop);
183
+                $pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
184
+            }
185
+        }
186
+        else	// Only a right part
187
+        {
188
+            // Output right area
189
+            if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
190
+            else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
191
+            else
192
+            {
193
+                $pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
194
+                $pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
195
+            }
196
+        }
197
+
198
+        // Bottom
199
+        if ($footer!='')
200
+        {
201
+            if ($this->code == "CARD")
202
+            {
203
+                $pdf->SetDrawColor(128,128,128);
204
+                $pdf->Line($_PosX, $_PosY+$this->_Height-$this->_Line_Height-2, $_PosX+$this->_Width, $_PosY+$this->_Height-$this->_Line_Height-2);
205
+                $pdf->SetDrawColor(0,0,0);
206
+            }
207
+            $pdf->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1);
208
+            $pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C');
209
+        }
210
+        //print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n";
211
+
212
+        $this->_COUNTY++;
213
+
214
+        if ($this->_COUNTY == $this->_Y_Number) {
215
+            // Si on est en bas de page, on remonte le 'curseur' de position
216
+            $this->_COUNTX++;
217
+            $this->_COUNTY=0;
218
+        }
219
+
220
+        if ($this->_COUNTX == $this->_X_Number) {
221
+            // Si on est en bout de page, alors on repart sur une nouvelle page
222
+            $this->_COUNTX=0;
223
+            $this->_COUNTY=0;
224
+        }
225
+    }
226 226
 
227 227
 
228 228
 
229 229
 
230 230
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
231
-	/**
232
-	 *	Function to build PDF on disk, then output on HTTP strem.
233
-	 *
234
-	 *	@param	array		$arrayofrecords		Array of record informations (array('textleft'=>,'textheader'=>, ..., 'id'=>,'photo'=>)
235
-	 *	@param	Translate	$outputlangs		Lang object for output language
236
-	 *	@param	string		$srctemplatepath	Full path of source filename for generator using a template file
237
-	 *	@param	string		$outputdir			Output directory for pdf file
238
-	 *  @param  string      $filename           Short file name of PDF output file
239
-	 *	@return int								1=OK, 0=KO
240
-	 */
241
-	function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$outputdir='',$filename='tmp_address_sheet.pdf')
242
-	{
231
+    /**
232
+     *	Function to build PDF on disk, then output on HTTP strem.
233
+     *
234
+     *	@param	array		$arrayofrecords		Array of record informations (array('textleft'=>,'textheader'=>, ..., 'id'=>,'photo'=>)
235
+     *	@param	Translate	$outputlangs		Lang object for output language
236
+     *	@param	string		$srctemplatepath	Full path of source filename for generator using a template file
237
+     *	@param	string		$outputdir			Output directory for pdf file
238
+     *  @param  string      $filename           Short file name of PDF output file
239
+     *	@return int								1=OK, 0=KO
240
+     */
241
+    function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$outputdir='',$filename='tmp_address_sheet.pdf')
242
+    {
243 243
         // phpcs:enable
244
-		global $user,$conf,$langs,$mysoc,$_Avery_Labels;
244
+        global $user,$conf,$langs,$mysoc,$_Avery_Labels;
245 245
 
246
-		$this->code=$srctemplatepath;
247
-		$this->Tformat = $_Avery_Labels[$this->code];
248
-		if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
249
-		$this->type = 'pdf';
246
+        $this->code=$srctemplatepath;
247
+        $this->Tformat = $_Avery_Labels[$this->code];
248
+        if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
249
+        $this->type = 'pdf';
250 250
         // standard format or custom
251 251
         if ($this->Tformat['paper-size']!='custom') {
252 252
             $this->format = $this->Tformat['paper-size'];
@@ -256,99 +256,99 @@  discard block
 block discarded – undo
256 256
             $this->format = $resolution;
257 257
         }
258 258
 
259
-		if (! is_object($outputlangs)) $outputlangs=$langs;
260
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
261
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
262
-
263
-		// Load traductions files requiredby by page
264
-		$outputlangs->loadLangs(array("main", "dict", "companies", "admin"));
259
+        if (! is_object($outputlangs)) $outputlangs=$langs;
260
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
261
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
265 262
 
266
-		$title=$outputlangs->transnoentities('Labels');
267
-		$keywords=$title." ".$outputlangs->convToOutputCharset($mysoc->name);
263
+        // Load traductions files requiredby by page
264
+        $outputlangs->loadLangs(array("main", "dict", "companies", "admin"));
268 265
 
269
-		$dir = (empty($outputdir)?$conf->adherent->dir_temp:$outputdir);
270
-		$file = $dir."/".$filename;
266
+        $title=$outputlangs->transnoentities('Labels');
267
+        $keywords=$title." ".$outputlangs->convToOutputCharset($mysoc->name);
271 268
 
272
-		if (! file_exists($dir))
273
-		{
274
-			if (dol_mkdir($dir) < 0)
275
-			{
276
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
277
-				return 0;
278
-			}
279
-		}
269
+        $dir = (empty($outputdir)?$conf->adherent->dir_temp:$outputdir);
270
+        $file = $dir."/".$filename;
280 271
 
281
-		$pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']);
282
-
283
-		if (class_exists('TCPDF'))
284
-		{
285
-			$pdf->setPrintHeader(false);
286
-			$pdf->setPrintFooter(false);
287
-		}
288
-		$pdf->SetFont(pdf_getPDFFont($outputlangs));
289
-
290
-		$pdf->SetTitle($title);
291
-		$pdf->SetSubject($title);
292
-		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
293
-		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
294
-		$pdf->SetKeyWords($keywords);
295
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
296
-
297
-		$pdf->SetMargins(0,0);
298
-		$pdf->SetAutoPageBreak(false);
299
-
300
-		$this->_Metric_Doc = $this->Tformat['metric'];
301
-		// Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
302
-		$posX=1;
303
-		$posY=1;
304
-		if ($posX > 0) $posX--; else $posX=0;
305
-		if ($posY > 0) $posY--; else $posY=0;
306
-		$this->_COUNTX = $posX;
307
-		$this->_COUNTY = $posY;
308
-		$this->_Set_Format($pdf, $this->Tformat);
309
-
310
-
311
-		$pdf->Open();
312
-		$pdf->AddPage();
272
+        if (! file_exists($dir))
273
+        {
274
+            if (dol_mkdir($dir) < 0)
275
+            {
276
+                $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
277
+                return 0;
278
+            }
279
+        }
313 280
 
281
+        $pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']);
314 282
 
315
-		// Add each record
316
-		foreach($arrayofrecords as $val)
317
-		{
318
-			// imprime le texte specifique sur la carte
319
-			$this->Add_PDF_label($pdf,$val['textleft'],$val['textheader'],$val['textfooter'],$langs,$val['textright'],$val['photo']);
320
-		}
283
+        if (class_exists('TCPDF'))
284
+        {
285
+            $pdf->setPrintHeader(false);
286
+            $pdf->setPrintFooter(false);
287
+        }
288
+        $pdf->SetFont(pdf_getPDFFont($outputlangs));
289
+
290
+        $pdf->SetTitle($title);
291
+        $pdf->SetSubject($title);
292
+        $pdf->SetCreator("Dolibarr ".DOL_VERSION);
293
+        $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
294
+        $pdf->SetKeyWords($keywords);
295
+        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
296
+
297
+        $pdf->SetMargins(0,0);
298
+        $pdf->SetAutoPageBreak(false);
299
+
300
+        $this->_Metric_Doc = $this->Tformat['metric'];
301
+        // Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
302
+        $posX=1;
303
+        $posY=1;
304
+        if ($posX > 0) $posX--; else $posX=0;
305
+        if ($posY > 0) $posY--; else $posY=0;
306
+        $this->_COUNTX = $posX;
307
+        $this->_COUNTY = $posY;
308
+        $this->_Set_Format($pdf, $this->Tformat);
309
+
310
+
311
+        $pdf->Open();
312
+        $pdf->AddPage();
313
+
314
+
315
+        // Add each record
316
+        foreach($arrayofrecords as $val)
317
+        {
318
+            // imprime le texte specifique sur la carte
319
+            $this->Add_PDF_label($pdf,$val['textleft'],$val['textheader'],$val['textfooter'],$langs,$val['textright'],$val['photo']);
320
+        }
321 321
 
322
-		//$pdf->SetXY(10, 295);
323
-		//$pdf->Cell($this->_Width, $this->_Line_Height, 'XXX',0,1,'C');
322
+        //$pdf->SetXY(10, 295);
323
+        //$pdf->Cell($this->_Width, $this->_Line_Height, 'XXX',0,1,'C');
324 324
 
325 325
 
326
-		// Output to file
327
-		$pdf->Output($file,'F');
326
+        // Output to file
327
+        $pdf->Output($file,'F');
328 328
 
329
-		if (! empty($conf->global->MAIN_UMASK))
330
-			@chmod($file, octdec($conf->global->MAIN_UMASK));
329
+        if (! empty($conf->global->MAIN_UMASK))
330
+            @chmod($file, octdec($conf->global->MAIN_UMASK));
331 331
 
332
-		// Output to http stream
333
-		clearstatcache();
332
+        // Output to http stream
333
+        clearstatcache();
334 334
 
335
-		$attachment=true;
336
-		if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
337
-		$type=dol_mimetype($filename);
335
+        $attachment=true;
336
+        if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
337
+        $type=dol_mimetype($filename);
338 338
 
339
-		//if ($encoding)   header('Content-Encoding: '.$encoding);
340
-		if ($type)		 header('Content-Type: '.$type);
341
-		if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
342
-		else header('Content-Disposition: inline; filename="'.$filename.'"');
339
+        //if ($encoding)   header('Content-Encoding: '.$encoding);
340
+        if ($type)		 header('Content-Type: '.$type);
341
+        if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
342
+        else header('Content-Disposition: inline; filename="'.$filename.'"');
343 343
 
344
-		// Ajout directives pour resoudre bug IE
345
-		header('Cache-Control: Public, must-revalidate');
346
-		header('Pragma: public');
344
+        // Ajout directives pour resoudre bug IE
345
+        header('Cache-Control: Public, must-revalidate');
346
+        header('Pragma: public');
347 347
 
348
-		readfile($file);
348
+        readfile($file);
349 349
 
350
-		$this->result = array('fullpath'=>$file);
350
+        $this->result = array('fullpath'=>$file);
351 351
 
352
-		return 1;
353
-	}
352
+        return 1;
353
+    }
354 354
 }
Please login to merge, or discard this patch.
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 * @param	array		$param			Associative array containing label content and optional parameters
42 42
 	 * @return	void
43 43
 	 */
44
-    function addSticker(&$pdf,$outputlangs,$param)
44
+    function addSticker(&$pdf, $outputlangs, $param)
45 45
     {
46 46
 		// use this method in future refactoring
47 47
 	}
@@ -61,151 +61,151 @@  discard block
 block discarded – undo
61 61
 	 * @param	string		$photo			Photo (full path to image file used as replacement for key %PHOTOS% into left, right, header or footer text)
62 62
 	 * @return	void
63 63
 	 */
64
-	function Add_PDF_label(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$photo='')
64
+	function Add_PDF_label(&$pdf, $textleft, $header, $footer, $outputlangs, $textright = '', $photo = '')
65 65
 	{
66 66
         // phpcs:enable
67 67
 		global $mysoc, $conf, $langs;
68 68
 		global $forceimgscalewidth, $forceimgscaleheight;
69 69
 
70
-		$imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth);	// Scale of image for width (1=Full width of sticker)
71
-		$imgscaleheight=(empty($forceimgscaleheight)?0.5:$forceimgscaleheight);	// Scale of image for height (1=Full height of sticker)
70
+		$imgscalewidth = (empty($forceimgscalewidth) ? 0.3 : $forceimgscalewidth); // Scale of image for width (1=Full width of sticker)
71
+		$imgscaleheight = (empty($forceimgscaleheight) ? 0.5 : $forceimgscaleheight); // Scale of image for height (1=Full height of sticker)
72 72
 
73 73
 		// We are in a new page, then we must add a page
74
-		if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) {
74
+		if (($this->_COUNTX == 0) && ($this->_COUNTY == 0) and (!$this->_First == 1)) {
75 75
 			$pdf->AddPage();
76 76
 		}
77
-		$this->_First=0;
78
-		$_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space));
79
-		$_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space));
77
+		$this->_First = 0;
78
+		$_PosX = $this->_Margin_Left + ($this->_COUNTX * ($this->_Width + $this->_X_Space));
79
+		$_PosY = $this->_Margin_Top + ($this->_COUNTY * ($this->_Height + $this->_Y_Space));
80 80
 
81 81
 		// Define logo
82
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
83
-		if (! is_readable($logo))
82
+		$logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
83
+		if (!is_readable($logo))
84 84
 		{
85
-			$logo='';
86
-			if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
85
+			$logo = '';
86
+			if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
87 87
 			{
88
-				$logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
88
+				$logo = $conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
89 89
 			}
90
-			elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
90
+			elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
91 91
 			{
92
-				$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
92
+				$logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
93 93
 			}
94 94
 		}
95 95
 
96 96
 		// Define photo
97
-		if (! empty($photo))
97
+		if (!empty($photo))
98 98
 		{
99
-			if (! is_readable($photo)) $photo='';
99
+			if (!is_readable($photo)) $photo = '';
100 100
 		}
101 101
 
102 102
 		// Define background image
103
-		$backgroundimage='';
103
+		$backgroundimage = '';
104 104
 
105 105
 		// Print lines
106 106
 		if ($this->code == "CARD")
107 107
 		{
108
-			$this->Tformat=$this->_Avery_Labels["CARD"];
108
+			$this->Tformat = $this->_Avery_Labels["CARD"];
109 109
 			//$this->_Pointille($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.3,25);
110
-			$this->_Croix($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.1,10);
110
+			$this->_Croix($pdf, $_PosX, $_PosY, $_PosX + $this->_Width, $_PosY + $this->_Height, 0.1, 10);
111 111
 		}
112 112
 
113 113
 		// Background
114 114
 		if ($backgroundimage)
115 115
 		{
116
-			$pdf->image($backgroundimage,$_PosX,$_PosY,$this->_Width,$this->_Height);
116
+			$pdf->image($backgroundimage, $_PosX, $_PosY, $this->_Width, $this->_Height);
117 117
 		}
118 118
 
119
-		$xleft=2; $ytop=2;
119
+		$xleft = 2; $ytop = 2;
120 120
 
121 121
 		// Top
122
-		if ($header!='')
122
+		if ($header != '')
123 123
 		{
124 124
 			if ($this->code == "CARD")
125 125
 			{
126
-				$pdf->SetDrawColor(128,128,128);
127
-				$pdf->Line($_PosX, $_PosY+$this->_Line_Height+1, $_PosX+$this->_Width, $_PosY+$this->_Line_Height+1); // Only 1 mm and not ytop for top text
128
-				$pdf->SetDrawColor(0,0,0);
126
+				$pdf->SetDrawColor(128, 128, 128);
127
+				$pdf->Line($_PosX, $_PosY + $this->_Line_Height + 1, $_PosX + $this->_Width, $_PosY + $this->_Line_Height + 1); // Only 1 mm and not ytop for top text
128
+				$pdf->SetDrawColor(0, 0, 0);
129 129
 			}
130
-			$pdf->SetXY($_PosX+$xleft, $_PosY+1); // Only 1 mm and not ytop for top text
131
-			$pdf->Cell($this->_Width-2*$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C');
130
+			$pdf->SetXY($_PosX + $xleft, $_PosY + 1); // Only 1 mm and not ytop for top text
131
+			$pdf->Cell($this->_Width - 2 * $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header), 0, 1, 'C');
132 132
 		}
133 133
 
134 134
 
135
-		$ytop+=(empty($header)?0:(1+$this->_Line_Height));
135
+		$ytop += (empty($header) ? 0 : (1 + $this->_Line_Height));
136 136
 
137 137
 		// Define widthtouse and heighttouse
138
-		$maxwidthtouse=round(($this->_Width - 2*$xleft)*$imgscalewidth); $maxheighttouse=round(($this->_Height - 2*$ytop)*$imgscaleheight);
139
-		$defaultratio=($maxwidthtouse/$maxheighttouse);
140
-		$widthtouse=$maxwidthtouse; $heighttouse=0;		// old value for image
141
-		$tmp=dol_getImageSize($photo, false);
138
+		$maxwidthtouse = round(($this->_Width - 2 * $xleft) * $imgscalewidth); $maxheighttouse = round(($this->_Height - 2 * $ytop) * $imgscaleheight);
139
+		$defaultratio = ($maxwidthtouse / $maxheighttouse);
140
+		$widthtouse = $maxwidthtouse; $heighttouse = 0; // old value for image
141
+		$tmp = dol_getImageSize($photo, false);
142 142
 		if ($tmp['height'])
143 143
 		{
144
-			$imgratio=$tmp['width']/$tmp['height'];
144
+			$imgratio = $tmp['width'] / $tmp['height'];
145 145
 			if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); }
146 146
 			else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); }
147 147
 		}
148 148
 		//var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit;
149 149
 
150 150
 		// Center
151
-		if ($textright=='')	// Only a left part
151
+		if ($textright == '')	// Only a left part
152 152
 		{
153 153
 			// Output left area
154
-			if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
155
-			else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
154
+			if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
155
+			else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
156 156
 			else
157 157
 			{
158
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
159
-				$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
158
+				$pdf->SetXY($_PosX + $xleft, $_PosY + $ytop);
159
+				$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L');
160 160
 			}
161 161
 		}
162
-		else if ($textleft!='' && $textright!='')	//
162
+		else if ($textleft != '' && $textright != '')	//
163 163
 		{
164 164
 			if ($textleft == '%LOGO%' || $textleft == '%PHOTO%')
165 165
 			{
166
-				if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
167
-				else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
168
-				$pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop);
169
-				$pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
166
+				if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
167
+				else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo, $_PosX + $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
168
+				$pdf->SetXY($_PosX + $xleft + $widthtouse + 1, $_PosY + $ytop);
169
+				$pdf->MultiCell($this->_Width - $xleft - $xleft - $widthtouse - 1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
170 170
 			}
171 171
 			else if ($textright == '%LOGO%' || $textright == '%PHOTO%')
172 172
 			{
173
-				if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
174
-				else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
175
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
176
-				$pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
173
+				if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
174
+				else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
175
+				$pdf->SetXY($_PosX + $xleft, $_PosY + $ytop);
176
+				$pdf->MultiCell($this->_Width - $widthtouse - $xleft - $xleft - 1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L');
177 177
 			}
178 178
 			else	// text on halft left and text on half right
179 179
 			{
180
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
181
-				$pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
182
-				$pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop);
183
-				$pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
180
+				$pdf->SetXY($_PosX + $xleft, $_PosY + $ytop);
181
+				$pdf->MultiCell(round($this->_Width / 2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L');
182
+				$pdf->SetXY($_PosX + round($this->_Width / 2), $_PosY + $ytop);
183
+				$pdf->MultiCell(round($this->_Width / 2) - 2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
184 184
 			}
185 185
 		}
186 186
 		else	// Only a right part
187 187
 		{
188 188
 			// Output right area
189
-			if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
190
-			else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
189
+			if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
190
+			else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo, $_PosX + $this->_Width - $widthtouse - $xleft, $_PosY + $ytop, $widthtouse, $heighttouse);
191 191
 			else
192 192
 			{
193
-				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
194
-				$pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
193
+				$pdf->SetXY($_PosX + $xleft, $_PosY + $ytop);
194
+				$pdf->MultiCell($this->_Width - $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
195 195
 			}
196 196
 		}
197 197
 
198 198
 		// Bottom
199
-		if ($footer!='')
199
+		if ($footer != '')
200 200
 		{
201 201
 			if ($this->code == "CARD")
202 202
 			{
203
-				$pdf->SetDrawColor(128,128,128);
204
-				$pdf->Line($_PosX, $_PosY+$this->_Height-$this->_Line_Height-2, $_PosX+$this->_Width, $_PosY+$this->_Height-$this->_Line_Height-2);
205
-				$pdf->SetDrawColor(0,0,0);
203
+				$pdf->SetDrawColor(128, 128, 128);
204
+				$pdf->Line($_PosX, $_PosY + $this->_Height - $this->_Line_Height - 2, $_PosX + $this->_Width, $_PosY + $this->_Height - $this->_Line_Height - 2);
205
+				$pdf->SetDrawColor(0, 0, 0);
206 206
 			}
207
-			$pdf->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1);
208
-			$pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C');
207
+			$pdf->SetXY($_PosX, $_PosY + $this->_Height - $this->_Line_Height - 1);
208
+			$pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer), 0, 1, 'C');
209 209
 		}
210 210
 		//print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n";
211 211
 
@@ -214,13 +214,13 @@  discard block
 block discarded – undo
214 214
 		if ($this->_COUNTY == $this->_Y_Number) {
215 215
 			// Si on est en bas de page, on remonte le 'curseur' de position
216 216
 			$this->_COUNTX++;
217
-			$this->_COUNTY=0;
217
+			$this->_COUNTY = 0;
218 218
 		}
219 219
 
220 220
 		if ($this->_COUNTX == $this->_X_Number) {
221 221
 			// Si on est en bout de page, alors on repart sur une nouvelle page
222
-			$this->_COUNTX=0;
223
-			$this->_COUNTY=0;
222
+			$this->_COUNTX = 0;
223
+			$this->_COUNTY = 0;
224 224
 		}
225 225
 	}
226 226
 
@@ -238,47 +238,47 @@  discard block
 block discarded – undo
238 238
 	 *  @param  string      $filename           Short file name of PDF output file
239 239
 	 *	@return int								1=OK, 0=KO
240 240
 	 */
241
-	function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$outputdir='',$filename='tmp_address_sheet.pdf')
241
+	function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = '', $filename = 'tmp_address_sheet.pdf')
242 242
 	{
243 243
         // phpcs:enable
244
-		global $user,$conf,$langs,$mysoc,$_Avery_Labels;
244
+		global $user, $conf, $langs, $mysoc, $_Avery_Labels;
245 245
 
246
-		$this->code=$srctemplatepath;
246
+		$this->code = $srctemplatepath;
247 247
 		$this->Tformat = $_Avery_Labels[$this->code];
248
-		if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
248
+		if (empty($this->Tformat)) { dol_print_error('', 'ErrorBadTypeForCard'.$this->code); exit; }
249 249
 		$this->type = 'pdf';
250 250
         // standard format or custom
251
-        if ($this->Tformat['paper-size']!='custom') {
251
+        if ($this->Tformat['paper-size'] != 'custom') {
252 252
             $this->format = $this->Tformat['paper-size'];
253 253
         } else {
254 254
             //custom
255
-            $resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']);
255
+            $resolution = array($this->Tformat['custom_x'], $this->Tformat['custom_y']);
256 256
             $this->format = $resolution;
257 257
         }
258 258
 
259
-		if (! is_object($outputlangs)) $outputlangs=$langs;
259
+		if (!is_object($outputlangs)) $outputlangs = $langs;
260 260
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
261
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
261
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
262 262
 
263 263
 		// Load traductions files requiredby by page
264 264
 		$outputlangs->loadLangs(array("main", "dict", "companies", "admin"));
265 265
 
266
-		$title=$outputlangs->transnoentities('Labels');
267
-		$keywords=$title." ".$outputlangs->convToOutputCharset($mysoc->name);
266
+		$title = $outputlangs->transnoentities('Labels');
267
+		$keywords = $title." ".$outputlangs->convToOutputCharset($mysoc->name);
268 268
 
269
-		$dir = (empty($outputdir)?$conf->adherent->dir_temp:$outputdir);
269
+		$dir = (empty($outputdir) ? $conf->adherent->dir_temp : $outputdir);
270 270
 		$file = $dir."/".$filename;
271 271
 
272
-		if (! file_exists($dir))
272
+		if (!file_exists($dir))
273 273
 		{
274 274
 			if (dol_mkdir($dir) < 0)
275 275
 			{
276
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
276
+				$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
277 277
 				return 0;
278 278
 			}
279 279
 		}
280 280
 
281
-		$pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']);
281
+		$pdf = pdf_getInstance($this->format, $this->Tformat['metric'], $this->Tformat['orientation']);
282 282
 
283 283
 		if (class_exists('TCPDF'))
284 284
 		{
@@ -292,17 +292,17 @@  discard block
 block discarded – undo
292 292
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
293 293
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
294 294
 		$pdf->SetKeyWords($keywords);
295
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
295
+		if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
296 296
 
297
-		$pdf->SetMargins(0,0);
297
+		$pdf->SetMargins(0, 0);
298 298
 		$pdf->SetAutoPageBreak(false);
299 299
 
300 300
 		$this->_Metric_Doc = $this->Tformat['metric'];
301 301
 		// Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
302
-		$posX=1;
303
-		$posY=1;
304
-		if ($posX > 0) $posX--; else $posX=0;
305
-		if ($posY > 0) $posY--; else $posY=0;
302
+		$posX = 1;
303
+		$posY = 1;
304
+		if ($posX > 0) $posX--; else $posX = 0;
305
+		if ($posY > 0) $posY--; else $posY = 0;
306 306
 		$this->_COUNTX = $posX;
307 307
 		$this->_COUNTY = $posY;
308 308
 		$this->_Set_Format($pdf, $this->Tformat);
@@ -313,10 +313,10 @@  discard block
 block discarded – undo
313 313
 
314 314
 
315 315
 		// Add each record
316
-		foreach($arrayofrecords as $val)
316
+		foreach ($arrayofrecords as $val)
317 317
 		{
318 318
 			// imprime le texte specifique sur la carte
319
-			$this->Add_PDF_label($pdf,$val['textleft'],$val['textheader'],$val['textfooter'],$langs,$val['textright'],$val['photo']);
319
+			$this->Add_PDF_label($pdf, $val['textleft'], $val['textheader'], $val['textfooter'], $langs, $val['textright'], $val['photo']);
320 320
 		}
321 321
 
322 322
 		//$pdf->SetXY(10, 295);
@@ -324,17 +324,17 @@  discard block
 block discarded – undo
324 324
 
325 325
 
326 326
 		// Output to file
327
-		$pdf->Output($file,'F');
327
+		$pdf->Output($file, 'F');
328 328
 
329
-		if (! empty($conf->global->MAIN_UMASK))
329
+		if (!empty($conf->global->MAIN_UMASK))
330 330
 			@chmod($file, octdec($conf->global->MAIN_UMASK));
331 331
 
332 332
 		// Output to http stream
333 333
 		clearstatcache();
334 334
 
335
-		$attachment=true;
336
-		if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
337
-		$type=dol_mimetype($filename);
335
+		$attachment = true;
336
+		if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false;
337
+		$type = dol_mimetype($filename);
338 338
 
339 339
 		//if ($encoding)   header('Content-Encoding: '.$encoding);
340 340
 		if ($type)		 header('Content-Type: '.$type);
Please login to merge, or discard this patch.
Braces   +61 added lines, -33 removed lines patch added patch discarded remove patch
@@ -86,8 +86,7 @@  discard block
 block discarded – undo
86 86
 			if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
87 87
 			{
88 88
 				$logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
89
-			}
90
-			elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
89
+			} elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
91 90
 			{
92 91
 				$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
93 92
 			}
@@ -96,7 +95,9 @@  discard block
 block discarded – undo
96 95
 		// Define photo
97 96
 		if (! empty($photo))
98 97
 		{
99
-			if (! is_readable($photo)) $photo='';
98
+			if (! is_readable($photo)) {
99
+			    $photo='';
100
+			}
100 101
 		}
101 102
 
102 103
 		// Define background image
@@ -142,53 +143,58 @@  discard block
 block discarded – undo
142 143
 		if ($tmp['height'])
143 144
 		{
144 145
 			$imgratio=$tmp['width']/$tmp['height'];
145
-			if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); }
146
-			else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); }
146
+			if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); } else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); }
147 147
 		}
148 148
 		//var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit;
149 149
 
150 150
 		// Center
151
-		if ($textright=='')	// Only a left part
151
+		if ($textright=='') {
152
+		    // Only a left part
152 153
 		{
153 154
 			// Output left area
154 155
 			if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
155
-			else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
156
-			else
156
+		} else if ($textleft == '%PHOTO%' && $photo) {
157
+			    $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
158
+			} else
157 159
 			{
158 160
 				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
159 161
 				$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
160 162
 			}
161
-		}
162
-		else if ($textleft!='' && $textright!='')	//
163
+		} else if ($textleft!='' && $textright!='') {
164
+		    //
163 165
 		{
164 166
 			if ($textleft == '%LOGO%' || $textleft == '%PHOTO%')
165 167
 			{
166 168
 				if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
167
-				else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
169
+		} else if ($textleft == '%PHOTO%' && $photo) {
170
+				    $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
171
+				}
168 172
 				$pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop);
169 173
 				$pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
170
-			}
171
-			else if ($textright == '%LOGO%' || $textright == '%PHOTO%')
174
+			} else if ($textright == '%LOGO%' || $textright == '%PHOTO%')
172 175
 			{
173
-				if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
174
-				else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
176
+				if ($textright == '%LOGO%' && $logo) {
177
+				    $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
178
+				} else if ($textright == '%PHOTO%' && $photo) {
179
+				    $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
180
+				}
175 181
 				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
176 182
 				$pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
177
-			}
178
-			else	// text on halft left and text on half right
183
+			} else	// text on halft left and text on half right
179 184
 			{
180 185
 				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
181 186
 				$pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
182 187
 				$pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop);
183 188
 				$pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
184 189
 			}
185
-		}
186
-		else	// Only a right part
190
+		} else	// Only a right part
187 191
 		{
188 192
 			// Output right area
189
-			if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
190
-			else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
191
-			else
193
+			if ($textright == '%LOGO%' && $logo) {
194
+			    $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
195
+			} else if ($textright == '%PHOTO%' && $photo) {
196
+			    $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
197
+			} else
192 198
 			{
193 199
 				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
194 200
 				$pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
@@ -256,9 +262,13 @@  discard block
 block discarded – undo
256 262
             $this->format = $resolution;
257 263
         }
258 264
 
259
-		if (! is_object($outputlangs)) $outputlangs=$langs;
265
+		if (! is_object($outputlangs)) {
266
+		    $outputlangs=$langs;
267
+		}
260 268
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
261
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
269
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
270
+		    $outputlangs->charset_output='ISO-8859-1';
271
+		}
262 272
 
263 273
 		// Load traductions files requiredby by page
264 274
 		$outputlangs->loadLangs(array("main", "dict", "companies", "admin"));
@@ -292,7 +302,9 @@  discard block
 block discarded – undo
292 302
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
293 303
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
294 304
 		$pdf->SetKeyWords($keywords);
295
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
305
+		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
306
+		    $pdf->SetCompression(false);
307
+		}
296 308
 
297 309
 		$pdf->SetMargins(0,0);
298 310
 		$pdf->SetAutoPageBreak(false);
@@ -301,8 +313,16 @@  discard block
 block discarded – undo
301 313
 		// Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
302 314
 		$posX=1;
303 315
 		$posY=1;
304
-		if ($posX > 0) $posX--; else $posX=0;
305
-		if ($posY > 0) $posY--; else $posY=0;
316
+		if ($posX > 0) {
317
+		    $posX--;
318
+		} else {
319
+		    $posX=0;
320
+		}
321
+		if ($posY > 0) {
322
+		    $posY--;
323
+		} else {
324
+		    $posY=0;
325
+		}
306 326
 		$this->_COUNTX = $posX;
307 327
 		$this->_COUNTY = $posY;
308 328
 		$this->_Set_Format($pdf, $this->Tformat);
@@ -326,20 +346,28 @@  discard block
 block discarded – undo
326 346
 		// Output to file
327 347
 		$pdf->Output($file,'F');
328 348
 
329
-		if (! empty($conf->global->MAIN_UMASK))
330
-			@chmod($file, octdec($conf->global->MAIN_UMASK));
349
+		if (! empty($conf->global->MAIN_UMASK)) {
350
+					@chmod($file, octdec($conf->global->MAIN_UMASK));
351
+		}
331 352
 
332 353
 		// Output to http stream
333 354
 		clearstatcache();
334 355
 
335 356
 		$attachment=true;
336
-		if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
357
+		if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) {
358
+		    $attachment=false;
359
+		}
337 360
 		$type=dol_mimetype($filename);
338 361
 
339 362
 		//if ($encoding)   header('Content-Encoding: '.$encoding);
340
-		if ($type)		 header('Content-Type: '.$type);
341
-		if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
342
-		else header('Content-Disposition: inline; filename="'.$filename.'"');
363
+		if ($type) {
364
+		    header('Content-Type: '.$type);
365
+		}
366
+		if ($attachment) {
367
+		    header('Content-Disposition: attachment; filename="'.$filename.'"');
368
+		} else {
369
+		    header('Content-Disposition: inline; filename="'.$filename.'"');
370
+		}
343 371
 
344 372
 		// Ajout directives pour resoudre bug IE
345 373
 		header('Cache-Control: Public, must-revalidate');
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/printsheet/modules_labels.php 3 patches
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -34,33 +34,33 @@  discard block
 block discarded – undo
34 34
  */
35 35
 class ModelePDFLabels
36 36
 {
37
-	/**
38
-	 * @var string Error code (or message)
39
-	 */
40
-	public $error='';
37
+    /**
38
+     * @var string Error code (or message)
39
+     */
40
+    public $error='';
41 41
 
42 42
 
43 43
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
44
-	/**
45
-	 *  Return list of active generation modules
46
-	 *
44
+    /**
45
+     *  Return list of active generation modules
46
+     *
47 47
      *  @param  DoliDB	$db     			Database handler
48 48
      *  @param  integer	$maxfilenamelength  Max length of value to show
49 49
      *  @return	array						List of templates
50
-	 */
51
-	function liste_modeles($db,$maxfilenamelength=0)
52
-	{
50
+     */
51
+    function liste_modeles($db,$maxfilenamelength=0)
52
+    {
53 53
         // phpcs:enable
54
-		global $conf;
54
+        global $conf;
55 55
 
56
-		$type='members_labels';
57
-		$liste=array();
56
+        $type='members_labels';
57
+        $liste=array();
58 58
 
59
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
60
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
59
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
60
+        $liste=getListOfModels($db,$type,$maxfilenamelength);
61 61
 
62
-		return $liste;
63
-	}
62
+        return $liste;
63
+    }
64 64
 }
65 65
 
66 66
 
@@ -80,92 +80,92 @@  discard block
 block discarded – undo
80 80
 function doc_label_pdf_create($db, $arrayofrecords, $modele, $outputlangs, $outputdir='', $template='standardlabel', $filename='tmp_address_sheet.pdf')
81 81
 {
82 82
     // phpcs:enable
83
-	global $conf,$langs;
84
-	$langs->load("members");
85
-
86
-	$error=0;
87
-
88
-	// Increase limit for PDF build
89
-	$err=error_reporting();
90
-	error_reporting(0);
91
-	@set_time_limit(120);
92
-	error_reporting($err);
93
-
94
-	$code='';
95
-	$srctemplatepath='';
96
-
97
-	// Positionne le modele sur le nom du modele a utiliser
98
-	if (! dol_strlen($modele))
99
-	{
100
-		if (! empty($conf->global->ADHERENT_ETIQUETTE_TYPE))
101
-		{
102
-			$code = $conf->global->ADHERENT_ETIQUETTE_TYPE;
103
-		}
104
-		else
105
-		{
106
-			$code = $modele;
107
-		}
108
-	}
109
-	else $code=$modele;
110
-
111
-	// If selected modele is a filename template (then $modele="modelname:filename")
112
-	$tmp=explode(':',$template,2);
113
-	if (! empty($tmp[1]))
114
-	{
115
-		$template=$tmp[0];
116
-		$srctemplatepath=$tmp[1];
117
-	}
118
-	else $srctemplatepath=$code;
119
-
120
-	dol_syslog("modele=".$modele." outputdir=".$outputdir." template=".$template." code=".$code." srctemplatepath=".$srctemplatepath." filename=".$filename, LOG_DEBUG);
121
-
122
-	// Search template files
123
-	$file=''; $classname=''; $filefound=0;
124
-	$dirmodels=array('/');
125
-	if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']);
126
-	foreach($dirmodels as $reldir)
127
-	{
128
-		foreach(array('doc','pdf') as $prefix)
129
-		{
130
-			$file = $prefix."_".$template.".class.php";
131
-
132
-			// On verifie l'emplacement du modele
133
-			$file=dol_buildpath($reldir."core/modules/printsheet/doc/".$file,0);
134
-			if (file_exists($file))
135
-			{
136
-				$filefound=1;
137
-				$classname=$prefix.'_'.$template;
138
-				break;
139
-			}
140
-		}
141
-		if ($filefound) break;
142
-	}
143
-
144
-	// Charge le modele
145
-	if ($filefound)
146
-	{
147
-		require_once $file;
148
-
149
-		$obj = new $classname($db);
150
-
151
-		// We save charset_output to restore it because write_file can change it if needed for
152
-		// output format that does not support UTF8.
153
-		$sav_charset_output=$outputlangs->charset_output;
154
-		if ($obj->write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir, $filename) > 0)
155
-		{
156
-			$outputlangs->charset_output=$sav_charset_output;
157
-			return 1;
158
-		}
159
-		else
160
-		{
161
-			$outputlangs->charset_output=$sav_charset_output;
162
-			dol_print_error($db,"doc_label_pdf_create Error: ".$obj->error);
163
-			return -1;
164
-		}
165
-	}
166
-	else
167
-	{
168
-		dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file));
169
-		return -1;
170
-	}
83
+    global $conf,$langs;
84
+    $langs->load("members");
85
+
86
+    $error=0;
87
+
88
+    // Increase limit for PDF build
89
+    $err=error_reporting();
90
+    error_reporting(0);
91
+    @set_time_limit(120);
92
+    error_reporting($err);
93
+
94
+    $code='';
95
+    $srctemplatepath='';
96
+
97
+    // Positionne le modele sur le nom du modele a utiliser
98
+    if (! dol_strlen($modele))
99
+    {
100
+        if (! empty($conf->global->ADHERENT_ETIQUETTE_TYPE))
101
+        {
102
+            $code = $conf->global->ADHERENT_ETIQUETTE_TYPE;
103
+        }
104
+        else
105
+        {
106
+            $code = $modele;
107
+        }
108
+    }
109
+    else $code=$modele;
110
+
111
+    // If selected modele is a filename template (then $modele="modelname:filename")
112
+    $tmp=explode(':',$template,2);
113
+    if (! empty($tmp[1]))
114
+    {
115
+        $template=$tmp[0];
116
+        $srctemplatepath=$tmp[1];
117
+    }
118
+    else $srctemplatepath=$code;
119
+
120
+    dol_syslog("modele=".$modele." outputdir=".$outputdir." template=".$template." code=".$code." srctemplatepath=".$srctemplatepath." filename=".$filename, LOG_DEBUG);
121
+
122
+    // Search template files
123
+    $file=''; $classname=''; $filefound=0;
124
+    $dirmodels=array('/');
125
+    if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']);
126
+    foreach($dirmodels as $reldir)
127
+    {
128
+        foreach(array('doc','pdf') as $prefix)
129
+        {
130
+            $file = $prefix."_".$template.".class.php";
131
+
132
+            // On verifie l'emplacement du modele
133
+            $file=dol_buildpath($reldir."core/modules/printsheet/doc/".$file,0);
134
+            if (file_exists($file))
135
+            {
136
+                $filefound=1;
137
+                $classname=$prefix.'_'.$template;
138
+                break;
139
+            }
140
+        }
141
+        if ($filefound) break;
142
+    }
143
+
144
+    // Charge le modele
145
+    if ($filefound)
146
+    {
147
+        require_once $file;
148
+
149
+        $obj = new $classname($db);
150
+
151
+        // We save charset_output to restore it because write_file can change it if needed for
152
+        // output format that does not support UTF8.
153
+        $sav_charset_output=$outputlangs->charset_output;
154
+        if ($obj->write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir, $filename) > 0)
155
+        {
156
+            $outputlangs->charset_output=$sav_charset_output;
157
+            return 1;
158
+        }
159
+        else
160
+        {
161
+            $outputlangs->charset_output=$sav_charset_output;
162
+            dol_print_error($db,"doc_label_pdf_create Error: ".$obj->error);
163
+            return -1;
164
+        }
165
+    }
166
+    else
167
+    {
168
+        dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file));
169
+        return -1;
170
+    }
171 171
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	/**
38 38
 	 * @var string Error code (or message)
39 39
 	 */
40
-	public $error='';
40
+	public $error = '';
41 41
 
42 42
 
43 43
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -48,16 +48,16 @@  discard block
 block discarded – undo
48 48
      *  @param  integer	$maxfilenamelength  Max length of value to show
49 49
      *  @return	array						List of templates
50 50
 	 */
51
-	function liste_modeles($db,$maxfilenamelength=0)
51
+	function liste_modeles($db, $maxfilenamelength = 0)
52 52
 	{
53 53
         // phpcs:enable
54 54
 		global $conf;
55 55
 
56
-		$type='members_labels';
57
-		$liste=array();
56
+		$type = 'members_labels';
57
+		$liste = array();
58 58
 
59 59
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
60
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
60
+		$liste = getListOfModels($db, $type, $maxfilenamelength);
61 61
 
62 62
 		return $liste;
63 63
 	}
@@ -77,27 +77,27 @@  discard block
 block discarded – undo
77 77
  *  @param  string      $filename           Short file name of PDF output file
78 78
  *	@return int        						<0 if KO, >0 if OK
79 79
  */
80
-function doc_label_pdf_create($db, $arrayofrecords, $modele, $outputlangs, $outputdir='', $template='standardlabel', $filename='tmp_address_sheet.pdf')
80
+function doc_label_pdf_create($db, $arrayofrecords, $modele, $outputlangs, $outputdir = '', $template = 'standardlabel', $filename = 'tmp_address_sheet.pdf')
81 81
 {
82 82
     // phpcs:enable
83
-	global $conf,$langs;
83
+	global $conf, $langs;
84 84
 	$langs->load("members");
85 85
 
86
-	$error=0;
86
+	$error = 0;
87 87
 
88 88
 	// Increase limit for PDF build
89
-	$err=error_reporting();
89
+	$err = error_reporting();
90 90
 	error_reporting(0);
91 91
 	@set_time_limit(120);
92 92
 	error_reporting($err);
93 93
 
94
-	$code='';
95
-	$srctemplatepath='';
94
+	$code = '';
95
+	$srctemplatepath = '';
96 96
 
97 97
 	// Positionne le modele sur le nom du modele a utiliser
98
-	if (! dol_strlen($modele))
98
+	if (!dol_strlen($modele))
99 99
 	{
100
-		if (! empty($conf->global->ADHERENT_ETIQUETTE_TYPE))
100
+		if (!empty($conf->global->ADHERENT_ETIQUETTE_TYPE))
101 101
 		{
102 102
 			$code = $conf->global->ADHERENT_ETIQUETTE_TYPE;
103 103
 		}
@@ -106,35 +106,35 @@  discard block
 block discarded – undo
106 106
 			$code = $modele;
107 107
 		}
108 108
 	}
109
-	else $code=$modele;
109
+	else $code = $modele;
110 110
 
111 111
 	// If selected modele is a filename template (then $modele="modelname:filename")
112
-	$tmp=explode(':',$template,2);
113
-	if (! empty($tmp[1]))
112
+	$tmp = explode(':', $template, 2);
113
+	if (!empty($tmp[1]))
114 114
 	{
115
-		$template=$tmp[0];
116
-		$srctemplatepath=$tmp[1];
115
+		$template = $tmp[0];
116
+		$srctemplatepath = $tmp[1];
117 117
 	}
118
-	else $srctemplatepath=$code;
118
+	else $srctemplatepath = $code;
119 119
 
120 120
 	dol_syslog("modele=".$modele." outputdir=".$outputdir." template=".$template." code=".$code." srctemplatepath=".$srctemplatepath." filename=".$filename, LOG_DEBUG);
121 121
 
122 122
 	// Search template files
123
-	$file=''; $classname=''; $filefound=0;
124
-	$dirmodels=array('/');
125
-	if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']);
126
-	foreach($dirmodels as $reldir)
123
+	$file = ''; $classname = ''; $filefound = 0;
124
+	$dirmodels = array('/');
125
+	if (is_array($conf->modules_parts['models'])) $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
126
+	foreach ($dirmodels as $reldir)
127 127
 	{
128
-		foreach(array('doc','pdf') as $prefix)
128
+		foreach (array('doc', 'pdf') as $prefix)
129 129
 		{
130 130
 			$file = $prefix."_".$template.".class.php";
131 131
 
132 132
 			// On verifie l'emplacement du modele
133
-			$file=dol_buildpath($reldir."core/modules/printsheet/doc/".$file,0);
133
+			$file = dol_buildpath($reldir."core/modules/printsheet/doc/".$file, 0);
134 134
 			if (file_exists($file))
135 135
 			{
136
-				$filefound=1;
137
-				$classname=$prefix.'_'.$template;
136
+				$filefound = 1;
137
+				$classname = $prefix.'_'.$template;
138 138
 				break;
139 139
 			}
140 140
 		}
@@ -150,22 +150,22 @@  discard block
 block discarded – undo
150 150
 
151 151
 		// We save charset_output to restore it because write_file can change it if needed for
152 152
 		// output format that does not support UTF8.
153
-		$sav_charset_output=$outputlangs->charset_output;
153
+		$sav_charset_output = $outputlangs->charset_output;
154 154
 		if ($obj->write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir, $filename) > 0)
155 155
 		{
156
-			$outputlangs->charset_output=$sav_charset_output;
156
+			$outputlangs->charset_output = $sav_charset_output;
157 157
 			return 1;
158 158
 		}
159 159
 		else
160 160
 		{
161
-			$outputlangs->charset_output=$sav_charset_output;
162
-			dol_print_error($db,"doc_label_pdf_create Error: ".$obj->error);
161
+			$outputlangs->charset_output = $sav_charset_output;
162
+			dol_print_error($db, "doc_label_pdf_create Error: ".$obj->error);
163 163
 			return -1;
164 164
 		}
165 165
 	}
166 166
 	else
167 167
 	{
168
-		dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file));
168
+		dol_print_error('', $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file));
169 169
 		return -1;
170 170
 	}
171 171
 }
Please login to merge, or discard this patch.
Braces   +13 added lines, -10 removed lines patch added patch discarded remove patch
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
 		if (! empty($conf->global->ADHERENT_ETIQUETTE_TYPE))
101 101
 		{
102 102
 			$code = $conf->global->ADHERENT_ETIQUETTE_TYPE;
103
-		}
104
-		else
103
+		} else
105 104
 		{
106 105
 			$code = $modele;
107 106
 		}
107
+	} else {
108
+	    $code=$modele;
108 109
 	}
109
-	else $code=$modele;
110 110
 
111 111
 	// If selected modele is a filename template (then $modele="modelname:filename")
112 112
 	$tmp=explode(':',$template,2);
@@ -114,15 +114,18 @@  discard block
 block discarded – undo
114 114
 	{
115 115
 		$template=$tmp[0];
116 116
 		$srctemplatepath=$tmp[1];
117
+	} else {
118
+	    $srctemplatepath=$code;
117 119
 	}
118
-	else $srctemplatepath=$code;
119 120
 
120 121
 	dol_syslog("modele=".$modele." outputdir=".$outputdir." template=".$template." code=".$code." srctemplatepath=".$srctemplatepath." filename=".$filename, LOG_DEBUG);
121 122
 
122 123
 	// Search template files
123 124
 	$file=''; $classname=''; $filefound=0;
124 125
 	$dirmodels=array('/');
125
-	if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']);
126
+	if (is_array($conf->modules_parts['models'])) {
127
+	    $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']);
128
+	}
126 129
 	foreach($dirmodels as $reldir)
127 130
 	{
128 131
 		foreach(array('doc','pdf') as $prefix)
@@ -138,7 +141,9 @@  discard block
 block discarded – undo
138 141
 				break;
139 142
 			}
140 143
 		}
141
-		if ($filefound) break;
144
+		if ($filefound) {
145
+		    break;
146
+		}
142 147
 	}
143 148
 
144 149
 	// Charge le modele
@@ -155,15 +160,13 @@  discard block
 block discarded – undo
155 160
 		{
156 161
 			$outputlangs->charset_output=$sav_charset_output;
157 162
 			return 1;
158
-		}
159
-		else
163
+		} else
160 164
 		{
161 165
 			$outputlangs->charset_output=$sav_charset_output;
162 166
 			dol_print_error($db,"doc_label_pdf_create Error: ".$obj->error);
163 167
 			return -1;
164 168
 		}
165
-	}
166
-	else
169
+	} else
167 170
 	{
168 171
 		dol_print_error('',$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file));
169 172
 		return -1;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/supplier_order/modules_commandefournisseur.php 3 patches
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -37,33 +37,33 @@  discard block
 block discarded – undo
37 37
  */
38 38
 abstract class ModelePDFSuppliersOrders extends CommonDocGenerator
39 39
 {
40
-	/**
41
-	 * @var string Error code (or message)
42
-	 */
43
-	public $error='';
40
+    /**
41
+     * @var string Error code (or message)
42
+     */
43
+    public $error='';
44 44
 
45 45
 
46 46
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
47
-	/**
48
-	 *  Return list of active generation models
49
-	 *
47
+    /**
48
+     *  Return list of active generation models
49
+     *
50 50
      *  @param	DoliDB	$db     			Database handler
51 51
      *  @param  integer	$maxfilenamelength  Max length of value to show
52 52
      *  @return	array						List of templates
53
-	 */
54
-	static function liste_modeles($db,$maxfilenamelength=0)
55
-	{
56
-		// phpcs:enable
57
-		global $conf;
53
+     */
54
+    static function liste_modeles($db,$maxfilenamelength=0)
55
+    {
56
+        // phpcs:enable
57
+        global $conf;
58 58
 
59
-		$type='order_supplier';
60
-		$liste=array();
59
+        $type='order_supplier';
60
+        $liste=array();
61 61
 
62
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
63
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
62
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
63
+        $liste=getListOfModels($db,$type,$maxfilenamelength);
64 64
 
65
-		return $liste;
66
-	}
65
+        return $liste;
66
+    }
67 67
 }
68 68
 
69 69
 
@@ -73,74 +73,74 @@  discard block
 block discarded – undo
73 73
  */
74 74
 abstract class ModeleNumRefSuppliersOrders
75 75
 {
76
-	/**
77
-	 * @var string Error code (or message)
78
-	 */
79
-	public $error='';
80
-
81
-	/**  Return if a model can be used or not
82
-	 *
83
-	 *   @return	boolean     true if model can be used
84
-	 */
85
-	function isEnabled()
86
-	{
87
-		return true;
88
-	}
89
-
90
-	/**  Returns default description of numbering model
91
-	 *
92
-	 *   @return    string      Description Text
93
-	 */
94
-	function info()
95
-	{
96
-		global $langs;
97
-		$langs->load("orders");
98
-		return $langs->trans("NoDescription");
99
-	}
100
-
101
-	/**   Returns a numbering example
102
-	 *
103
-	 *    @return   string      Example
104
-	 */
105
-	function getExample()
106
-	{
107
-		global $langs;
108
-		$langs->load("orders");
109
-		return $langs->trans("NoExample");
110
-	}
111
-
112
-	/**  Tests if existing numbers make problems with numbering
113
-	 *
114
-	 *   @return	boolean     false if conflict, true if ok
115
-	 */
116
-	function canBeActivated()
117
-	{
118
-		return true;
119
-	}
120
-
121
-	/**  Returns next value assigned
122
-	 *
123
-	 *   @return     string      Valeur
124
-	 */
125
-	function getNextValue()
126
-	{
127
-		global $langs;
128
-		return $langs->trans("NotAvailable");
129
-	}
130
-
131
-	/**   Returns version of the numbering model
132
-	 *
133
-	 *    @return     string      Value
134
-	 */
135
-	function getVersion()
136
-	{
137
-		global $langs;
138
-		$langs->load("admin");
139
-
140
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
141
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
142
-		if ($this->version == 'dolibarr') return DOL_VERSION;
143
-		if ($this->version) return $this->version;
144
-		return $langs->trans("NotAvailable");
145
-	}
76
+    /**
77
+     * @var string Error code (or message)
78
+     */
79
+    public $error='';
80
+
81
+    /**  Return if a model can be used or not
82
+     *
83
+     *   @return	boolean     true if model can be used
84
+     */
85
+    function isEnabled()
86
+    {
87
+        return true;
88
+    }
89
+
90
+    /**  Returns default description of numbering model
91
+     *
92
+     *   @return    string      Description Text
93
+     */
94
+    function info()
95
+    {
96
+        global $langs;
97
+        $langs->load("orders");
98
+        return $langs->trans("NoDescription");
99
+    }
100
+
101
+    /**   Returns a numbering example
102
+     *
103
+     *    @return   string      Example
104
+     */
105
+    function getExample()
106
+    {
107
+        global $langs;
108
+        $langs->load("orders");
109
+        return $langs->trans("NoExample");
110
+    }
111
+
112
+    /**  Tests if existing numbers make problems with numbering
113
+     *
114
+     *   @return	boolean     false if conflict, true if ok
115
+     */
116
+    function canBeActivated()
117
+    {
118
+        return true;
119
+    }
120
+
121
+    /**  Returns next value assigned
122
+     *
123
+     *   @return     string      Valeur
124
+     */
125
+    function getNextValue()
126
+    {
127
+        global $langs;
128
+        return $langs->trans("NotAvailable");
129
+    }
130
+
131
+    /**   Returns version of the numbering model
132
+     *
133
+     *    @return     string      Value
134
+     */
135
+    function getVersion()
136
+    {
137
+        global $langs;
138
+        $langs->load("admin");
139
+
140
+        if ($this->version == 'development') return $langs->trans("VersionDevelopment");
141
+        if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
142
+        if ($this->version == 'dolibarr') return DOL_VERSION;
143
+        if ($this->version) return $this->version;
144
+        return $langs->trans("NotAvailable");
145
+    }
146 146
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
  *                  and parent class for supplier orders numbering models
30 30
  */
31 31
 require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
32
-require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';	// required for use by classes that inherit
32
+require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit
33 33
 
34 34
 
35 35
 /**
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	/**
41 41
 	 * @var string Error code (or message)
42 42
 	 */
43
-	public $error='';
43
+	public $error = '';
44 44
 
45 45
 
46 46
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -51,16 +51,16 @@  discard block
 block discarded – undo
51 51
      *  @param  integer	$maxfilenamelength  Max length of value to show
52 52
      *  @return	array						List of templates
53 53
 	 */
54
-	static function liste_modeles($db,$maxfilenamelength=0)
54
+	static function liste_modeles($db, $maxfilenamelength = 0)
55 55
 	{
56 56
 		// phpcs:enable
57 57
 		global $conf;
58 58
 
59
-		$type='order_supplier';
60
-		$liste=array();
59
+		$type = 'order_supplier';
60
+		$liste = array();
61 61
 
62 62
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
63
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
63
+		$liste = getListOfModels($db, $type, $maxfilenamelength);
64 64
 
65 65
 		return $liste;
66 66
 	}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	/**
77 77
 	 * @var string Error code (or message)
78 78
 	 */
79
-	public $error='';
79
+	public $error = '';
80 80
 
81 81
 	/**  Return if a model can be used or not
82 82
 	 *
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -142,10 +142,18 @@
 block discarded – undo
142 142
 		global $langs;
143 143
 		$langs->load("admin");
144 144
 
145
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
146
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
147
-		if ($this->version == 'dolibarr') return DOL_VERSION;
148
-		if ($this->version) return $this->version;
145
+		if ($this->version == 'development') {
146
+		    return $langs->trans("VersionDevelopment");
147
+		}
148
+		if ($this->version == 'experimental') {
149
+		    return $langs->trans("VersionExperimental");
150
+		}
151
+		if ($this->version == 'dolibarr') {
152
+		    return DOL_VERSION;
153
+		}
154
+		if ($this->version) {
155
+		    return $this->version;
156
+		}
149 157
 		return $langs->trans("NotAvailable");
150 158
 	}
151 159
 }
Please login to merge, or discard this patch.
htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php 2 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -32,28 +32,28 @@  discard block
 block discarded – undo
32 32
  */
33 33
 class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders
34 34
 {
35
-	/**
35
+    /**
36 36
      * Dolibarr version of the loaded document
37 37
      * @public string
38 38
      */
39
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
39
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
40 40
 
41
-	/**
41
+    /**
42 42
      * @var string Error code (or message)
43 43
      */
44 44
     public $error = '';
45 45
 
46
-	/**
47
-	 * @var string Nom du modele
48
-	 * @deprecated
49
-	 * @see name
50
-	 */
51
-	public $nom='Orchidee';
46
+    /**
47
+     * @var string Nom du modele
48
+     * @deprecated
49
+     * @see name
50
+     */
51
+    public $nom='Orchidee';
52 52
 
53
-	/**
54
-	 * @var string model name
55
-	 */
56
-	public $name='Orchidee';
53
+    /**
54
+     * @var string model name
55
+     */
56
+    public $name='Orchidee';
57 57
 
58 58
 
59 59
     /**
@@ -61,40 +61,40 @@  discard block
 block discarded – undo
61 61
      *
62 62
      * 	@return     string      Texte descripif
63 63
      */
64
-	function info()
64
+    function info()
65 65
     {
66
-    	global $conf, $langs;
66
+        global $conf, $langs;
67 67
 
68
-		// Load translation files required by the page
68
+        // Load translation files required by the page
69 69
         $langs->loadLangs(array("bills","admin"));
70 70
 
71
-		$form = new Form($this->db);
71
+        $form = new Form($this->db);
72 72
 
73
-		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
74
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
75
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
76
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
77
-		$texte.= '<input type="hidden" name="maskconstorder" value="COMMANDE_FOURNISSEUR_ORCHIDEE_MASK">';
78
-		$texte.= '<table class="nobordernopadding" width="100%">';
73
+        $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
74
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
75
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
76
+        $texte.= '<input type="hidden" name="action" value="updateMask">';
77
+        $texte.= '<input type="hidden" name="maskconstorder" value="COMMANDE_FOURNISSEUR_ORCHIDEE_MASK">';
78
+        $texte.= '<table class="nobordernopadding" width="100%">';
79 79
 
80
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
81
-		$tooltip.=$langs->trans("GenericMaskCodes2");
82
-		$tooltip.=$langs->trans("GenericMaskCodes3");
83
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
84
-		$tooltip.=$langs->trans("GenericMaskCodes5");
80
+        $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
81
+        $tooltip.=$langs->trans("GenericMaskCodes2");
82
+        $tooltip.=$langs->trans("GenericMaskCodes3");
83
+        $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
84
+        $tooltip.=$langs->trans("GenericMaskCodes5");
85 85
 
86
-		// Parametrage du prefix
87
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
88
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_FOURNISSEUR_ORCHIDEE_MASK.'">',$tooltip,1,1).'</td>';
86
+        // Parametrage du prefix
87
+        $texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
88
+        $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_FOURNISSEUR_ORCHIDEE_MASK.'">',$tooltip,1,1).'</td>';
89 89
 
90
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
90
+        $texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
91 91
 
92
-		$texte.= '</tr>';
92
+        $texte.= '</tr>';
93 93
 
94
-		$texte.= '</table>';
95
-		$texte.= '</form>';
94
+        $texte.= '</table>';
95
+        $texte.= '</form>';
96 96
 
97
-		return $texte;
97
+        return $texte;
98 98
     }
99 99
 
100 100
     /**
@@ -104,54 +104,54 @@  discard block
 block discarded – undo
104 104
      */
105 105
     function getExample()
106 106
     {
107
-    	global $conf,$langs,$mysoc;
108
-
109
-    	$old_code_client=$mysoc->code_client;
110
-    	$mysoc->code_client='CCCCCCCCCC';
111
-    	$numExample = $this->getNextValue($mysoc,'');
112
-		$mysoc->code_client=$old_code_client;
113
-
114
-		if (! $numExample)
115
-		{
116
-			$numExample = $langs->trans('NotConfigured');
117
-		}
118
-		return $numExample;
107
+        global $conf,$langs,$mysoc;
108
+
109
+        $old_code_client=$mysoc->code_client;
110
+        $mysoc->code_client='CCCCCCCCCC';
111
+        $numExample = $this->getNextValue($mysoc,'');
112
+        $mysoc->code_client=$old_code_client;
113
+
114
+        if (! $numExample)
115
+        {
116
+            $numExample = $langs->trans('NotConfigured');
117
+        }
118
+        return $numExample;
119 119
     }
120 120
 
121
-	/**
122
-	 *  Return next value
123
-	 *
124
-	 *  @param	Societe		$objsoc     Object third party
125
-	 *  @param  Object	    $object		Object
121
+    /**
122
+     *  Return next value
123
+     *
124
+     *  @param	Societe		$objsoc     Object third party
125
+     *  @param  Object	    $object		Object
126 126
      *  @return string      			Value if OK, 0 if KO
127
-	*/
127
+     */
128 128
     function getNextValue($objsoc=0,$object='')
129 129
     {
130
-		global $db,$conf;
130
+        global $db,$conf;
131 131
 
132
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
132
+        require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
133 133
 
134
-		// On defini critere recherche compteur
135
-		$mask=$conf->global->COMMANDE_FOURNISSEUR_ORCHIDEE_MASK;
134
+        // On defini critere recherche compteur
135
+        $mask=$conf->global->COMMANDE_FOURNISSEUR_ORCHIDEE_MASK;
136 136
 
137
-		if (! $mask)
138
-		{
139
-			$this->error='NotConfigured';
140
-			return 0;
141
-		}
137
+        if (! $mask)
138
+        {
139
+            $this->error='NotConfigured';
140
+            return 0;
141
+        }
142 142
 
143
-		$numFinal=get_next_value($db,$mask,'commande_fournisseur','ref','',$objsoc,$object->date_commande);
143
+        $numFinal=get_next_value($db,$mask,'commande_fournisseur','ref','',$objsoc,$object->date_commande);
144 144
 
145
-		return  $numFinal;
146
-	}
145
+        return  $numFinal;
146
+    }
147 147
 
148 148
 
149 149
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
150 150
     /**
151 151
      *  Renvoie la reference de commande suivante non utilisee
152 152
      *
153
-	 *  @param	Societe		$objsoc     Object third party
154
-	 *  @param  Object	    $object		Object
153
+     *  @param	Societe		$objsoc     Object third party
154
+     *  @param  Object	    $object		Object
155 155
      *  @return string      			Texte descripif
156 156
      */
157 157
     function commande_get_num($objsoc=0,$object='')
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *	\brief      Fichier contenant la classe du modele de numerotation de reference de commande fournisseur Orchidee
25 25
  */
26 26
 
27
-require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_order/modules_commandefournisseur.php';
27
+require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_order/modules_commandefournisseur.php';
28 28
 
29 29
 
30 30
 /**
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      * Dolibarr version of the loaded document
37 37
      * @public string
38 38
      */
39
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
39
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
40 40
 
41 41
 	/**
42 42
      * @var string Error code (or message)
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
 	 * @deprecated
49 49
 	 * @see name
50 50
 	 */
51
-	public $nom='Orchidee';
51
+	public $nom = 'Orchidee';
52 52
 
53 53
 	/**
54 54
 	 * @var string model name
55 55
 	 */
56
-	public $name='Orchidee';
56
+	public $name = 'Orchidee';
57 57
 
58 58
 
59 59
     /**
@@ -66,33 +66,33 @@  discard block
 block discarded – undo
66 66
     	global $conf, $langs;
67 67
 
68 68
 		// Load translation files required by the page
69
-        $langs->loadLangs(array("bills","admin"));
69
+        $langs->loadLangs(array("bills", "admin"));
70 70
 
71 71
 		$form = new Form($this->db);
72 72
 
73 73
 		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
74
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
75
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
76
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
77
-		$texte.= '<input type="hidden" name="maskconstorder" value="COMMANDE_FOURNISSEUR_ORCHIDEE_MASK">';
78
-		$texte.= '<table class="nobordernopadding" width="100%">';
79
-
80
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
81
-		$tooltip.=$langs->trans("GenericMaskCodes2");
82
-		$tooltip.=$langs->trans("GenericMaskCodes3");
83
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order"));
84
-		$tooltip.=$langs->trans("GenericMaskCodes5");
74
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
75
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
76
+		$texte .= '<input type="hidden" name="action" value="updateMask">';
77
+		$texte .= '<input type="hidden" name="maskconstorder" value="COMMANDE_FOURNISSEUR_ORCHIDEE_MASK">';
78
+		$texte .= '<table class="nobordernopadding" width="100%">';
79
+
80
+		$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Order"), $langs->transnoentities("Order"));
81
+		$tooltip .= $langs->trans("GenericMaskCodes2");
82
+		$tooltip .= $langs->trans("GenericMaskCodes3");
83
+		$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Order"), $langs->transnoentities("Order"));
84
+		$tooltip .= $langs->trans("GenericMaskCodes5");
85 85
 
86 86
 		// Parametrage du prefix
87
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
88
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_FOURNISSEUR_ORCHIDEE_MASK.'">',$tooltip,1,1).'</td>';
87
+		$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
88
+		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskorder" value="'.$conf->global->COMMANDE_FOURNISSEUR_ORCHIDEE_MASK.'">', $tooltip, 1, 1).'</td>';
89 89
 
90
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
90
+		$texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
91 91
 
92
-		$texte.= '</tr>';
92
+		$texte .= '</tr>';
93 93
 
94
-		$texte.= '</table>';
95
-		$texte.= '</form>';
94
+		$texte .= '</table>';
95
+		$texte .= '</form>';
96 96
 
97 97
 		return $texte;
98 98
     }
@@ -104,14 +104,14 @@  discard block
 block discarded – undo
104 104
      */
105 105
     function getExample()
106 106
     {
107
-    	global $conf,$langs,$mysoc;
107
+    	global $conf, $langs, $mysoc;
108 108
 
109
-    	$old_code_client=$mysoc->code_client;
110
-    	$mysoc->code_client='CCCCCCCCCC';
111
-    	$numExample = $this->getNextValue($mysoc,'');
112
-		$mysoc->code_client=$old_code_client;
109
+    	$old_code_client = $mysoc->code_client;
110
+    	$mysoc->code_client = 'CCCCCCCCCC';
111
+    	$numExample = $this->getNextValue($mysoc, '');
112
+		$mysoc->code_client = $old_code_client;
113 113
 
114
-		if (! $numExample)
114
+		if (!$numExample)
115 115
 		{
116 116
 			$numExample = $langs->trans('NotConfigured');
117 117
 		}
@@ -125,22 +125,22 @@  discard block
 block discarded – undo
125 125
 	 *  @param  Object	    $object		Object
126 126
      *  @return string      			Value if OK, 0 if KO
127 127
 	*/
128
-    function getNextValue($objsoc=0,$object='')
128
+    function getNextValue($objsoc = 0, $object = '')
129 129
     {
130
-		global $db,$conf;
130
+		global $db, $conf;
131 131
 
132
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
132
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
133 133
 
134 134
 		// On defini critere recherche compteur
135
-		$mask=$conf->global->COMMANDE_FOURNISSEUR_ORCHIDEE_MASK;
135
+		$mask = $conf->global->COMMANDE_FOURNISSEUR_ORCHIDEE_MASK;
136 136
 
137
-		if (! $mask)
137
+		if (!$mask)
138 138
 		{
139
-			$this->error='NotConfigured';
139
+			$this->error = 'NotConfigured';
140 140
 			return 0;
141 141
 		}
142 142
 
143
-		$numFinal=get_next_value($db,$mask,'commande_fournisseur','ref','',$objsoc,$object->date_commande);
143
+		$numFinal = get_next_value($db, $mask, 'commande_fournisseur', 'ref', '', $objsoc, $object->date_commande);
144 144
 
145 145
 		return  $numFinal;
146 146
 	}
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
 	 *  @param  Object	    $object		Object
155 155
      *  @return string      			Texte descripif
156 156
      */
157
-    function commande_get_num($objsoc=0,$object='')
157
+    function commande_get_num($objsoc = 0, $object = '')
158 158
     {
159 159
         // phpcs:enable
160
-        return $this->getNextValue($objsoc,$object);
160
+        return $this->getNextValue($objsoc, $object);
161 161
     }
162 162
 }
Please login to merge, or discard this patch.
htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php 3 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -31,41 +31,41 @@  discard block
 block discarded – undo
31 31
  */
32 32
 class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders
33 33
 {
34
-	/**
34
+    /**
35 35
      * Dolibarr version of the loaded document
36 36
      * @public string
37 37
      */
38
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
38
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
39 39
 
40
-	/**
40
+    /**
41 41
      * @var string Error code (or message)
42 42
      */
43 43
     public $error = '';
44 44
 
45
-	/**
46
-	 * @var string Nom du modele
47
-	 * @deprecated
48
-	 * @see name
49
-	 */
50
-	public $nom='Muguet';
45
+    /**
46
+     * @var string Nom du modele
47
+     * @deprecated
48
+     * @see name
49
+     */
50
+    public $nom='Muguet';
51 51
 
52
-	/**
53
-	 * @var string model name
54
-	 */
55
-	public $name='Muguet';
52
+    /**
53
+     * @var string model name
54
+     */
55
+    public $name='Muguet';
56 56
 
57
-	public $prefix='CF';
57
+    public $prefix='CF';
58 58
 
59 59
 
60
-	/**
61
-	 * Constructor
62
-	 */
63
-	function __construct()
64
-	{
65
-	    global $conf;
60
+    /**
61
+     * Constructor
62
+     */
63
+    function __construct()
64
+    {
65
+        global $conf;
66 66
 
67
-	    if ((float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 5.0) $this->prefix = 'PO';   // We use correct standard code "PO = Purchase Order"
68
-	}
67
+        if ((float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 5.0) $this->prefix = 'PO';   // We use correct standard code "PO = Purchase Order"
68
+    }
69 69
 
70 70
     /**
71 71
      * 	Return description of numbering module
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
      */
75 75
     function info()
76 76
     {
77
-    	global $langs;
78
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
77
+        global $langs;
78
+            return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
79 79
     }
80 80
 
81 81
 
@@ -98,14 +98,14 @@  discard block
 block discarded – undo
98 98
      */
99 99
     function canBeActivated()
100 100
     {
101
-    	global $conf,$langs,$db;
101
+        global $conf,$langs,$db;
102 102
 
103 103
         $coyymm=''; $max='';
104 104
 
105
-		$posindice=8;
106
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
105
+        $posindice=8;
106
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
107 107
         $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
108
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
108
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
109 109
         $sql.= " AND entity = ".$conf->entity;
110 110
         $resql=$db->query($sql);
111 111
         if ($resql)
@@ -119,18 +119,18 @@  discard block
 block discarded – undo
119 119
         }
120 120
         else
121 121
         {
122
-			$langs->load("errors");
123
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
122
+            $langs->load("errors");
123
+            $this->error=$langs->trans('ErrorNumRefModel',$max);
124 124
             return false;
125 125
         }
126 126
     }
127 127
 
128 128
     /**
129 129
      * 	Return next value
130
-	 *
131
-	 *  @param	Societe		$objsoc     Object third party
132
-	 *  @param  Object		$object		Object
133
-	 *  @return string      			Value if OK, 0 if KO
130
+     *
131
+     *  @param	Societe		$objsoc     Object third party
132
+     *  @param  Object		$object		Object
133
+     *  @return string      			Value if OK, 0 if KO
134 134
      */
135 135
     function getNextValue($objsoc=0,$object='')
136 136
     {
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         $posindice=8;
141 141
         $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
142 142
         $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
143
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
143
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
144 144
         $sql.= " AND entity = ".$conf->entity;
145 145
 
146 146
         $resql=$db->query($sql);
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
             else $max=0;
152 152
         }
153 153
 
154
-		//$date=time();
154
+        //$date=time();
155 155
         $date=$object->date_commande;   // Not always defined
156 156
         if (empty($date)) $date=$object->date;  // Creation date is order date for suppliers orders
157 157
         $yymm = strftime("%y%m",$date);
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
     /**
168 168
      * 	Renvoie la reference de commande suivante non utilisee
169 169
      *
170
-	 *  @param	Societe		$objsoc     Object third party
171
-	 *  @param  Object	    $object		Object
170
+     *  @param	Societe		$objsoc     Object third party
171
+     *  @param  Object	    $object		Object
172 172
      *  @return string      			Texte descripif
173 173
      */
174 174
     function commande_get_num($objsoc=0,$object='')
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *		\brief      Fichier contenant la classe du modele de numerotation de reference de commande fournisseur Muguet
24 24
  */
25 25
 
26
-require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_order/modules_commandefournisseur.php';
26
+require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_order/modules_commandefournisseur.php';
27 27
 
28 28
 
29 29
 /**
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      * Dolibarr version of the loaded document
36 36
      * @public string
37 37
      */
38
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
38
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
39 39
 
40 40
 	/**
41 41
      * @var string Error code (or message)
@@ -47,14 +47,14 @@  discard block
 block discarded – undo
47 47
 	 * @deprecated
48 48
 	 * @see name
49 49
 	 */
50
-	public $nom='Muguet';
50
+	public $nom = 'Muguet';
51 51
 
52 52
 	/**
53 53
 	 * @var string model name
54 54
 	 */
55
-	public $name='Muguet';
55
+	public $name = 'Muguet';
56 56
 
57
-	public $prefix='CF';
57
+	public $prefix = 'CF';
58 58
 
59 59
 
60 60
 	/**
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	{
65 65
 	    global $conf;
66 66
 
67
-	    if ((float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 5.0) $this->prefix = 'PO';   // We use correct standard code "PO = Purchase Order"
67
+	    if ((float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 5.0) $this->prefix = 'PO'; // We use correct standard code "PO = Purchase Order"
68 68
 	}
69 69
 
70 70
     /**
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     function info()
76 76
     {
77 77
     	global $langs;
78
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
78
+      	return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
79 79
     }
80 80
 
81 81
 
@@ -98,29 +98,29 @@  discard block
 block discarded – undo
98 98
      */
99 99
     function canBeActivated()
100 100
     {
101
-    	global $conf,$langs,$db;
101
+    	global $conf, $langs, $db;
102 102
 
103
-        $coyymm=''; $max='';
103
+        $coyymm = ''; $max = '';
104 104
 
105
-		$posindice=8;
105
+		$posindice = 8;
106 106
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
107
-        $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
108
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
109
-        $sql.= " AND entity = ".$conf->entity;
110
-        $resql=$db->query($sql);
107
+        $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
108
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
109
+        $sql .= " AND entity = ".$conf->entity;
110
+        $resql = $db->query($sql);
111 111
         if ($resql)
112 112
         {
113 113
             $row = $db->fetch_row($resql);
114
-            if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; }
114
+            if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; }
115 115
         }
116
-        if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
116
+        if (!$coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
117 117
         {
118 118
             return true;
119 119
         }
120 120
         else
121 121
         {
122 122
 			$langs->load("errors");
123
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
123
+			$this->error = $langs->trans('ErrorNumRefModel', $max);
124 124
             return false;
125 125
         }
126 126
     }
@@ -132,32 +132,32 @@  discard block
 block discarded – undo
132 132
 	 *  @param  Object		$object		Object
133 133
 	 *  @return string      			Value if OK, 0 if KO
134 134
      */
135
-    function getNextValue($objsoc=0,$object='')
135
+    function getNextValue($objsoc = 0, $object = '')
136 136
     {
137
-        global $db,$conf;
137
+        global $db, $conf;
138 138
 
139 139
         // D'abord on recupere la valeur max
140
-        $posindice=8;
140
+        $posindice = 8;
141 141
         $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
142
-        $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
143
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
144
-        $sql.= " AND entity = ".$conf->entity;
142
+        $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
143
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
144
+        $sql .= " AND entity = ".$conf->entity;
145 145
 
146
-        $resql=$db->query($sql);
146
+        $resql = $db->query($sql);
147 147
         if ($resql)
148 148
         {
149 149
             $obj = $db->fetch_object($resql);
150 150
             if ($obj) $max = intval($obj->max);
151
-            else $max=0;
151
+            else $max = 0;
152 152
         }
153 153
 
154 154
 		//$date=time();
155
-        $date=$object->date_commande;   // Not always defined
156
-        if (empty($date)) $date=$object->date;  // Creation date is order date for suppliers orders
157
-        $yymm = strftime("%y%m",$date);
155
+        $date = $object->date_commande; // Not always defined
156
+        if (empty($date)) $date = $object->date; // Creation date is order date for suppliers orders
157
+        $yymm = strftime("%y%m", $date);
158 158
 
159
-        if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
160
-        else $num = sprintf("%04s",$max+1);
159
+        if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
160
+        else $num = sprintf("%04s", $max + 1);
161 161
 
162 162
         return $this->prefix.$yymm."-".$num;
163 163
     }
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
 	 *  @param  Object	    $object		Object
172 172
      *  @return string      			Texte descripif
173 173
      */
174
-    function commande_get_num($objsoc=0,$object='')
174
+    function commande_get_num($objsoc = 0, $object = '')
175 175
     {
176 176
         // phpcs:enable
177
-        return $this->getNextValue($objsoc,$object);
177
+        return $this->getNextValue($objsoc, $object);
178 178
     }
179 179
 }
Please login to merge, or discard this patch.
Braces   +21 added lines, -8 removed lines patch added patch discarded remove patch
@@ -64,7 +64,10 @@  discard block
 block discarded – undo
64 64
 	{
65 65
 	    global $conf;
66 66
 
67
-	    if ((float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 5.0) $this->prefix = 'PO';   // We use correct standard code "PO = Purchase Order"
67
+	    if ((float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 5.0) {
68
+	        $this->prefix = 'PO';
69
+	    }
70
+	    // We use correct standard code "PO = Purchase Order"
68 71
 	}
69 72
 
70 73
     /**
@@ -116,8 +119,7 @@  discard block
 block discarded – undo
116 119
         if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
117 120
         {
118 121
             return true;
119
-        }
120
-        else
122
+        } else
121 123
         {
122 124
 			$langs->load("errors");
123 125
 			$this->error=$langs->trans('ErrorNumRefModel',$max);
@@ -147,17 +149,28 @@  discard block
 block discarded – undo
147 149
         if ($resql)
148 150
         {
149 151
             $obj = $db->fetch_object($resql);
150
-            if ($obj) $max = intval($obj->max);
151
-            else $max=0;
152
+            if ($obj) {
153
+                $max = intval($obj->max);
154
+            } else {
155
+                $max=0;
156
+            }
152 157
         }
153 158
 
154 159
 		//$date=time();
155 160
         $date=$object->date_commande;   // Not always defined
156
-        if (empty($date)) $date=$object->date;  // Creation date is order date for suppliers orders
161
+        if (empty($date)) {
162
+            $date=$object->date;
163
+        }
164
+        // Creation date is order date for suppliers orders
157 165
         $yymm = strftime("%y%m",$date);
158 166
 
159
-        if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
160
-        else $num = sprintf("%04s",$max+1);
167
+        if ($max >= (pow(10, 4) - 1)) {
168
+            $num=$max+1;
169
+        }
170
+        // If counter > 9999, we do not format on 4 chars, we take number as it is
171
+        else {
172
+            $num = sprintf("%04s",$max+1);
173
+        }
161 174
 
162 175
         return $this->prefix.$yymm."-".$num;
163 176
     }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php 3 patches
Indentation   +1152 added lines, -1152 removed lines patch added patch discarded remove patch
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public $db;
48 48
 
49
-	/**
49
+    /**
50 50
      * @var string model name
51 51
      */
52 52
     public $name;
53 53
 
54
-	/**
54
+    /**
55 55
      * @var string model description (short text)
56 56
      */
57 57
     public $description;
@@ -63,138 +63,138 @@  discard block
 block discarded – undo
63 63
 
64 64
     /**
65 65
      * @var array() Minimum version of PHP required by module.
66
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
66
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
67 67
      */
68
-	public $phpmin = array(5, 4);
68
+    public $phpmin = array(5, 4);
69 69
 
70
-	/**
70
+    /**
71 71
      * Dolibarr version of the loaded document
72 72
      * @public string
73 73
      */
74
-	public $version = 'dolibarr';
74
+    public $version = 'dolibarr';
75 75
 
76
-	/**
76
+    /**
77 77
      * @var int page_largeur
78 78
      */
79 79
     public $page_largeur;
80 80
 
81
-	/**
81
+    /**
82 82
      * @var int page_hauteur
83 83
      */
84 84
     public $page_hauteur;
85 85
 
86
-	/**
86
+    /**
87 87
      * @var array format
88 88
      */
89 89
     public $format;
90 90
 
91
-	/**
91
+    /**
92 92
      * @var int marge_gauche
93 93
      */
94
-	public $marge_gauche;
94
+    public $marge_gauche;
95 95
 
96
-	/**
96
+    /**
97 97
      * @var int marge_droite
98 98
      */
99
-	public $marge_droite;
99
+    public $marge_droite;
100 100
 
101
-	/**
101
+    /**
102 102
      * @var int marge_haute
103 103
      */
104
-	public $marge_haute;
104
+    public $marge_haute;
105 105
 
106
-	/**
106
+    /**
107 107
      * @var int marge_basse
108 108
      */
109
-	public $marge_basse;
110
-
111
-	/**
112
-	 * Issuer
113
-	 * @var Company object that emits
114
-	 */
115
-	public $emetteur;
116
-
117
-
118
-	/**
119
-	 *	Constructor
120
-	 *
121
-	 *  @param	DoliDB		$db      	Database handler
122
-	 */
123
-	function __construct($db)
124
-	{
125
-		global $conf, $langs, $mysoc;
126
-
127
-		// Load translation files required by the page
128
-		$langs->loadLangs(array("main", "bills"));
129
-
130
-		$this->db = $db;
131
-		$this->name = "muscadet";
132
-		$this->description = $langs->trans('SuppliersCommandModel');
133
-
134
-		// Dimension page pour format A4
135
-		$this->type = 'pdf';
136
-		$formatarray=pdf_getFormat();
137
-		$this->page_largeur = $formatarray['width'];
138
-		$this->page_hauteur = $formatarray['height'];
139
-		$this->format = array($this->page_largeur,$this->page_hauteur);
140
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
141
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
142
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
143
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
144
-
145
-		$this->option_logo = 1;                    // Affiche logo
146
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
147
-		$this->option_modereg = 1;                 // Affiche mode reglement
148
-		$this->option_condreg = 1;                 // Affiche conditions reglement
149
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
150
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
151
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
152
-		$this->option_credit_note = 0;             // Support credit notes
153
-		$this->option_freetext = 1;				   // Support add of a personalised text
154
-		$this->option_draft_watermark = 1;		   // Support add of a watermark on drafts
155
-
156
-		$this->franchise=!$mysoc->tva_assuj;
109
+    public $marge_basse;
110
+
111
+    /**
112
+     * Issuer
113
+     * @var Company object that emits
114
+     */
115
+    public $emetteur;
116
+
117
+
118
+    /**
119
+     *	Constructor
120
+     *
121
+     *  @param	DoliDB		$db      	Database handler
122
+     */
123
+    function __construct($db)
124
+    {
125
+        global $conf, $langs, $mysoc;
126
+
127
+        // Load translation files required by the page
128
+        $langs->loadLangs(array("main", "bills"));
129
+
130
+        $this->db = $db;
131
+        $this->name = "muscadet";
132
+        $this->description = $langs->trans('SuppliersCommandModel');
133
+
134
+        // Dimension page pour format A4
135
+        $this->type = 'pdf';
136
+        $formatarray=pdf_getFormat();
137
+        $this->page_largeur = $formatarray['width'];
138
+        $this->page_hauteur = $formatarray['height'];
139
+        $this->format = array($this->page_largeur,$this->page_hauteur);
140
+        $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
141
+        $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
142
+        $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
143
+        $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
144
+
145
+        $this->option_logo = 1;                    // Affiche logo
146
+        $this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
147
+        $this->option_modereg = 1;                 // Affiche mode reglement
148
+        $this->option_condreg = 1;                 // Affiche conditions reglement
149
+        $this->option_codeproduitservice = 1;      // Affiche code produit-service
150
+        $this->option_multilang = 1;               // Dispo en plusieurs langues
151
+        $this->option_escompte = 0;                // Affiche si il y a eu escompte
152
+        $this->option_credit_note = 0;             // Support credit notes
153
+        $this->option_freetext = 1;				   // Support add of a personalised text
154
+        $this->option_draft_watermark = 1;		   // Support add of a watermark on drafts
155
+
156
+        $this->franchise=!$mysoc->tva_assuj;
157 157
 
158 158
         // Get source company
159
-		$this->emetteur=$mysoc;
160
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
159
+        $this->emetteur=$mysoc;
160
+        if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
161 161
 
162
-		// Defini position des colonnes
163
-		$this->posxdesc=$this->marge_gauche+1;
164
-		$this->posxdiscount=162;
165
-		$this->postotalht=174;
162
+        // Defini position des colonnes
163
+        $this->posxdesc=$this->marge_gauche+1;
164
+        $this->posxdiscount=162;
165
+        $this->postotalht=174;
166 166
 
167
-		if ($conf->global->PRODUCT_USE_UNITS)
168
-		{
169
-			$this->posxtva=95;
170
-			$this->posxup=114;
171
-			$this->posxqty=132;
172
-			$this->posxunit=147;
173
-		} else {
174
-			$this->posxtva=110;
175
-			$this->posxup=126;
176
-			$this->posxqty=145;
177
-		}
178
-
179
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxup = $this->posxtva; // posxtva is picture position reference
180
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
181
-		if ($this->page_largeur < 210) // To work with US executive format
182
-		{
183
-			$this->posxpicture-=20;
184
-			$this->posxtva-=20;
185
-			$this->posxup-=20;
186
-			$this->posxqty-=20;
187
-			$this->posxunit-=20;
188
-			$this->posxdiscount-=20;
189
-			$this->postotalht-=20;
190
-		}
191
-
192
-		$this->tva=array();
167
+        if ($conf->global->PRODUCT_USE_UNITS)
168
+        {
169
+            $this->posxtva=95;
170
+            $this->posxup=114;
171
+            $this->posxqty=132;
172
+            $this->posxunit=147;
173
+        } else {
174
+            $this->posxtva=110;
175
+            $this->posxup=126;
176
+            $this->posxqty=145;
177
+        }
178
+
179
+        if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxup = $this->posxtva; // posxtva is picture position reference
180
+        $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
181
+        if ($this->page_largeur < 210) // To work with US executive format
182
+        {
183
+            $this->posxpicture-=20;
184
+            $this->posxtva-=20;
185
+            $this->posxup-=20;
186
+            $this->posxqty-=20;
187
+            $this->posxunit-=20;
188
+            $this->posxdiscount-=20;
189
+            $this->postotalht-=20;
190
+        }
191
+
192
+        $this->tva=array();
193 193
         $this->localtax1=array();
194 194
         $this->localtax2=array();
195 195
         $this->atleastoneratenotnull=0;
196
-		$this->atleastonediscount=0;
197
-	}
196
+        $this->atleastonediscount=0;
197
+    }
198 198
 
199 199
 
200 200
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -209,111 +209,111 @@  discard block
 block discarded – undo
209 209
      *  @param		int					$hideref			Do not show ref
210 210
      *  @return		int										1=OK, 0=KO
211 211
      */
212
-	function write_file($object,$outputlangs='',$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
213
-	{
212
+    function write_file($object,$outputlangs='',$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
213
+    {
214 214
         // phpcs:enable
215
-		global $user,$langs,$conf,$hookmanager,$mysoc,$nblignes;
215
+        global $user,$langs,$conf,$hookmanager,$mysoc,$nblignes;
216 216
 
217
-		if (! is_object($outputlangs)) $outputlangs=$langs;
218
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
219
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
217
+        if (! is_object($outputlangs)) $outputlangs=$langs;
218
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
219
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
220 220
 
221
-		// Load translation files required by the page
222
-		$outputlangs->loadLangs(array("main", "orders", "companies", "bills", "dict", "products"));
221
+        // Load translation files required by the page
222
+        $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "dict", "products"));
223 223
 
224
-		$nblignes = count($object->lines);
224
+        $nblignes = count($object->lines);
225 225
 
226
-		// Loop on each lines to detect if there is at least one image to show
227
-		$realpatharray=array();
228
-		if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE))
229
-		{
230
-			for ($i = 0 ; $i < $nblignes ; $i++)
231
-			{
232
-				if (empty($object->lines[$i]->fk_product)) continue;
233
-
234
-				$objphoto = new Product($this->db);
235
-				$objphoto->fetch($object->lines[$i]->fk_product);
236
-
237
-				if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
238
-				{
239
-					$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
240
-					$dir = $conf->product->dir_output.'/'.$pdir;
241
-				}
242
-				else
243
-				{
244
-					$pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
245
-					$dir = $conf->product->dir_output.'/'.$pdir;
246
-				}
247
-
248
-				$realpath='';
249
-				foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
250
-				{
251
-					$filename=$obj['photo'];
252
-					//if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette'];
253
-					$realpath = $dir.$filename;
254
-					break;
255
-				}
256
-
257
-				if ($realpath) $realpatharray[$i]=$realpath;
258
-			}
259
-		}
260
-		if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
261
-
262
-		if ($conf->fournisseur->commande->dir_output)
263
-		{
264
-			$object->fetch_thirdparty();
226
+        // Loop on each lines to detect if there is at least one image to show
227
+        $realpatharray=array();
228
+        if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE))
229
+        {
230
+            for ($i = 0 ; $i < $nblignes ; $i++)
231
+            {
232
+                if (empty($object->lines[$i]->fk_product)) continue;
233
+
234
+                $objphoto = new Product($this->db);
235
+                $objphoto->fetch($object->lines[$i]->fk_product);
236
+
237
+                if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
238
+                {
239
+                    $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
240
+                    $dir = $conf->product->dir_output.'/'.$pdir;
241
+                }
242
+                else
243
+                {
244
+                    $pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
245
+                    $dir = $conf->product->dir_output.'/'.$pdir;
246
+                }
247
+
248
+                $realpath='';
249
+                foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
250
+                {
251
+                    $filename=$obj['photo'];
252
+                    //if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette'];
253
+                    $realpath = $dir.$filename;
254
+                    break;
255
+                }
265 256
 
266
-			$deja_regle = 0;
267
-			$amount_credit_notes_included = 0;
268
-			$amount_deposits_included = 0;
269
-			//$amount_credit_notes_included = $object->getSumCreditNotesUsed();
257
+                if ($realpath) $realpatharray[$i]=$realpath;
258
+            }
259
+        }
260
+        if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
261
+
262
+        if ($conf->fournisseur->commande->dir_output)
263
+        {
264
+            $object->fetch_thirdparty();
265
+
266
+            $deja_regle = 0;
267
+            $amount_credit_notes_included = 0;
268
+            $amount_deposits_included = 0;
269
+            //$amount_credit_notes_included = $object->getSumCreditNotesUsed();
270 270
             //$amount_deposits_included = $object->getSumDepositsUsed();
271 271
 
272
-			// Definition of $dir and $file
273
-			if ($object->specimen)
274
-			{
275
-				$dir = $conf->fournisseur->commande->dir_output;
276
-				$file = $dir . "/SPECIMEN.pdf";
277
-			}
278
-			else
279
-			{
280
-				$objectref = dol_sanitizeFileName($object->ref);
281
-				$objectrefsupplier = dol_sanitizeFileName($object->ref_supplier);
282
-				$dir = $conf->fournisseur->commande->dir_output . '/'. $objectref;
283
-				$file = $dir . "/" . $objectref . ".pdf";
284
-				if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf";
285
-			}
286
-
287
-			if (! file_exists($dir))
288
-			{
289
-				if (dol_mkdir($dir) < 0)
290
-				{
291
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
292
-					return 0;
293
-				}
294
-			}
295
-
296
-			if (file_exists($dir))
297
-			{
298
-				// Add pdfgeneration hook
299
-				if (! is_object($hookmanager))
300
-				{
301
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
302
-					$hookmanager=new HookManager($this->db);
303
-				}
304
-				$hookmanager->initHooks(array('pdfgeneration'));
305
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
306
-				global $action;
307
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
308
-
309
-				$nblignes = count($object->lines);
272
+            // Definition of $dir and $file
273
+            if ($object->specimen)
274
+            {
275
+                $dir = $conf->fournisseur->commande->dir_output;
276
+                $file = $dir . "/SPECIMEN.pdf";
277
+            }
278
+            else
279
+            {
280
+                $objectref = dol_sanitizeFileName($object->ref);
281
+                $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier);
282
+                $dir = $conf->fournisseur->commande->dir_output . '/'. $objectref;
283
+                $file = $dir . "/" . $objectref . ".pdf";
284
+                if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf";
285
+            }
286
+
287
+            if (! file_exists($dir))
288
+            {
289
+                if (dol_mkdir($dir) < 0)
290
+                {
291
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
292
+                    return 0;
293
+                }
294
+            }
295
+
296
+            if (file_exists($dir))
297
+            {
298
+                // Add pdfgeneration hook
299
+                if (! is_object($hookmanager))
300
+                {
301
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
302
+                    $hookmanager=new HookManager($this->db);
303
+                }
304
+                $hookmanager->initHooks(array('pdfgeneration'));
305
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
306
+                global $action;
307
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
308
+
309
+                $nblignes = count($object->lines);
310 310
 
311 311
                 $pdf=pdf_getInstance($this->format);
312 312
                 $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
313 313
                 $heightforinfotot = 50;	// Height reserved to output the info and total part
314
-		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
315
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
316
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
314
+                $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
315
+                $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
316
+                if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
317 317
                 $pdf->SetAutoPageBreak(1,0);
318 318
 
319 319
                 if (class_exists('TCPDF'))
@@ -329,1047 +329,1047 @@  discard block
 block discarded – undo
329 329
                     $tplidx = $pdf->importPage(1);
330 330
                 }
331 331
 
332
-				$pdf->Open();
333
-				$pagenb=0;
334
-				$pdf->SetDrawColor(128,128,128);
335
-
336
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
337
-				$pdf->SetSubject($outputlangs->transnoentities("Order"));
338
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
339
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
340
-				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
341
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
342
-
343
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
344
-
345
-				// Positionne $this->atleastonediscount si on a au moins une remise
346
-				for ($i = 0 ; $i < $nblignes ; $i++)
347
-				{
348
-					if ($object->lines[$i]->remise_percent)
349
-					{
350
-						$this->atleastonediscount++;
351
-					}
352
-				}
353
-				if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
354
-				{
355
-					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
356
-					$this->posxtva+=($this->postotalht - $this->posxdiscount);
357
-					$this->posxup+=($this->postotalht - $this->posxdiscount);
358
-					$this->posxqty+=($this->postotalht - $this->posxdiscount);
359
-					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
360
-					//$this->postotalht;
361
-				}
362
-
363
-				// New page
364
-				$pdf->AddPage();
365
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
366
-				$pagenb++;
367
-				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
368
-				$pdf->SetFont('','', $default_font_size - 1);
369
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
370
-				$pdf->SetTextColor(0,0,0);
371
-
372
-				$tab_top = 90+$top_shift;
373
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
374
-
375
-				// Incoterm
376
-				if ($conf->incoterm->enabled)
377
-				{
378
-					$desc_incoterms = $object->getIncotermsForPDF();
379
-					if ($desc_incoterms)
380
-					{
381
-						$tab_top -= 2;
382
-
383
-						$pdf->SetFont('','', $default_font_size - 1);
384
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
385
-						$nexY = $pdf->GetY();
386
-						$height_incoterms=$nexY-$tab_top;
387
-
388
-						// Rect prend une longueur en 3eme param
389
-						$pdf->SetDrawColor(192,192,192);
390
-						$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
391
-
392
-						$tab_top = $nexY+6;
393
-					}
394
-				}
395
-
396
-				// Affiche notes
397
-				if (! empty($object->note_public))
398
-				{
399
-					$tab_top -= 2;
400
-
401
-					$pdf->SetFont('','', $default_font_size - 1);
402
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1);
403
-					$nexY = $pdf->GetY();
404
-					$height_note=$nexY-$tab_top;
405
-
406
-					// Rect prend une longueur en 3eme param
407
-					$pdf->SetDrawColor(192,192,192);
408
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
409
-
410
-					$tab_top = $nexY+6;
411
-				}
412
-
413
-				$iniY = $tab_top + 7;
414
-				$curY = $tab_top + 7;
415
-				$nexY = $tab_top + 7;
416
-
417
-				// Loop on each lines
418
-				for ($i = 0 ; $i < $nblignes ; $i++)
419
-				{
420
-					$curY = $nexY;
421
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
422
-					$pdf->SetTextColor(0,0,0);
423
-
424
-					// Define size of image if we need it
425
-					$imglinesize=array();
426
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
427
-
428
-					$pdf->setTopMargin($tab_top_newpage);
429
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
430
-					$pageposbefore=$pdf->getPage();
431
-
432
-					$showpricebeforepagebreak=1;
433
-					$posYAfterImage=0;
434
-					$posYAfterDescription=0;
435
-
436
-					// We start with Photo of product line
437
-					if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
438
-					{
439
-						$pdf->AddPage('','',true);
440
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
441
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
442
-						$pdf->setPage($pageposbefore+1);
443
-
444
-						$curY = $tab_top_newpage;
445
-						$showpricebeforepagebreak=0;
446
-					}
447
-
448
-					if (!empty($imglinesize['width']) && !empty($imglinesize['height']))
449
-					{
450
-						$curX = $this->posxpicture-1;
451
-						$pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
452
-						// $pdf->Image does not increase value return by getY, so we save it manually
453
-						$posYAfterImage=$curY+$imglinesize['height'];
454
-					}
455
-					// Description of product line
456
-					$curX = $this->posxdesc-1;
457
-					$showpricebeforepagebreak=1;
458
-
459
-					$pdf->startTransaction();
460
-					if ($posYAfterImage > 0)
461
-					{
462
-						$descWidth = $this->posxpicture-$curX;
463
-					}
464
-					else
465
-					{
466
-						$descWidth = $this->posxtva-$curX;
467
-					}
468
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1);
469
-
470
-					$pageposafter=$pdf->getPage();
471
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
472
-					{
473
-						$pdf->rollbackTransaction(true);
474
-						$pageposafter=$pageposbefore;
475
-						//print $pageposafter.'-'.$pageposbefore;exit;
476
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
477
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1);
478
-						$posyafter=$pdf->GetY();
479
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
480
-						{
481
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
482
-							{
483
-								$pdf->AddPage('','',true);
484
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
485
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
486
-								$pdf->setPage($pageposafter+1);
487
-							}
488
-						}
489
-						else
490
-						{
491
-							// We found a page break
492
-							$showpricebeforepagebreak=0;
493
-						}
494
-					}
495
-					else	// No pagebreak
496
-					{
497
-						$pdf->commitTransaction();
498
-					}
499
-
500
-					$nexY = $pdf->GetY();
332
+                $pdf->Open();
333
+                $pagenb=0;
334
+                $pdf->SetDrawColor(128,128,128);
335
+
336
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
337
+                $pdf->SetSubject($outputlangs->transnoentities("Order"));
338
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
339
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
340
+                $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
341
+                if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
342
+
343
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
344
+
345
+                // Positionne $this->atleastonediscount si on a au moins une remise
346
+                for ($i = 0 ; $i < $nblignes ; $i++)
347
+                {
348
+                    if ($object->lines[$i]->remise_percent)
349
+                    {
350
+                        $this->atleastonediscount++;
351
+                    }
352
+                }
353
+                if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
354
+                {
355
+                    $this->posxpicture+=($this->postotalht - $this->posxdiscount);
356
+                    $this->posxtva+=($this->postotalht - $this->posxdiscount);
357
+                    $this->posxup+=($this->postotalht - $this->posxdiscount);
358
+                    $this->posxqty+=($this->postotalht - $this->posxdiscount);
359
+                    $this->posxdiscount+=($this->postotalht - $this->posxdiscount);
360
+                    //$this->postotalht;
361
+                }
362
+
363
+                // New page
364
+                $pdf->AddPage();
365
+                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
366
+                $pagenb++;
367
+                $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
368
+                $pdf->SetFont('','', $default_font_size - 1);
369
+                $pdf->MultiCell(0, 3, '');		// Set interline to 3
370
+                $pdf->SetTextColor(0,0,0);
371
+
372
+                $tab_top = 90+$top_shift;
373
+                $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
374
+
375
+                // Incoterm
376
+                if ($conf->incoterm->enabled)
377
+                {
378
+                    $desc_incoterms = $object->getIncotermsForPDF();
379
+                    if ($desc_incoterms)
380
+                    {
381
+                        $tab_top -= 2;
382
+
383
+                        $pdf->SetFont('','', $default_font_size - 1);
384
+                        $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
385
+                        $nexY = $pdf->GetY();
386
+                        $height_incoterms=$nexY-$tab_top;
387
+
388
+                        // Rect prend une longueur en 3eme param
389
+                        $pdf->SetDrawColor(192,192,192);
390
+                        $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
391
+
392
+                        $tab_top = $nexY+6;
393
+                    }
394
+                }
395
+
396
+                // Affiche notes
397
+                if (! empty($object->note_public))
398
+                {
399
+                    $tab_top -= 2;
400
+
401
+                    $pdf->SetFont('','', $default_font_size - 1);
402
+                    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1);
403
+                    $nexY = $pdf->GetY();
404
+                    $height_note=$nexY-$tab_top;
405
+
406
+                    // Rect prend une longueur en 3eme param
407
+                    $pdf->SetDrawColor(192,192,192);
408
+                    $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
409
+
410
+                    $tab_top = $nexY+6;
411
+                }
412
+
413
+                $iniY = $tab_top + 7;
414
+                $curY = $tab_top + 7;
415
+                $nexY = $tab_top + 7;
416
+
417
+                // Loop on each lines
418
+                for ($i = 0 ; $i < $nblignes ; $i++)
419
+                {
420
+                    $curY = $nexY;
421
+                    $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
422
+                    $pdf->SetTextColor(0,0,0);
423
+
424
+                    // Define size of image if we need it
425
+                    $imglinesize=array();
426
+                    if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
427
+
428
+                    $pdf->setTopMargin($tab_top_newpage);
429
+                    $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
430
+                    $pageposbefore=$pdf->getPage();
431
+
432
+                    $showpricebeforepagebreak=1;
433
+                    $posYAfterImage=0;
434
+                    $posYAfterDescription=0;
435
+
436
+                    // We start with Photo of product line
437
+                    if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
438
+                    {
439
+                        $pdf->AddPage('','',true);
440
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
441
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
442
+                        $pdf->setPage($pageposbefore+1);
443
+
444
+                        $curY = $tab_top_newpage;
445
+                        $showpricebeforepagebreak=0;
446
+                    }
447
+
448
+                    if (!empty($imglinesize['width']) && !empty($imglinesize['height']))
449
+                    {
450
+                        $curX = $this->posxpicture-1;
451
+                        $pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
452
+                        // $pdf->Image does not increase value return by getY, so we save it manually
453
+                        $posYAfterImage=$curY+$imglinesize['height'];
454
+                    }
455
+                    // Description of product line
456
+                    $curX = $this->posxdesc-1;
457
+                    $showpricebeforepagebreak=1;
458
+
459
+                    $pdf->startTransaction();
460
+                    if ($posYAfterImage > 0)
461
+                    {
462
+                        $descWidth = $this->posxpicture-$curX;
463
+                    }
464
+                    else
465
+                    {
466
+                        $descWidth = $this->posxtva-$curX;
467
+                    }
468
+                    pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1);
469
+
501 470
                     $pageposafter=$pdf->getPage();
502
-					$pdf->setPage($pageposbefore);
503
-					$pdf->setTopMargin($this->marge_haute);
504
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
505
-
506
-					// We suppose that a too long description is moved completely on next page
507
-					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
508
-						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
509
-					}
510
-
511
-					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
512
-
513
-					// VAT Rate
514
-					if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
515
-					{
516
-						$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
517
-						$pdf->SetXY($this->posxtva, $curY);
518
-						$pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R');
519
-					}
520
-
521
-					// Unit price before discount
522
-					$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
523
-					$pdf->SetXY($this->posxup, $curY);
524
-					$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
525
-
526
-					// Quantity
527
-					$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
528
-					$pdf->SetXY($this->posxqty, $curY);
529
-					// Enough for 6 chars
530
-					if($conf->global->PRODUCT_USE_UNITS)
531
-					{
532
-						$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
533
-					}
534
-					else
535
-					{
536
-						$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
537
-					}
538
-
539
-					// Unit
540
-					if($conf->global->PRODUCT_USE_UNITS)
541
-					{
542
-						$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
543
-						$pdf->SetXY($this->posxunit, $curY);
544
-						$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
545
-					}
546
-
547
-					// Discount on line
548
-					$pdf->SetXY($this->posxdiscount, $curY);
549
-					if ($object->lines[$i]->remise_percent)
550
-					{
551
-					    $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
552
-						$pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $remise_percent, 0, 'R');
553
-					}
554
-
555
-					// Total HT line
471
+                    if ($pageposafter > $pageposbefore)	// There is a pagebreak
472
+                    {
473
+                        $pdf->rollbackTransaction(true);
474
+                        $pageposafter=$pageposbefore;
475
+                        //print $pageposafter.'-'.$pageposbefore;exit;
476
+                        $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
477
+                        pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1);
478
+                        $posyafter=$pdf->GetY();
479
+                        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
480
+                        {
481
+                            if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
482
+                            {
483
+                                $pdf->AddPage('','',true);
484
+                                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
485
+                                if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
486
+                                $pdf->setPage($pageposafter+1);
487
+                            }
488
+                        }
489
+                        else
490
+                        {
491
+                            // We found a page break
492
+                            $showpricebeforepagebreak=0;
493
+                        }
494
+                    }
495
+                    else	// No pagebreak
496
+                    {
497
+                        $pdf->commitTransaction();
498
+                    }
499
+
500
+                    $nexY = $pdf->GetY();
501
+                    $pageposafter=$pdf->getPage();
502
+                    $pdf->setPage($pageposbefore);
503
+                    $pdf->setTopMargin($this->marge_haute);
504
+                    $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
505
+
506
+                    // We suppose that a too long description is moved completely on next page
507
+                    if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
508
+                        $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
509
+                    }
510
+
511
+                    $pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
512
+
513
+                    // VAT Rate
514
+                    if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
515
+                    {
516
+                        $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
517
+                        $pdf->SetXY($this->posxtva, $curY);
518
+                        $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R');
519
+                    }
520
+
521
+                    // Unit price before discount
522
+                    $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
523
+                    $pdf->SetXY($this->posxup, $curY);
524
+                    $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
525
+
526
+                    // Quantity
527
+                    $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
528
+                    $pdf->SetXY($this->posxqty, $curY);
529
+                    // Enough for 6 chars
530
+                    if($conf->global->PRODUCT_USE_UNITS)
531
+                    {
532
+                        $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
533
+                    }
534
+                    else
535
+                    {
536
+                        $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
537
+                    }
538
+
539
+                    // Unit
540
+                    if($conf->global->PRODUCT_USE_UNITS)
541
+                    {
542
+                        $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
543
+                        $pdf->SetXY($this->posxunit, $curY);
544
+                        $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
545
+                    }
546
+
547
+                    // Discount on line
548
+                    $pdf->SetXY($this->posxdiscount, $curY);
549
+                    if ($object->lines[$i]->remise_percent)
550
+                    {
551
+                        $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
552
+                        $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $remise_percent, 0, 'R');
553
+                    }
554
+
555
+                    // Total HT line
556 556
                     $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs);
557
-					$pdf->SetXY($this->postotalht, $curY);
558
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
559
-
560
-					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
561
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
562
-					else $tvaligne=$object->lines[$i]->total_tva;
563
-
564
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
565
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
566
-					$localtax1_rate=$object->lines[$i]->localtax1_tx;
567
-					$localtax2_rate=$object->lines[$i]->localtax2_tx;
568
-					$localtax1_type=$object->lines[$i]->localtax1_type;
569
-					$localtax2_type=$object->lines[$i]->localtax2_type;
570
-
571
-					if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100;
572
-					if (! empty($object->remise_percent)) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
573
-					if (! empty($object->remise_percent)) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
574
-
575
-					$vatrate=(string) $object->lines[$i]->tva_tx;
576
-
577
-					// Retrieve type from database for backward compatibility with old records
578
-					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
579
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
580
-					{
581
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc,$object->thirdparty);
582
-						$localtax1_type = $localtaxtmp_array[0];
583
-						$localtax2_type = $localtaxtmp_array[2];
584
-					}
585
-
586
-				    // retrieve global local tax
587
-					if ($localtax1_type && $localtax1ligne != 0)
588
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
589
-					if ($localtax2_type && $localtax2ligne != 0)
590
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
591
-
592
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
593
-					if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
594
-					$this->tva[$vatrate] += $tvaligne;
595
-
596
-					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
597
-
598
-					// Add line
599
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
600
-					{
601
-						$pdf->setPage($pageposafter);
602
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
603
-						//$pdf->SetDrawColor(190,190,200);
604
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
605
-						$pdf->SetLineStyle(array('dash'=>0));
606
-					}
607
-
608
-					$nexY+=2;    // Passe espace entre les lignes
609
-
610
-					// Detect if some page were added automatically and output _tableau for past pages
611
-					while ($pagenb < $pageposafter)
612
-					{
613
-						$pdf->setPage($pagenb);
614
-						if ($pagenb == 1)
615
-						{
616
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
617
-						}
618
-						else
619
-						{
620
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
621
-						}
622
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
623
-						$pagenb++;
624
-						$pdf->setPage($pagenb);
625
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
626
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
627
-					}
628
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
629
-					{
630
-						if ($pagenb == 1)
631
-						{
632
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
633
-						}
634
-						else
635
-						{
636
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
637
-						}
638
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
639
-						// New page
640
-						$pdf->AddPage();
641
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
642
-						$pagenb++;
643
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
644
-					}
645
-				}
646
-
647
-				// Show square
648
-				if ($pagenb == 1)
649
-				{
650
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
651
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
652
-				}
653
-				else
654
-				{
655
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
656
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
657
-				}
658
-
659
-				// Affiche zone infos
660
-				$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
661
-
662
-				// Affiche zone totaux
663
-				$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
664
-
665
-				// Affiche zone versements
666
-				if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included)
667
-				{
668
-					$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
669
-				}
557
+                    $pdf->SetXY($this->postotalht, $curY);
558
+                    $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
559
+
560
+                    // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
561
+                    if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
562
+                    else $tvaligne=$object->lines[$i]->total_tva;
563
+
564
+                    $localtax1ligne=$object->lines[$i]->total_localtax1;
565
+                    $localtax2ligne=$object->lines[$i]->total_localtax2;
566
+                    $localtax1_rate=$object->lines[$i]->localtax1_tx;
567
+                    $localtax2_rate=$object->lines[$i]->localtax2_tx;
568
+                    $localtax1_type=$object->lines[$i]->localtax1_type;
569
+                    $localtax2_type=$object->lines[$i]->localtax2_type;
570
+
571
+                    if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100;
572
+                    if (! empty($object->remise_percent)) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
573
+                    if (! empty($object->remise_percent)) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
574
+
575
+                    $vatrate=(string) $object->lines[$i]->tva_tx;
576
+
577
+                    // Retrieve type from database for backward compatibility with old records
578
+                    if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
579
+                    && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
580
+                    {
581
+                        $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc,$object->thirdparty);
582
+                        $localtax1_type = $localtaxtmp_array[0];
583
+                        $localtax2_type = $localtaxtmp_array[2];
584
+                    }
585
+
586
+                    // retrieve global local tax
587
+                    if ($localtax1_type && $localtax1ligne != 0)
588
+                        $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
589
+                    if ($localtax2_type && $localtax2ligne != 0)
590
+                        $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
591
+
592
+                    if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
593
+                    if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
594
+                    $this->tva[$vatrate] += $tvaligne;
595
+
596
+                    if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
597
+
598
+                    // Add line
599
+                    if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
600
+                    {
601
+                        $pdf->setPage($pageposafter);
602
+                        $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
603
+                        //$pdf->SetDrawColor(190,190,200);
604
+                        $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
605
+                        $pdf->SetLineStyle(array('dash'=>0));
606
+                    }
607
+
608
+                    $nexY+=2;    // Passe espace entre les lignes
609
+
610
+                    // Detect if some page were added automatically and output _tableau for past pages
611
+                    while ($pagenb < $pageposafter)
612
+                    {
613
+                        $pdf->setPage($pagenb);
614
+                        if ($pagenb == 1)
615
+                        {
616
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
617
+                        }
618
+                        else
619
+                        {
620
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
621
+                        }
622
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
623
+                        $pagenb++;
624
+                        $pdf->setPage($pagenb);
625
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
626
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
627
+                    }
628
+                    if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
629
+                    {
630
+                        if ($pagenb == 1)
631
+                        {
632
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
633
+                        }
634
+                        else
635
+                        {
636
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
637
+                        }
638
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
639
+                        // New page
640
+                        $pdf->AddPage();
641
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
642
+                        $pagenb++;
643
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
644
+                    }
645
+                }
646
+
647
+                // Show square
648
+                if ($pagenb == 1)
649
+                {
650
+                    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
651
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
652
+                }
653
+                else
654
+                {
655
+                    $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
656
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
657
+                }
658
+
659
+                // Affiche zone infos
660
+                $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
661
+
662
+                // Affiche zone totaux
663
+                $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
664
+
665
+                // Affiche zone versements
666
+                if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included)
667
+                {
668
+                    $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
669
+                }
670 670
 
671 671
                 // Pied de page
672
-				$this->_pagefoot($pdf, $object, $outputlangs);
673
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
672
+                $this->_pagefoot($pdf, $object, $outputlangs);
673
+                if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
674 674
 
675
-				$pdf->Close();
675
+                $pdf->Close();
676 676
 
677
-				$pdf->Output($file,'F');
677
+                $pdf->Output($file,'F');
678 678
 
679
-				// Add pdfgeneration hook
680
-				$hookmanager->initHooks(array('pdfgeneration'));
681
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
682
-				global $action;
683
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
679
+                // Add pdfgeneration hook
680
+                $hookmanager->initHooks(array('pdfgeneration'));
681
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
682
+                global $action;
683
+                $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
684 684
 
685
-				if (! empty($conf->global->MAIN_UMASK))
686
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
685
+                if (! empty($conf->global->MAIN_UMASK))
686
+                @chmod($file, octdec($conf->global->MAIN_UMASK));
687 687
 
688
-				$this->result = array('fullpath'=>$file);
688
+                $this->result = array('fullpath'=>$file);
689 689
 
690
-				return 1;   // Pas d'erreur
691
-			}
692
-			else
693
-			{
694
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
695
-				return 0;
696
-			}
697
-		}
698
-		else
699
-		{
700
-			$this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR");
701
-			return 0;
702
-		}
703
-	}
690
+                return 1;   // Pas d'erreur
691
+            }
692
+            else
693
+            {
694
+                $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
695
+                return 0;
696
+            }
697
+        }
698
+        else
699
+        {
700
+            $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR");
701
+            return 0;
702
+        }
703
+    }
704 704
 
705 705
 
706 706
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
707
-	/**
708
-	 *  Show payments table
709
-	 *
710
-	 *  @param	PDF			$pdf     		Object PDF
711
-	 *  @param  CommandeFournisseur		$object			Object order
712
-	 *	@param	int			$posy			Position y in PDF
713
-	 *	@param	Translate	$outputlangs	Object langs for output
714
-	 *	@return int							<0 if KO, >0 if OK
715
-	 */
716
-	function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
717
-	{
707
+    /**
708
+     *  Show payments table
709
+     *
710
+     *  @param	PDF			$pdf     		Object PDF
711
+     *  @param  CommandeFournisseur		$object			Object order
712
+     *	@param	int			$posy			Position y in PDF
713
+     *	@param	Translate	$outputlangs	Object langs for output
714
+     *	@return int							<0 if KO, >0 if OK
715
+     */
716
+    function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
717
+    {
718 718
         // phpcs:enable
719
-	}
719
+    }
720 720
 
721 721
 
722 722
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
723
-	/**
724
-	 *   Show miscellaneous information (payment mode, payment term, ...)
725
-	 *
726
-	 *   @param		PDF			$pdf     		Object PDF
727
-	 *   @param		CommandeFournisseur		$object			Object to show
728
-	 *   @param		int			$posy			Y
729
-	 *   @param		Translate	$outputlangs	Langs object
730
-	 *   @return	integer
731
-	 */
732
-	function _tableau_info(&$pdf, $object, $posy, $outputlangs)
733
-	{
723
+    /**
724
+     *   Show miscellaneous information (payment mode, payment term, ...)
725
+     *
726
+     *   @param		PDF			$pdf     		Object PDF
727
+     *   @param		CommandeFournisseur		$object			Object to show
728
+     *   @param		int			$posy			Y
729
+     *   @param		Translate	$outputlangs	Langs object
730
+     *   @return	integer
731
+     */
732
+    function _tableau_info(&$pdf, $object, $posy, $outputlangs)
733
+    {
734 734
         // phpcs:enable
735
-	    global $conf;
736
-	    $default_font_size = pdf_getPDFFontSize($outputlangs);
735
+        global $conf;
736
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
737 737
 
738 738
         // If France, show VAT mention if not applicable
739
-		if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
740
-		{
741
-			$pdf->SetFont('','B', $default_font_size - 2);
742
-			$pdf->SetXY($this->marge_gauche, $posy);
743
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
744
-
745
-			$posy=$pdf->GetY()+4;
746
-		}
747
-
748
-		$posxval=52;
739
+        if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
740
+        {
741
+            $pdf->SetFont('','B', $default_font_size - 2);
742
+            $pdf->SetXY($this->marge_gauche, $posy);
743
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
749 744
 
750
-	    // Show payments conditions
751
-	    if (!empty($object->cond_reglement_code) || $object->cond_reglement)
752
-	    {
753
-	        $pdf->SetFont('','B', $default_font_size - 2);
754
-	        $pdf->SetXY($this->marge_gauche, $posy);
755
-	        $titre = $outputlangs->transnoentities("PaymentConditions").':';
756
-	        $pdf->MultiCell(80, 4, $titre, 0, 'L');
745
+            $posy=$pdf->GetY()+4;
746
+        }
757 747
 
758
-			$pdf->SetFont('','', $default_font_size - 2);
759
-			$pdf->SetXY($posxval, $posy);
760
-			$lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement);
761
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
762
-			$pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
748
+        $posxval=52;
763 749
 
764
-	        $posy=$pdf->GetY()+3;
765
-	    }
750
+        // Show payments conditions
751
+        if (!empty($object->cond_reglement_code) || $object->cond_reglement)
752
+        {
753
+            $pdf->SetFont('','B', $default_font_size - 2);
754
+            $pdf->SetXY($this->marge_gauche, $posy);
755
+            $titre = $outputlangs->transnoentities("PaymentConditions").':';
756
+            $pdf->MultiCell(80, 4, $titre, 0, 'L');
757
+
758
+            $pdf->SetFont('','', $default_font_size - 2);
759
+            $pdf->SetXY($posxval, $posy);
760
+            $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement);
761
+            $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
762
+            $pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
763
+
764
+            $posy=$pdf->GetY()+3;
765
+        }
766 766
 
767
-      	// Show payment mode
767
+            // Show payment mode
768 768
         if (!empty($object->mode_reglement_code))
769 769
         {
770
-        	$pdf->SetFont('','B', $default_font_size - 2);
771
-        	$pdf->SetXY($this->marge_gauche, $posy);
772
-        	$titre = $outputlangs->transnoentities("PaymentMode").':';
773
-        	$pdf->MultiCell(80, 5, $titre, 0, 'L');
770
+            $pdf->SetFont('','B', $default_font_size - 2);
771
+            $pdf->SetXY($this->marge_gauche, $posy);
772
+            $titre = $outputlangs->transnoentities("PaymentMode").':';
773
+            $pdf->MultiCell(80, 5, $titre, 0, 'L');
774 774
 
775
-        	$pdf->SetFont('','', $default_font_size - 2);
776
-        	$pdf->SetXY($posxval, $posy);
777
-        	$lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
778
-        	$pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
775
+            $pdf->SetFont('','', $default_font_size - 2);
776
+            $pdf->SetXY($posxval, $posy);
777
+            $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
778
+            $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
779 779
 
780
-        	$posy=$pdf->GetY()+2;
780
+            $posy=$pdf->GetY()+2;
781 781
         }
782 782
 
783 783
 
784
-		return $posy;
785
-	}
784
+        return $posy;
785
+    }
786 786
 
787 787
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
788
-	/**
789
-	 *  Show total to pay
790
-	 *
791
-	 *  @param	PDF			$pdf           Object PDF
792
-	 *	@param  Facture		$object         Object invoice
793
-	 *	@param  int			$deja_regle     Montant deja regle
794
-	 *	@param	int			$posy			Position depart
795
-	 *	@param	Translate	$outputlangs	Objet langs
796
-	 *	@return int							Position pour suite
797
-	 */
798
-	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
799
-	{
788
+    /**
789
+     *  Show total to pay
790
+     *
791
+     *  @param	PDF			$pdf           Object PDF
792
+     *	@param  Facture		$object         Object invoice
793
+     *	@param  int			$deja_regle     Montant deja regle
794
+     *	@param	int			$posy			Position depart
795
+     *	@param	Translate	$outputlangs	Objet langs
796
+     *	@return int							Position pour suite
797
+     */
798
+    function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
799
+    {
800 800
         // phpcs:enable
801
-		global $conf,$mysoc;
801
+        global $conf,$mysoc;
802 802
 
803
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
803
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
804 804
 
805 805
         $tab2_top = $posy;
806
-		$tab2_hl = 4;
807
-		$pdf->SetFont('','', $default_font_size - 1);
806
+        $tab2_hl = 4;
807
+        $pdf->SetFont('','', $default_font_size - 1);
808 808
 
809
-		// Tableau total
810
-		$col1x = 120; $col2x = 170;
811
-		if ($this->page_largeur < 210) // To work with US executive format
812
-		{
813
-			$col2x-=20;
814
-		}
815
-		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
809
+        // Tableau total
810
+        $col1x = 120; $col2x = 170;
811
+        if ($this->page_largeur < 210) // To work with US executive format
812
+        {
813
+            $col2x-=20;
814
+        }
815
+        $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
816 816
 
817
-		$useborder=0;
818
-		$index = 0;
817
+        $useborder=0;
818
+        $index = 0;
819 819
 
820
-		// Total HT
821
-		$pdf->SetFillColor(255,255,255);
822
-		$pdf->SetXY($col1x, $tab2_top + 0);
823
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
820
+        // Total HT
821
+        $pdf->SetFillColor(255,255,255);
822
+        $pdf->SetXY($col1x, $tab2_top + 0);
823
+        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
824 824
 
825
-		$total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
826
-		$pdf->SetXY($col2x, $tab2_top + 0);
827
-		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0)), 0, 'R', 1);
825
+        $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
826
+        $pdf->SetXY($col2x, $tab2_top + 0);
827
+        $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0)), 0, 'R', 1);
828 828
 
829
-		// Show VAT by rates and total
830
-		$pdf->SetFillColor(248,248,248);
829
+        // Show VAT by rates and total
830
+        $pdf->SetFillColor(248,248,248);
831 831
 
832
-		$this->atleastoneratenotnull=0;
833
-		foreach( $this->tva as $tvakey => $tvaval )
834
-		{
835
-			if ($tvakey > 0)    // On affiche pas taux 0
836
-			{
837
-				$this->atleastoneratenotnull++;
838
-
839
-				$index++;
840
-				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
841
-
842
-				$tvacompl='';
843
-
844
-				if (preg_match('/\*/',$tvakey))
845
-				{
846
-					$tvakey=str_replace('*','',$tvakey);
847
-					$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
848
-				}
849
-
850
-				$totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
851
-				$totalvat.=vatrate($tvakey,1).$tvacompl;
852
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
853
-
854
-				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
855
-				$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
856
-			}
857
-		}
858
-		if (! $this->atleastoneratenotnull) // If no vat at all
859
-		{
860
-			$index++;
861
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
862
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1);
863
-
864
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
865
-			$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);
866
-
867
-			// Total LocalTax1
868
-			if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0)
869
-			{
870
-				$index++;
871
-				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
872
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code), 0, 'L', 1);
873
-				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
874
-				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1);
875
-			}
876
-
877
-			// Total LocalTax2
878
-			if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0)
879
-			{
880
-				$index++;
881
-				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
882
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code), 0, 'L', 1);
883
-				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
884
-				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1);
885
-			}
886
-		}
887
-		else
888
-		{
889
-			//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
890
-			//{
891
-    			//Local tax 1
892
-			foreach( $this->localtax1 as $localtax_type => $localtax_rate )
893
-			{
894
-				if (in_array((string) $localtax_type, array('2','4','6'))) continue;
895
-
896
-				foreach( $localtax_rate as $tvakey => $tvaval )
897
-				{
898
-					if ($tvakey != 0)    // On affiche pas taux 0
899
-					{
900
-						//$this->atleastoneratenotnull++;
901
-
902
-						$index++;
903
-						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
904
-
905
-						$tvacompl='';
906
-						if (preg_match('/\*/',$tvakey))
907
-						{
908
-							$tvakey=str_replace('*','',$tvakey);
909
-							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
910
-						}
911
-						$totalvat =$outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
912
-						$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
913
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
914
-
915
-						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
916
-						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
917
-					}
918
-				}
919
-			}
920
-
921
-			//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
922
-			//{
923
-    			//Local tax 2
924
-			foreach( $this->localtax2 as $localtax_type => $localtax_rate )
925
-			{
926
-				if (in_array((string) $localtax_type, array('2','4','6'))) continue;
927
-
928
-				foreach( $localtax_rate as $tvakey => $tvaval )
929
-				{
930
-					if ($tvakey != 0)    // On affiche pas taux 0
931
-					{
932
-						//$this->atleastoneratenotnull++;
933
-
934
-						$index++;
935
-						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
936
-
937
-						$tvacompl='';
938
-						if (preg_match('/\*/',$tvakey))
939
-						{
940
-							$tvakey=str_replace('*','',$tvakey);
941
-							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
942
-						}
943
-						$totalvat =$outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
944
-						$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
945
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
946
-
947
-						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
948
-						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
949
-					}
950
-				}
951
-			}
952
-		}
953
-
954
-		// Total TTC
955
-		$index++;
956
-		$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
957
-		$pdf->SetTextColor(0,0,60);
958
-		$pdf->SetFillColor(224,224,224);
959
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
960
-
961
-		$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
962
-		$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
963
-		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1);
964
-		$pdf->SetFont('','', $default_font_size - 1);
965
-		$pdf->SetTextColor(0,0,0);
832
+        $this->atleastoneratenotnull=0;
833
+        foreach( $this->tva as $tvakey => $tvaval )
834
+        {
835
+            if ($tvakey > 0)    // On affiche pas taux 0
836
+            {
837
+                $this->atleastoneratenotnull++;
838
+
839
+                $index++;
840
+                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
841
+
842
+                $tvacompl='';
843
+
844
+                if (preg_match('/\*/',$tvakey))
845
+                {
846
+                    $tvakey=str_replace('*','',$tvakey);
847
+                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
848
+                }
849
+
850
+                $totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
851
+                $totalvat.=vatrate($tvakey,1).$tvacompl;
852
+                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
853
+
854
+                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
855
+                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
856
+            }
857
+        }
858
+        if (! $this->atleastoneratenotnull) // If no vat at all
859
+        {
860
+            $index++;
861
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
862
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1);
863
+
864
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
865
+            $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);
866
+
867
+            // Total LocalTax1
868
+            if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0)
869
+            {
870
+                $index++;
871
+                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
872
+                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code), 0, 'L', 1);
873
+                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
874
+                $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1);
875
+            }
876
+
877
+            // Total LocalTax2
878
+            if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0)
879
+            {
880
+                $index++;
881
+                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
882
+                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code), 0, 'L', 1);
883
+                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
884
+                $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1);
885
+            }
886
+        }
887
+        else
888
+        {
889
+            //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
890
+            //{
891
+                //Local tax 1
892
+            foreach( $this->localtax1 as $localtax_type => $localtax_rate )
893
+            {
894
+                if (in_array((string) $localtax_type, array('2','4','6'))) continue;
895
+
896
+                foreach( $localtax_rate as $tvakey => $tvaval )
897
+                {
898
+                    if ($tvakey != 0)    // On affiche pas taux 0
899
+                    {
900
+                        //$this->atleastoneratenotnull++;
901
+
902
+                        $index++;
903
+                        $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
904
+
905
+                        $tvacompl='';
906
+                        if (preg_match('/\*/',$tvakey))
907
+                        {
908
+                            $tvakey=str_replace('*','',$tvakey);
909
+                            $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
910
+                        }
911
+                        $totalvat =$outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
912
+                        $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
913
+                        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
914
+
915
+                        $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
916
+                        $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
917
+                    }
918
+                }
919
+            }
920
+
921
+            //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
922
+            //{
923
+                //Local tax 2
924
+            foreach( $this->localtax2 as $localtax_type => $localtax_rate )
925
+            {
926
+                if (in_array((string) $localtax_type, array('2','4','6'))) continue;
927
+
928
+                foreach( $localtax_rate as $tvakey => $tvaval )
929
+                {
930
+                    if ($tvakey != 0)    // On affiche pas taux 0
931
+                    {
932
+                        //$this->atleastoneratenotnull++;
933
+
934
+                        $index++;
935
+                        $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
936
+
937
+                        $tvacompl='';
938
+                        if (preg_match('/\*/',$tvakey))
939
+                        {
940
+                            $tvakey=str_replace('*','',$tvakey);
941
+                            $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
942
+                        }
943
+                        $totalvat =$outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
944
+                        $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
945
+                        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
946
+
947
+                        $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
948
+                        $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
949
+                    }
950
+                }
951
+            }
952
+        }
953
+
954
+        // Total TTC
955
+        $index++;
956
+        $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
957
+        $pdf->SetTextColor(0,0,60);
958
+        $pdf->SetFillColor(224,224,224);
959
+        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
960
+
961
+        $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
962
+        $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
963
+        $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1);
964
+        $pdf->SetFont('','', $default_font_size - 1);
965
+        $pdf->SetTextColor(0,0,0);
966 966
 
967 967
         $creditnoteamount=0;
968 968
         $depositsamount=0;
969
-		//$creditnoteamount=$object->getSumCreditNotesUsed();
970
-		//$depositsamount=$object->getSumDepositsUsed();
971
-		//print "x".$creditnoteamount."-".$depositsamount;exit;
972
-		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
973
-		if (! empty($object->paye)) $resteapayer=0;
969
+        //$creditnoteamount=$object->getSumCreditNotesUsed();
970
+        //$depositsamount=$object->getSumDepositsUsed();
971
+        //print "x".$creditnoteamount."-".$depositsamount;exit;
972
+        $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
973
+        if (! empty($object->paye)) $resteapayer=0;
974 974
 
975
-		if ($deja_regle > 0)
976
-		{
977
-			// Already paid + Deposits
978
-		    $index++;
975
+        if ($deja_regle > 0)
976
+        {
977
+            // Already paid + Deposits
978
+            $index++;
979 979
 
980
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
981
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
982
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
983
-			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);
980
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
981
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
982
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
983
+            $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);
984 984
 
985
-			$index++;
986
-			$pdf->SetTextColor(0,0,60);
987
-			$pdf->SetFillColor(224,224,224);
988
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
989
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
985
+            $index++;
986
+            $pdf->SetTextColor(0,0,60);
987
+            $pdf->SetFillColor(224,224,224);
988
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
989
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
990 990
 
991
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
992
-			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
991
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
992
+            $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
993 993
 
994
-			$pdf->SetFont('','', $default_font_size - 1);
995
-			$pdf->SetTextColor(0,0,0);
996
-		}
994
+            $pdf->SetFont('','', $default_font_size - 1);
995
+            $pdf->SetTextColor(0,0,0);
996
+        }
997 997
 
998
-		$index++;
999
-		return ($tab2_top + ($tab2_hl * $index));
1000
-	}
998
+        $index++;
999
+        return ($tab2_top + ($tab2_hl * $index));
1000
+    }
1001 1001
 
1002 1002
     /**
1003
-	 *   Show table for lines
1004
-	 *
1005
-	 *   @param		PDF			$pdf     		Object PDF
1006
-	 *   @param		string		$tab_top		Top position of table
1007
-	 *   @param		string		$tab_height		Height of table (rectangle)
1008
-	 *   @param		int			$nexY			Y (not used)
1009
-	 *   @param		Translate	$outputlangs	Langs object
1010
-	 *   @param		int			$hidetop		Hide top bar of array
1011
-	 *   @param		int			$hidebottom		Hide bottom bar of array
1012
-	 *   @param		string		$currency		Currency code
1013
-	 *   @return	void
1014
-	 */
1015
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1016
-	{
1017
-		global $conf;
1018
-
1019
-		// Force to disable hidetop and hidebottom
1020
-		$hidebottom=0;
1021
-		if ($hidetop) $hidetop=-1;
1022
-
1023
-		$currency = !empty($currency) ? $currency : $conf->currency;
1024
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1003
+     *   Show table for lines
1004
+     *
1005
+     *   @param		PDF			$pdf     		Object PDF
1006
+     *   @param		string		$tab_top		Top position of table
1007
+     *   @param		string		$tab_height		Height of table (rectangle)
1008
+     *   @param		int			$nexY			Y (not used)
1009
+     *   @param		Translate	$outputlangs	Langs object
1010
+     *   @param		int			$hidetop		Hide top bar of array
1011
+     *   @param		int			$hidebottom		Hide bottom bar of array
1012
+     *   @param		string		$currency		Currency code
1013
+     *   @return	void
1014
+     */
1015
+    function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1016
+    {
1017
+        global $conf;
1018
+
1019
+        // Force to disable hidetop and hidebottom
1020
+        $hidebottom=0;
1021
+        if ($hidetop) $hidetop=-1;
1022
+
1023
+        $currency = !empty($currency) ? $currency : $conf->currency;
1024
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1025 1025
 
1026 1026
         // Amount in (at tab_top - 1)
1027
-		$pdf->SetTextColor(0,0,0);
1028
-		$pdf->SetFont('','', $default_font_size - 2);
1027
+        $pdf->SetTextColor(0,0,0);
1028
+        $pdf->SetFont('','', $default_font_size - 2);
1029 1029
 
1030
-		if (empty($hidetop))
1031
-		{
1032
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1033
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1034
-			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1030
+        if (empty($hidetop))
1031
+        {
1032
+            $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1033
+            $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1034
+            $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1035 1035
 
1036
-			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1037
-			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1038
-		}
1036
+            //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1037
+            if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1038
+        }
1039 1039
 
1040
-		$pdf->SetDrawColor(128,128,128);
1041
-		$pdf->SetFont('','', $default_font_size - 1);
1040
+        $pdf->SetDrawColor(128,128,128);
1041
+        $pdf->SetFont('','', $default_font_size - 1);
1042 1042
 
1043
-		// Output Rect
1044
-		$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect prend une longueur en 3eme param et 4eme param
1043
+        // Output Rect
1044
+        $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect prend une longueur en 3eme param et 4eme param
1045 1045
 
1046
-		if (empty($hidetop))
1047
-		{
1048
-			$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);	// line prend une position y en 2eme param et 4eme param
1046
+        if (empty($hidetop))
1047
+        {
1048
+            $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);	// line prend une position y en 2eme param et 4eme param
1049 1049
 
1050
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
1051
-			$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1052
-		}
1050
+            $pdf->SetXY($this->posxdesc-1, $tab_top+1);
1051
+            $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1052
+        }
1053 1053
 
1054 1054
         if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1055 1055
         {
1056
-    		$pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height);
1057
-			if (empty($hidetop))
1058
-			{
1059
-    			$pdf->SetXY($this->posxtva-3, $tab_top+1);
1060
-    			$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1061
-			}
1056
+            $pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height);
1057
+            if (empty($hidetop))
1058
+            {
1059
+                $pdf->SetXY($this->posxtva-3, $tab_top+1);
1060
+                $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1061
+            }
1062 1062
         }
1063 1063
 
1064
-		$pdf->line($this->posxup, $tab_top, $this->posxup, $tab_top + $tab_height);
1065
-		if (empty($hidetop))
1066
-		{
1067
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
1068
-			$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1069
-		}
1064
+        $pdf->line($this->posxup, $tab_top, $this->posxup, $tab_top + $tab_height);
1065
+        if (empty($hidetop))
1066
+        {
1067
+            $pdf->SetXY($this->posxup-1, $tab_top+1);
1068
+            $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1069
+        }
1070 1070
 
1071
-		$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1072
-		if (empty($hidetop))
1073
-		{
1074
-			$pdf->SetXY($this->posxqty-1, $tab_top+1);
1075
-			if($conf->global->PRODUCT_USE_UNITS)
1076
-			{
1077
-				$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1078
-			}
1079
-			else
1080
-			{
1081
-				$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1082
-			}
1083
-		}
1084
-
1085
-		if($conf->global->PRODUCT_USE_UNITS) {
1086
-			$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1087
-			if (empty($hidetop)) {
1088
-				$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1089
-				$pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
1090
-					'C');
1091
-			}
1092
-		}
1093
-
1094
-		$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1095
-		if (empty($hidetop))
1096
-		{
1097
-			if ($this->atleastonediscount)
1098
-			{
1099
-				$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1100
-				$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1101
-			}
1102
-		}
1103
-
1104
-		if ($this->atleastonediscount)
1105
-		{
1106
-			$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1107
-		}
1108
-		if (empty($hidetop))
1109
-		{
1110
-			$pdf->SetXY($this->postotalht-1, $tab_top+1);
1111
-			$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHTShort"),'','C');
1112
-		}
1113
-	}
1114
-
1115
-	/**
1116
-	 *  Show top header of page.
1117
-	 *
1118
-	 *  @param	PDF			$pdf     		Object PDF
1119
-	 *  @param  CommandeFournisseur		$object     	Object to show
1120
-	 *  @param  int	    	$showaddress    0=no, 1=yes
1121
-	 *  @param  Translate	$outputlangs	Object lang for output
1122
-	 *  @return	void
1123
-	 */
1124
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1125
-	{
1126
-		global $langs, $conf, $mysoc;
1127
-
1128
-		// Load translation files required by the page
1129
-		$outputlangs->loadLangs(array("main", "orders", "companies", "bills", "sendings"));
1130
-
1131
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1132
-
1133
-		// Do not add the BACKGROUND as this is for suppliers
1134
-		//pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1135
-
1136
-		//Affiche le filigrane brouillon - Print Draft Watermark
1137
-		/*if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
1071
+        $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1072
+        if (empty($hidetop))
1073
+        {
1074
+            $pdf->SetXY($this->posxqty-1, $tab_top+1);
1075
+            if($conf->global->PRODUCT_USE_UNITS)
1076
+            {
1077
+                $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1078
+            }
1079
+            else
1080
+            {
1081
+                $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1082
+            }
1083
+        }
1084
+
1085
+        if($conf->global->PRODUCT_USE_UNITS) {
1086
+            $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1087
+            if (empty($hidetop)) {
1088
+                $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1089
+                $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
1090
+                    'C');
1091
+            }
1092
+        }
1093
+
1094
+        $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1095
+        if (empty($hidetop))
1096
+        {
1097
+            if ($this->atleastonediscount)
1098
+            {
1099
+                $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1100
+                $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1101
+            }
1102
+        }
1103
+
1104
+        if ($this->atleastonediscount)
1105
+        {
1106
+            $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1107
+        }
1108
+        if (empty($hidetop))
1109
+        {
1110
+            $pdf->SetXY($this->postotalht-1, $tab_top+1);
1111
+            $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHTShort"),'','C');
1112
+        }
1113
+    }
1114
+
1115
+    /**
1116
+     *  Show top header of page.
1117
+     *
1118
+     *  @param	PDF			$pdf     		Object PDF
1119
+     *  @param  CommandeFournisseur		$object     	Object to show
1120
+     *  @param  int	    	$showaddress    0=no, 1=yes
1121
+     *  @param  Translate	$outputlangs	Object lang for output
1122
+     *  @return	void
1123
+     */
1124
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1125
+    {
1126
+        global $langs, $conf, $mysoc;
1127
+
1128
+        // Load translation files required by the page
1129
+        $outputlangs->loadLangs(array("main", "orders", "companies", "bills", "sendings"));
1130
+
1131
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1132
+
1133
+        // Do not add the BACKGROUND as this is for suppliers
1134
+        //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1135
+
1136
+        //Affiche le filigrane brouillon - Print Draft Watermark
1137
+        /*if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
1138 1138
 		{
1139 1139
             pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
1140 1140
 		}*/
1141
-		//Print content
1141
+        //Print content
1142 1142
 
1143
-		$pdf->SetTextColor(0,0,60);
1144
-		$pdf->SetFont('','B',$default_font_size + 3);
1143
+        $pdf->SetTextColor(0,0,60);
1144
+        $pdf->SetFont('','B',$default_font_size + 3);
1145 1145
 
1146
-		$posx=$this->page_largeur-$this->marge_droite-100;
1147
-		$posy=$this->marge_haute;
1146
+        $posx=$this->page_largeur-$this->marge_droite-100;
1147
+        $posy=$this->marge_haute;
1148 1148
 
1149
-		$pdf->SetXY($this->marge_gauche,$posy);
1149
+        $pdf->SetXY($this->marge_gauche,$posy);
1150 1150
 
1151
-		// Logo
1152
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1153
-		if ($this->emetteur->logo)
1154
-		{
1155
-			if (is_readable($logo))
1156
-			{
1157
-			    $height=pdf_getHeightForLogo($logo);
1158
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1159
-			}
1160
-			else
1161
-			{
1162
-				$pdf->SetTextColor(200,0,0);
1163
-				$pdf->SetFont('','B', $default_font_size - 2);
1164
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1165
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
1166
-			}
1167
-		}
1168
-		else
1169
-		{
1170
-			$text=$this->emetteur->name;
1171
-			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1172
-		}
1173
-
1174
-		$pdf->SetFont('', 'B', $default_font_size + 3);
1175
-		$pdf->SetXY($posx,$posy);
1176
-		$pdf->SetTextColor(0,0,60);
1177
-		$title=$outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref);
1178
-		$pdf->MultiCell(100, 3, $title, '', 'R');
1179
-		$posy+=1;
1180
-
1181
-		if ($object->ref_supplier)
1182
-		{
1183
-			$posy+=4;
1184
-			$pdf->SetFont('','B', $default_font_size);
1185
-			$pdf->SetXY($posx,$posy);
1186
-			$pdf->SetTextColor(0,0,60);
1187
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : " . $outputlangs->convToOutputCharset($object->ref_supplier), '', 'R');
1188
-			$posy+=1;
1189
-		}
1151
+        // Logo
1152
+        $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1153
+        if ($this->emetteur->logo)
1154
+        {
1155
+            if (is_readable($logo))
1156
+            {
1157
+                $height=pdf_getHeightForLogo($logo);
1158
+                $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1159
+            }
1160
+            else
1161
+            {
1162
+                $pdf->SetTextColor(200,0,0);
1163
+                $pdf->SetFont('','B', $default_font_size - 2);
1164
+                $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1165
+                $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
1166
+            }
1167
+        }
1168
+        else
1169
+        {
1170
+            $text=$this->emetteur->name;
1171
+            $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1172
+        }
1190 1173
 
1191
-		$pdf->SetFont('','', $default_font_size -1);
1174
+        $pdf->SetFont('', 'B', $default_font_size + 3);
1175
+        $pdf->SetXY($posx,$posy);
1176
+        $pdf->SetTextColor(0,0,60);
1177
+        $title=$outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref);
1178
+        $pdf->MultiCell(100, 3, $title, '', 'R');
1179
+        $posy+=1;
1192 1180
 
1193
-		if (! empty($conf->global->PDF_SHOW_PROJECT))
1194
-		{
1195
-			$object->fetch_projet();
1196
-			if (! empty($object->project->ref))
1197
-			{
1198
-				$posy+=4;
1199
-				$pdf->SetXY($posx,$posy);
1200
-				$langs->load("projects");
1201
-				$pdf->SetTextColor(0,0,60);
1202
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R');
1203
-			}
1204
-		}
1205
-
1206
-		if (! empty($object->date_commande))
1207
-		{
1208
-			$posy+=5;
1209
-			$pdf->SetXY($posx,$posy);
1210
-			$pdf->SetTextColor(0,0,60);
1211
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date_commande,"day",false,$outputlangs,true), '', 'R');
1212
-		}
1213
-		else
1214
-		{
1215
-			$posy+=5;
1216
-			$pdf->SetXY($posx,$posy);
1217
-			$pdf->SetTextColor(255,0,0);
1218
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderToProcess"), '', 'R');
1219
-		}
1220
-
1221
-		$pdf->SetTextColor(0,0,60);
1222
-		$usehourmin='day';
1223
-		if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin='dayhour';
1224
-		if (! empty($object->date_livraison))
1225
-		{
1226
-			$posy+=4;
1227
-			$pdf->SetXY($posx-90,$posy);
1228
-			$pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_livraison,$usehourmin,false,$outputlangs,true), '', 'R');
1229
-		}
1181
+        if ($object->ref_supplier)
1182
+        {
1183
+            $posy+=4;
1184
+            $pdf->SetFont('','B', $default_font_size);
1185
+            $pdf->SetXY($posx,$posy);
1186
+            $pdf->SetTextColor(0,0,60);
1187
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : " . $outputlangs->convToOutputCharset($object->ref_supplier), '', 'R');
1188
+            $posy+=1;
1189
+        }
1230 1190
 
1231
-		if ($object->thirdparty->code_fournisseur)
1232
-		{
1233
-			$posy+=4;
1234
-			$pdf->SetXY($posx,$posy);
1235
-			$pdf->SetTextColor(0,0,60);
1236
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
1237
-		}
1238
-
1239
-		// Get contact
1240
-		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1241
-		{
1242
-    		$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1243
-    		if (count($arrayidcontact) > 0)
1244
-    		{
1245
-    		    $usertmp=new User($this->db);
1246
-    		    $usertmp->fetch($arrayidcontact[0]);
1191
+        $pdf->SetFont('','', $default_font_size -1);
1192
+
1193
+        if (! empty($conf->global->PDF_SHOW_PROJECT))
1194
+        {
1195
+            $object->fetch_projet();
1196
+            if (! empty($object->project->ref))
1197
+            {
1247 1198
                 $posy+=4;
1248 1199
                 $pdf->SetXY($posx,$posy);
1249
-    		    $pdf->SetTextColor(0,0,60);
1250
-    		    $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
1251
-    		}
1252
-		}
1253
-
1254
-		$posy+=1;
1255
-		$pdf->SetTextColor(0,0,60);
1256
-
1257
-		$top_shift = 0;
1258
-		// Show list of linked objects
1259
-		$current_y = $pdf->getY();
1260
-		$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1261
-		if ($current_y < $pdf->getY())
1262
-		{
1263
-			$top_shift = $pdf->getY() - $current_y;
1264
-		}
1200
+                $langs->load("projects");
1201
+                $pdf->SetTextColor(0,0,60);
1202
+                $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R');
1203
+            }
1204
+        }
1265 1205
 
1266
-		if ($showaddress)
1267
-		{
1268
-		    // Sender properties
1269
-		    $carac_emetteur='';
1270
-		    // Add internal contact of proposal if defined
1271
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1272
-		    if (count($arrayidcontact) > 0)
1273
-		    {
1274
-		        $object->fetch_user($arrayidcontact[0]);
1275
-		        $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1276
-		    }
1277
-
1278
-			$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1279
-
1280
-			// Show sender
1281
-			$posy=42+$top_shift;
1282
-			$posx=$this->marge_gauche;
1283
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1284
-			$hautcadre=40;
1285
-
1286
-			// Show sender frame
1287
-			$pdf->SetTextColor(0,0,0);
1288
-			$pdf->SetFont('','', $default_font_size - 2);
1289
-			$pdf->SetXY($posx,$posy-5);
1290
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1291
-			$pdf->SetXY($posx,$posy);
1292
-			$pdf->SetFillColor(230,230,230);
1293
-			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1294
-			$pdf->SetTextColor(0,0,60);
1295
-
1296
-			// Show sender name
1297
-			$pdf->SetXY($posx+2,$posy+3);
1298
-			$pdf->SetFont('','B', $default_font_size);
1299
-			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1300
-			$posy=$pdf->getY();
1301
-
1302
-			// Show sender information
1303
-			$pdf->SetXY($posx+2,$posy);
1304
-			$pdf->SetFont('','', $default_font_size - 1);
1305
-			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1306
-
1307
-
1308
-
1309
-			// If BILLING contact defined on order, we use it
1310
-			$usecontact=false;
1311
-			$arrayidcontact=$object->getIdContact('external','BILLING');
1312
-			if (count($arrayidcontact) > 0)
1313
-			{
1314
-				$usecontact=true;
1315
-				$result=$object->fetch_contact($arrayidcontact[0]);
1316
-			}
1317
-
1318
-			//Recipient name
1319
-			// On peut utiliser le nom de la societe du contact
1320
-			if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1321
-				$thirdparty = $object->contact;
1322
-			} else {
1323
-				$thirdparty = $object->thirdparty;
1324
-			}
1325
-
1326
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1327
-
1328
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object);
1329
-
1330
-			// Show recipient
1331
-			$widthrecbox=100;
1332
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1333
-			$posy=42+$top_shift;
1334
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1335
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1336
-
1337
-			// Show recipient frame
1338
-			$pdf->SetTextColor(0,0,0);
1339
-			$pdf->SetFont('','', $default_font_size - 2);
1340
-			$pdf->SetXY($posx+2,$posy-5);
1341
-			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
1342
-			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1343
-
1344
-			// Show recipient name
1345
-			$pdf->SetXY($posx+2,$posy+3);
1346
-			$pdf->SetFont('','B', $default_font_size);
1347
-			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1348
-
1349
-			$posy = $pdf->getY();
1350
-
1351
-			// Show recipient information
1352
-			$pdf->SetFont('','', $default_font_size - 1);
1353
-			$pdf->SetXY($posx+2,$posy);
1354
-			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1355
-		}
1356
-
1357
-		return $top_shift;
1358
-	}
1359
-
1360
-	/**
1361
-	 *   	Show footer of page. Need this->emetteur object
1206
+        if (! empty($object->date_commande))
1207
+        {
1208
+            $posy+=5;
1209
+            $pdf->SetXY($posx,$posy);
1210
+            $pdf->SetTextColor(0,0,60);
1211
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date_commande,"day",false,$outputlangs,true), '', 'R');
1212
+        }
1213
+        else
1214
+        {
1215
+            $posy+=5;
1216
+            $pdf->SetXY($posx,$posy);
1217
+            $pdf->SetTextColor(255,0,0);
1218
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderToProcess"), '', 'R');
1219
+        }
1220
+
1221
+        $pdf->SetTextColor(0,0,60);
1222
+        $usehourmin='day';
1223
+        if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin='dayhour';
1224
+        if (! empty($object->date_livraison))
1225
+        {
1226
+            $posy+=4;
1227
+            $pdf->SetXY($posx-90,$posy);
1228
+            $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_livraison,$usehourmin,false,$outputlangs,true), '', 'R');
1229
+        }
1230
+
1231
+        if ($object->thirdparty->code_fournisseur)
1232
+        {
1233
+            $posy+=4;
1234
+            $pdf->SetXY($posx,$posy);
1235
+            $pdf->SetTextColor(0,0,60);
1236
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
1237
+        }
1238
+
1239
+        // Get contact
1240
+        if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1241
+        {
1242
+            $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1243
+            if (count($arrayidcontact) > 0)
1244
+            {
1245
+                $usertmp=new User($this->db);
1246
+                $usertmp->fetch($arrayidcontact[0]);
1247
+                $posy+=4;
1248
+                $pdf->SetXY($posx,$posy);
1249
+                $pdf->SetTextColor(0,0,60);
1250
+                $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
1251
+            }
1252
+        }
1253
+
1254
+        $posy+=1;
1255
+        $pdf->SetTextColor(0,0,60);
1256
+
1257
+        $top_shift = 0;
1258
+        // Show list of linked objects
1259
+        $current_y = $pdf->getY();
1260
+        $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1261
+        if ($current_y < $pdf->getY())
1262
+        {
1263
+            $top_shift = $pdf->getY() - $current_y;
1264
+        }
1265
+
1266
+        if ($showaddress)
1267
+        {
1268
+            // Sender properties
1269
+            $carac_emetteur='';
1270
+            // Add internal contact of proposal if defined
1271
+            $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1272
+            if (count($arrayidcontact) > 0)
1273
+            {
1274
+                $object->fetch_user($arrayidcontact[0]);
1275
+                $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1276
+            }
1277
+
1278
+            $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1279
+
1280
+            // Show sender
1281
+            $posy=42+$top_shift;
1282
+            $posx=$this->marge_gauche;
1283
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1284
+            $hautcadre=40;
1285
+
1286
+            // Show sender frame
1287
+            $pdf->SetTextColor(0,0,0);
1288
+            $pdf->SetFont('','', $default_font_size - 2);
1289
+            $pdf->SetXY($posx,$posy-5);
1290
+            $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1291
+            $pdf->SetXY($posx,$posy);
1292
+            $pdf->SetFillColor(230,230,230);
1293
+            $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1294
+            $pdf->SetTextColor(0,0,60);
1295
+
1296
+            // Show sender name
1297
+            $pdf->SetXY($posx+2,$posy+3);
1298
+            $pdf->SetFont('','B', $default_font_size);
1299
+            $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1300
+            $posy=$pdf->getY();
1301
+
1302
+            // Show sender information
1303
+            $pdf->SetXY($posx+2,$posy);
1304
+            $pdf->SetFont('','', $default_font_size - 1);
1305
+            $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1306
+
1307
+
1308
+
1309
+            // If BILLING contact defined on order, we use it
1310
+            $usecontact=false;
1311
+            $arrayidcontact=$object->getIdContact('external','BILLING');
1312
+            if (count($arrayidcontact) > 0)
1313
+            {
1314
+                $usecontact=true;
1315
+                $result=$object->fetch_contact($arrayidcontact[0]);
1316
+            }
1317
+
1318
+            //Recipient name
1319
+            // On peut utiliser le nom de la societe du contact
1320
+            if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1321
+                $thirdparty = $object->contact;
1322
+            } else {
1323
+                $thirdparty = $object->thirdparty;
1324
+            }
1325
+
1326
+            $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1327
+
1328
+            $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object);
1329
+
1330
+            // Show recipient
1331
+            $widthrecbox=100;
1332
+            if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1333
+            $posy=42+$top_shift;
1334
+            $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1335
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1336
+
1337
+            // Show recipient frame
1338
+            $pdf->SetTextColor(0,0,0);
1339
+            $pdf->SetFont('','', $default_font_size - 2);
1340
+            $pdf->SetXY($posx+2,$posy-5);
1341
+            $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
1342
+            $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1343
+
1344
+            // Show recipient name
1345
+            $pdf->SetXY($posx+2,$posy+3);
1346
+            $pdf->SetFont('','B', $default_font_size);
1347
+            $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1348
+
1349
+            $posy = $pdf->getY();
1350
+
1351
+            // Show recipient information
1352
+            $pdf->SetFont('','', $default_font_size - 1);
1353
+            $pdf->SetXY($posx+2,$posy);
1354
+            $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1355
+        }
1356
+
1357
+        return $top_shift;
1358
+    }
1359
+
1360
+    /**
1361
+     *   	Show footer of page. Need this->emetteur object
1362 1362
      *
1363
-	 *   	@param	PDF			$pdf     			PDF
1364
-	 * 		@param	CommandeFournisseur		$object				Object to show
1365
-	 *      @param	Translate	$outputlangs		Object lang for output
1366
-	 *      @param	int			$hidefreetext		1=Hide free text
1367
-	 *      @return	int								Return height of bottom margin including footer text
1368
-	 */
1369
-	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
1370
-	{
1371
-		global $conf;
1372
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1373
-		return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_ORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1374
-	}
1363
+     *   	@param	PDF			$pdf     			PDF
1364
+     * 		@param	CommandeFournisseur		$object				Object to show
1365
+     *      @param	Translate	$outputlangs		Object lang for output
1366
+     *      @param	int			$hidefreetext		1=Hide free text
1367
+     *      @return	int								Return height of bottom margin including footer text
1368
+     */
1369
+    function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
1370
+    {
1371
+        global $conf;
1372
+        $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1373
+        return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_ORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1374
+    }
1375 1375
 }
Please login to merge, or discard this patch.
Spacing   +388 added lines, -388 removed lines patch added patch discarded remove patch
@@ -133,67 +133,67 @@  discard block
 block discarded – undo
133 133
 
134 134
 		// Dimension page pour format A4
135 135
 		$this->type = 'pdf';
136
-		$formatarray=pdf_getFormat();
136
+		$formatarray = pdf_getFormat();
137 137
 		$this->page_largeur = $formatarray['width'];
138 138
 		$this->page_hauteur = $formatarray['height'];
139
-		$this->format = array($this->page_largeur,$this->page_hauteur);
140
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
141
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
142
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
143
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
144
-
145
-		$this->option_logo = 1;                    // Affiche logo
146
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
147
-		$this->option_modereg = 1;                 // Affiche mode reglement
148
-		$this->option_condreg = 1;                 // Affiche conditions reglement
149
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
150
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
151
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
152
-		$this->option_credit_note = 0;             // Support credit notes
153
-		$this->option_freetext = 1;				   // Support add of a personalised text
154
-		$this->option_draft_watermark = 1;		   // Support add of a watermark on drafts
155
-
156
-		$this->franchise=!$mysoc->tva_assuj;
139
+		$this->format = array($this->page_largeur, $this->page_hauteur);
140
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
141
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
142
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
143
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
144
+
145
+		$this->option_logo = 1; // Affiche logo
146
+		$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
147
+		$this->option_modereg = 1; // Affiche mode reglement
148
+		$this->option_condreg = 1; // Affiche conditions reglement
149
+		$this->option_codeproduitservice = 1; // Affiche code produit-service
150
+		$this->option_multilang = 1; // Dispo en plusieurs langues
151
+		$this->option_escompte = 0; // Affiche si il y a eu escompte
152
+		$this->option_credit_note = 0; // Support credit notes
153
+		$this->option_freetext = 1; // Support add of a personalised text
154
+		$this->option_draft_watermark = 1; // Support add of a watermark on drafts
155
+
156
+		$this->franchise = !$mysoc->tva_assuj;
157 157
 
158 158
         // Get source company
159
-		$this->emetteur=$mysoc;
160
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
159
+		$this->emetteur = $mysoc;
160
+		if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
161 161
 
162 162
 		// Defini position des colonnes
163
-		$this->posxdesc=$this->marge_gauche+1;
164
-		$this->posxdiscount=162;
165
-		$this->postotalht=174;
163
+		$this->posxdesc = $this->marge_gauche + 1;
164
+		$this->posxdiscount = 162;
165
+		$this->postotalht = 174;
166 166
 
167 167
 		if ($conf->global->PRODUCT_USE_UNITS)
168 168
 		{
169
-			$this->posxtva=95;
170
-			$this->posxup=114;
171
-			$this->posxqty=132;
172
-			$this->posxunit=147;
169
+			$this->posxtva = 95;
170
+			$this->posxup = 114;
171
+			$this->posxqty = 132;
172
+			$this->posxunit = 147;
173 173
 		} else {
174
-			$this->posxtva=110;
175
-			$this->posxup=126;
176
-			$this->posxqty=145;
174
+			$this->posxtva = 110;
175
+			$this->posxup = 126;
176
+			$this->posxqty = 145;
177 177
 		}
178 178
 
179
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxup = $this->posxtva; // posxtva is picture position reference
180
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
179
+		if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxup = $this->posxtva; // posxtva is picture position reference
180
+		$this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
181 181
 		if ($this->page_largeur < 210) // To work with US executive format
182 182
 		{
183
-			$this->posxpicture-=20;
184
-			$this->posxtva-=20;
185
-			$this->posxup-=20;
186
-			$this->posxqty-=20;
187
-			$this->posxunit-=20;
188
-			$this->posxdiscount-=20;
189
-			$this->postotalht-=20;
183
+			$this->posxpicture -= 20;
184
+			$this->posxtva -= 20;
185
+			$this->posxup -= 20;
186
+			$this->posxqty -= 20;
187
+			$this->posxunit -= 20;
188
+			$this->posxdiscount -= 20;
189
+			$this->postotalht -= 20;
190 190
 		}
191 191
 
192
-		$this->tva=array();
193
-        $this->localtax1=array();
194
-        $this->localtax2=array();
195
-        $this->atleastoneratenotnull=0;
196
-		$this->atleastonediscount=0;
192
+		$this->tva = array();
193
+        $this->localtax1 = array();
194
+        $this->localtax2 = array();
195
+        $this->atleastoneratenotnull = 0;
196
+		$this->atleastonediscount = 0;
197 197
 	}
198 198
 
199 199
 
@@ -209,14 +209,14 @@  discard block
 block discarded – undo
209 209
      *  @param		int					$hideref			Do not show ref
210 210
      *  @return		int										1=OK, 0=KO
211 211
      */
212
-	function write_file($object,$outputlangs='',$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
212
+	function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
213 213
 	{
214 214
         // phpcs:enable
215
-		global $user,$langs,$conf,$hookmanager,$mysoc,$nblignes;
215
+		global $user, $langs, $conf, $hookmanager, $mysoc, $nblignes;
216 216
 
217
-		if (! is_object($outputlangs)) $outputlangs=$langs;
217
+		if (!is_object($outputlangs)) $outputlangs = $langs;
218 218
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
219
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
219
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
220 220
 
221 221
 		// Load translation files required by the page
222 222
 		$outputlangs->loadLangs(array("main", "orders", "companies", "bills", "dict", "products"));
@@ -224,40 +224,40 @@  discard block
 block discarded – undo
224 224
 		$nblignes = count($object->lines);
225 225
 
226 226
 		// Loop on each lines to detect if there is at least one image to show
227
-		$realpatharray=array();
228
-		if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE))
227
+		$realpatharray = array();
228
+		if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE))
229 229
 		{
230
-			for ($i = 0 ; $i < $nblignes ; $i++)
230
+			for ($i = 0; $i < $nblignes; $i++)
231 231
 			{
232 232
 				if (empty($object->lines[$i]->fk_product)) continue;
233 233
 
234 234
 				$objphoto = new Product($this->db);
235 235
 				$objphoto->fetch($object->lines[$i]->fk_product);
236 236
 
237
-				if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
237
+				if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
238 238
 				{
239
-					$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
239
+					$pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
240 240
 					$dir = $conf->product->dir_output.'/'.$pdir;
241 241
 				}
242 242
 				else
243 243
 				{
244
-					$pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
244
+					$pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
245 245
 					$dir = $conf->product->dir_output.'/'.$pdir;
246 246
 				}
247 247
 
248
-				$realpath='';
249
-				foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
248
+				$realpath = '';
249
+				foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
250 250
 				{
251
-					$filename=$obj['photo'];
251
+					$filename = $obj['photo'];
252 252
 					//if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette'];
253 253
 					$realpath = $dir.$filename;
254 254
 					break;
255 255
 				}
256 256
 
257
-				if ($realpath) $realpatharray[$i]=$realpath;
257
+				if ($realpath) $realpatharray[$i] = $realpath;
258 258
 			}
259 259
 		}
260
-		if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
260
+		if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva;
261 261
 
262 262
 		if ($conf->fournisseur->commande->dir_output)
263 263
 		{
@@ -273,22 +273,22 @@  discard block
 block discarded – undo
273 273
 			if ($object->specimen)
274 274
 			{
275 275
 				$dir = $conf->fournisseur->commande->dir_output;
276
-				$file = $dir . "/SPECIMEN.pdf";
276
+				$file = $dir."/SPECIMEN.pdf";
277 277
 			}
278 278
 			else
279 279
 			{
280 280
 				$objectref = dol_sanitizeFileName($object->ref);
281 281
 				$objectrefsupplier = dol_sanitizeFileName($object->ref_supplier);
282
-				$dir = $conf->fournisseur->commande->dir_output . '/'. $objectref;
283
-				$file = $dir . "/" . $objectref . ".pdf";
284
-				if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf";
282
+				$dir = $conf->fournisseur->commande->dir_output.'/'.$objectref;
283
+				$file = $dir."/".$objectref.".pdf";
284
+				if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir."/".$objectref.($objectrefsupplier ? "_".$objectrefsupplier : "").".pdf";
285 285
 			}
286 286
 
287
-			if (! file_exists($dir))
287
+			if (!file_exists($dir))
288 288
 			{
289 289
 				if (dol_mkdir($dir) < 0)
290 290
 				{
291
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
291
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
292 292
 					return 0;
293 293
 				}
294 294
 			}
@@ -296,25 +296,25 @@  discard block
 block discarded – undo
296 296
 			if (file_exists($dir))
297 297
 			{
298 298
 				// Add pdfgeneration hook
299
-				if (! is_object($hookmanager))
299
+				if (!is_object($hookmanager))
300 300
 				{
301 301
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
302
-					$hookmanager=new HookManager($this->db);
302
+					$hookmanager = new HookManager($this->db);
303 303
 				}
304 304
 				$hookmanager->initHooks(array('pdfgeneration'));
305
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
305
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
306 306
 				global $action;
307
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
307
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
308 308
 
309 309
 				$nblignes = count($object->lines);
310 310
 
311
-                $pdf=pdf_getInstance($this->format);
312
-                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
313
-                $heightforinfotot = 50;	// Height reserved to output the info and total part
314
-		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
315
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
316
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
317
-                $pdf->SetAutoPageBreak(1,0);
311
+                $pdf = pdf_getInstance($this->format);
312
+                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
313
+                $heightforinfotot = 50; // Height reserved to output the info and total part
314
+		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
315
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
316
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
317
+                $pdf->SetAutoPageBreak(1, 0);
318 318
 
319 319
                 if (class_exists('TCPDF'))
320 320
                 {
@@ -323,27 +323,27 @@  discard block
 block discarded – undo
323 323
                 }
324 324
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
325 325
                 // Set path to the background PDF File
326
-                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
326
+                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
327 327
                 {
328 328
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
329 329
                     $tplidx = $pdf->importPage(1);
330 330
                 }
331 331
 
332 332
 				$pdf->Open();
333
-				$pagenb=0;
334
-				$pdf->SetDrawColor(128,128,128);
333
+				$pagenb = 0;
334
+				$pdf->SetDrawColor(128, 128, 128);
335 335
 
336 336
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
337 337
 				$pdf->SetSubject($outputlangs->transnoentities("Order"));
338 338
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
339 339
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
340 340
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
341
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
341
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
342 342
 
343
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
343
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
344 344
 
345 345
 				// Positionne $this->atleastonediscount si on a au moins une remise
346
-				for ($i = 0 ; $i < $nblignes ; $i++)
346
+				for ($i = 0; $i < $nblignes; $i++)
347 347
 				{
348 348
 					if ($object->lines[$i]->remise_percent)
349 349
 					{
@@ -352,25 +352,25 @@  discard block
 block discarded – undo
352 352
 				}
353 353
 				if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
354 354
 				{
355
-					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
356
-					$this->posxtva+=($this->postotalht - $this->posxdiscount);
357
-					$this->posxup+=($this->postotalht - $this->posxdiscount);
358
-					$this->posxqty+=($this->postotalht - $this->posxdiscount);
359
-					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
355
+					$this->posxpicture += ($this->postotalht - $this->posxdiscount);
356
+					$this->posxtva += ($this->postotalht - $this->posxdiscount);
357
+					$this->posxup += ($this->postotalht - $this->posxdiscount);
358
+					$this->posxqty += ($this->postotalht - $this->posxdiscount);
359
+					$this->posxdiscount += ($this->postotalht - $this->posxdiscount);
360 360
 					//$this->postotalht;
361 361
 				}
362 362
 
363 363
 				// New page
364 364
 				$pdf->AddPage();
365
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
365
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
366 366
 				$pagenb++;
367 367
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
368
-				$pdf->SetFont('','', $default_font_size - 1);
369
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
370
-				$pdf->SetTextColor(0,0,0);
368
+				$pdf->SetFont('', '', $default_font_size - 1);
369
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
370
+				$pdf->SetTextColor(0, 0, 0);
371 371
 
372
-				$tab_top = 90+$top_shift;
373
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
372
+				$tab_top = 90 + $top_shift;
373
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
374 374
 
375 375
 				// Incoterm
376 376
 				if ($conf->incoterm->enabled)
@@ -380,34 +380,34 @@  discard block
 block discarded – undo
380 380
 					{
381 381
 						$tab_top -= 2;
382 382
 
383
-						$pdf->SetFont('','', $default_font_size - 1);
384
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
383
+						$pdf->SetFont('', '', $default_font_size - 1);
384
+						$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
385 385
 						$nexY = $pdf->GetY();
386
-						$height_incoterms=$nexY-$tab_top;
386
+						$height_incoterms = $nexY - $tab_top;
387 387
 
388 388
 						// Rect prend une longueur en 3eme param
389
-						$pdf->SetDrawColor(192,192,192);
390
-						$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
389
+						$pdf->SetDrawColor(192, 192, 192);
390
+						$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
391 391
 
392
-						$tab_top = $nexY+6;
392
+						$tab_top = $nexY + 6;
393 393
 					}
394 394
 				}
395 395
 
396 396
 				// Affiche notes
397
-				if (! empty($object->note_public))
397
+				if (!empty($object->note_public))
398 398
 				{
399 399
 					$tab_top -= 2;
400 400
 
401
-					$pdf->SetFont('','', $default_font_size - 1);
402
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1);
401
+					$pdf->SetFont('', '', $default_font_size - 1);
402
+					$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($object->note_public), 0, 1);
403 403
 					$nexY = $pdf->GetY();
404
-					$height_note=$nexY-$tab_top;
404
+					$height_note = $nexY - $tab_top;
405 405
 
406 406
 					// Rect prend une longueur en 3eme param
407
-					$pdf->SetDrawColor(192,192,192);
408
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
407
+					$pdf->SetDrawColor(192, 192, 192);
408
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
409 409
 
410
-					$tab_top = $nexY+6;
410
+					$tab_top = $nexY + 6;
411 411
 				}
412 412
 
413 413
 				$iniY = $tab_top + 7;
@@ -415,81 +415,81 @@  discard block
 block discarded – undo
415 415
 				$nexY = $tab_top + 7;
416 416
 
417 417
 				// Loop on each lines
418
-				for ($i = 0 ; $i < $nblignes ; $i++)
418
+				for ($i = 0; $i < $nblignes; $i++)
419 419
 				{
420 420
 					$curY = $nexY;
421
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
422
-					$pdf->SetTextColor(0,0,0);
421
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
422
+					$pdf->SetTextColor(0, 0, 0);
423 423
 
424 424
 					// Define size of image if we need it
425
-					$imglinesize=array();
426
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
425
+					$imglinesize = array();
426
+					if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
427 427
 
428 428
 					$pdf->setTopMargin($tab_top_newpage);
429
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
430
-					$pageposbefore=$pdf->getPage();
429
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
430
+					$pageposbefore = $pdf->getPage();
431 431
 
432
-					$showpricebeforepagebreak=1;
433
-					$posYAfterImage=0;
434
-					$posYAfterDescription=0;
432
+					$showpricebeforepagebreak = 1;
433
+					$posYAfterImage = 0;
434
+					$posYAfterDescription = 0;
435 435
 
436 436
 					// We start with Photo of product line
437
-					if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
437
+					if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// If photo too high, we moved completely on new page
438 438
 					{
439
-						$pdf->AddPage('','',true);
440
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
439
+						$pdf->AddPage('', '', true);
440
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
441 441
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
442
-						$pdf->setPage($pageposbefore+1);
442
+						$pdf->setPage($pageposbefore + 1);
443 443
 
444 444
 						$curY = $tab_top_newpage;
445
-						$showpricebeforepagebreak=0;
445
+						$showpricebeforepagebreak = 0;
446 446
 					}
447 447
 
448 448
 					if (!empty($imglinesize['width']) && !empty($imglinesize['height']))
449 449
 					{
450
-						$curX = $this->posxpicture-1;
451
-						$pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
450
+						$curX = $this->posxpicture - 1;
451
+						$pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
452 452
 						// $pdf->Image does not increase value return by getY, so we save it manually
453
-						$posYAfterImage=$curY+$imglinesize['height'];
453
+						$posYAfterImage = $curY + $imglinesize['height'];
454 454
 					}
455 455
 					// Description of product line
456
-					$curX = $this->posxdesc-1;
457
-					$showpricebeforepagebreak=1;
456
+					$curX = $this->posxdesc - 1;
457
+					$showpricebeforepagebreak = 1;
458 458
 
459 459
 					$pdf->startTransaction();
460 460
 					if ($posYAfterImage > 0)
461 461
 					{
462
-						$descWidth = $this->posxpicture-$curX;
462
+						$descWidth = $this->posxpicture - $curX;
463 463
 					}
464 464
 					else
465 465
 					{
466
-						$descWidth = $this->posxtva-$curX;
466
+						$descWidth = $this->posxtva - $curX;
467 467
 					}
468
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1);
468
+					pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
469 469
 
470
-					$pageposafter=$pdf->getPage();
470
+					$pageposafter = $pdf->getPage();
471 471
 					if ($pageposafter > $pageposbefore)	// There is a pagebreak
472 472
 					{
473 473
 						$pdf->rollbackTransaction(true);
474
-						$pageposafter=$pageposbefore;
474
+						$pageposafter = $pageposbefore;
475 475
 						//print $pageposafter.'-'.$pageposbefore;exit;
476
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
477
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1);
478
-						$posyafter=$pdf->GetY();
479
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
476
+						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
477
+						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
478
+						$posyafter = $pdf->GetY();
479
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
480 480
 						{
481
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
481
+							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
482 482
 							{
483
-								$pdf->AddPage('','',true);
484
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
483
+								$pdf->AddPage('', '', true);
484
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
485 485
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
486
-								$pdf->setPage($pageposafter+1);
486
+								$pdf->setPage($pageposafter + 1);
487 487
 							}
488 488
 						}
489 489
 						else
490 490
 						{
491 491
 							// We found a page break
492
-							$showpricebeforepagebreak=0;
492
+							$showpricebeforepagebreak = 0;
493 493
 						}
494 494
 					}
495 495
 					else	// No pagebreak
@@ -498,50 +498,50 @@  discard block
 block discarded – undo
498 498
 					}
499 499
 
500 500
 					$nexY = $pdf->GetY();
501
-                    $pageposafter=$pdf->getPage();
501
+                    $pageposafter = $pdf->getPage();
502 502
 					$pdf->setPage($pageposbefore);
503 503
 					$pdf->setTopMargin($this->marge_haute);
504
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
504
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
505 505
 
506 506
 					// We suppose that a too long description is moved completely on next page
507 507
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
508 508
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
509 509
 					}
510 510
 
511
-					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
511
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
512 512
 
513 513
 					// VAT Rate
514 514
 					if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
515 515
 					{
516 516
 						$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
517 517
 						$pdf->SetXY($this->posxtva, $curY);
518
-						$pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R');
518
+						$pdf->MultiCell($this->posxup - $this->posxtva - 1, 3, $vat_rate, 0, 'R');
519 519
 					}
520 520
 
521 521
 					// Unit price before discount
522 522
 					$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
523 523
 					$pdf->SetXY($this->posxup, $curY);
524
-					$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
524
+					$pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0);
525 525
 
526 526
 					// Quantity
527 527
 					$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
528 528
 					$pdf->SetXY($this->posxqty, $curY);
529 529
 					// Enough for 6 chars
530
-					if($conf->global->PRODUCT_USE_UNITS)
530
+					if ($conf->global->PRODUCT_USE_UNITS)
531 531
 					{
532
-						$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
532
+						$pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R');
533 533
 					}
534 534
 					else
535 535
 					{
536
-						$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
536
+						$pdf->MultiCell($this->posxdiscount - $this->posxqty - 0.8, 4, $qty, 0, 'R');
537 537
 					}
538 538
 
539 539
 					// Unit
540
-					if($conf->global->PRODUCT_USE_UNITS)
540
+					if ($conf->global->PRODUCT_USE_UNITS)
541 541
 					{
542 542
 						$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
543 543
 						$pdf->SetXY($this->posxunit, $curY);
544
-						$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
544
+						$pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L');
545 545
 					}
546 546
 
547 547
 					// Discount on line
@@ -549,63 +549,63 @@  discard block
 block discarded – undo
549 549
 					if ($object->lines[$i]->remise_percent)
550 550
 					{
551 551
 					    $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
552
-						$pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $remise_percent, 0, 'R');
552
+						$pdf->MultiCell($this->postotalht - $this->posxdiscount - 1, 3, $remise_percent, 0, 'R');
553 553
 					}
554 554
 
555 555
 					// Total HT line
556 556
                     $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs);
557 557
 					$pdf->SetXY($this->postotalht, $curY);
558
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
558
+					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
559 559
 
560 560
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
561
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
562
-					else $tvaligne=$object->lines[$i]->total_tva;
561
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
562
+					else $tvaligne = $object->lines[$i]->total_tva;
563 563
 
564
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
565
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
566
-					$localtax1_rate=$object->lines[$i]->localtax1_tx;
567
-					$localtax2_rate=$object->lines[$i]->localtax2_tx;
568
-					$localtax1_type=$object->lines[$i]->localtax1_type;
569
-					$localtax2_type=$object->lines[$i]->localtax2_type;
564
+					$localtax1ligne = $object->lines[$i]->total_localtax1;
565
+					$localtax2ligne = $object->lines[$i]->total_localtax2;
566
+					$localtax1_rate = $object->lines[$i]->localtax1_tx;
567
+					$localtax2_rate = $object->lines[$i]->localtax2_tx;
568
+					$localtax1_type = $object->lines[$i]->localtax1_type;
569
+					$localtax2_type = $object->lines[$i]->localtax2_type;
570 570
 
571
-					if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100;
572
-					if (! empty($object->remise_percent)) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
573
-					if (! empty($object->remise_percent)) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
571
+					if (!empty($object->remise_percent)) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
572
+					if (!empty($object->remise_percent)) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
573
+					if (!empty($object->remise_percent)) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
574 574
 
575
-					$vatrate=(string) $object->lines[$i]->tva_tx;
575
+					$vatrate = (string) $object->lines[$i]->tva_tx;
576 576
 
577 577
 					// Retrieve type from database for backward compatibility with old records
578
-					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
579
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
578
+					if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
579
+					&& (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
580 580
 					{
581
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc,$object->thirdparty);
581
+						$localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $mysoc, $object->thirdparty);
582 582
 						$localtax1_type = $localtaxtmp_array[0];
583 583
 						$localtax2_type = $localtaxtmp_array[2];
584 584
 					}
585 585
 
586 586
 				    // retrieve global local tax
587 587
 					if ($localtax1_type && $localtax1ligne != 0)
588
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
588
+						$this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
589 589
 					if ($localtax2_type && $localtax2ligne != 0)
590
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
590
+						$this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
591 591
 
592
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
593
-					if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
592
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
593
+					if (!isset($this->tva[$vatrate])) 				$this->tva[$vatrate] = 0;
594 594
 					$this->tva[$vatrate] += $tvaligne;
595 595
 
596
-					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
596
+					if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage;
597 597
 
598 598
 					// Add line
599
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
599
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
600 600
 					{
601 601
 						$pdf->setPage($pageposafter);
602
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
602
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
603 603
 						//$pdf->SetDrawColor(190,190,200);
604
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
604
+						$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
605 605
 						$pdf->SetLineStyle(array('dash'=>0));
606 606
 					}
607 607
 
608
-					$nexY+=2;    // Passe espace entre les lignes
608
+					$nexY += 2; // Passe espace entre les lignes
609 609
 
610 610
 					// Detect if some page were added automatically and output _tableau for past pages
611 611
 					while ($pagenb < $pageposafter)
@@ -619,13 +619,13 @@  discard block
 block discarded – undo
619 619
 						{
620 620
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
621 621
 						}
622
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
622
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
623 623
 						$pagenb++;
624 624
 						$pdf->setPage($pagenb);
625
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
625
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
626 626
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
627 627
 					}
628
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
628
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
629 629
 					{
630 630
 						if ($pagenb == 1)
631 631
 						{
@@ -635,10 +635,10 @@  discard block
 block discarded – undo
635 635
 						{
636 636
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
637 637
 						}
638
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
638
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
639 639
 						// New page
640 640
 						$pdf->AddPage();
641
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
641
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
642 642
 						$pagenb++;
643 643
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
644 644
 					}
@@ -648,56 +648,56 @@  discard block
 block discarded – undo
648 648
 				if ($pagenb == 1)
649 649
 				{
650 650
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
651
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
651
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
652 652
 				}
653 653
 				else
654 654
 				{
655 655
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
656
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
656
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
657 657
 				}
658 658
 
659 659
 				// Affiche zone infos
660
-				$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
660
+				$posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
661 661
 
662 662
 				// Affiche zone totaux
663
-				$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
663
+				$posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
664 664
 
665 665
 				// Affiche zone versements
666 666
 				if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included)
667 667
 				{
668
-					$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
668
+					$posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs);
669 669
 				}
670 670
 
671 671
                 // Pied de page
672 672
 				$this->_pagefoot($pdf, $object, $outputlangs);
673
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
673
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
674 674
 
675 675
 				$pdf->Close();
676 676
 
677
-				$pdf->Output($file,'F');
677
+				$pdf->Output($file, 'F');
678 678
 
679 679
 				// Add pdfgeneration hook
680 680
 				$hookmanager->initHooks(array('pdfgeneration'));
681
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
681
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
682 682
 				global $action;
683
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
683
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
684 684
 
685
-				if (! empty($conf->global->MAIN_UMASK))
685
+				if (!empty($conf->global->MAIN_UMASK))
686 686
 				@chmod($file, octdec($conf->global->MAIN_UMASK));
687 687
 
688 688
 				$this->result = array('fullpath'=>$file);
689 689
 
690
-				return 1;   // Pas d'erreur
690
+				return 1; // Pas d'erreur
691 691
 			}
692 692
 			else
693 693
 			{
694
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
694
+				$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
695 695
 				return 0;
696 696
 			}
697 697
 		}
698 698
 		else
699 699
 		{
700
-			$this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR");
700
+			$this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR");
701 701
 			return 0;
702 702
 		}
703 703
 	}
@@ -738,46 +738,46 @@  discard block
 block discarded – undo
738 738
         // If France, show VAT mention if not applicable
739 739
 		if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
740 740
 		{
741
-			$pdf->SetFont('','B', $default_font_size - 2);
741
+			$pdf->SetFont('', 'B', $default_font_size - 2);
742 742
 			$pdf->SetXY($this->marge_gauche, $posy);
743 743
 			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
744 744
 
745
-			$posy=$pdf->GetY()+4;
745
+			$posy = $pdf->GetY() + 4;
746 746
 		}
747 747
 
748
-		$posxval=52;
748
+		$posxval = 52;
749 749
 
750 750
 	    // Show payments conditions
751 751
 	    if (!empty($object->cond_reglement_code) || $object->cond_reglement)
752 752
 	    {
753
-	        $pdf->SetFont('','B', $default_font_size - 2);
753
+	        $pdf->SetFont('', 'B', $default_font_size - 2);
754 754
 	        $pdf->SetXY($this->marge_gauche, $posy);
755 755
 	        $titre = $outputlangs->transnoentities("PaymentConditions").':';
756 756
 	        $pdf->MultiCell(80, 4, $titre, 0, 'L');
757 757
 
758
-			$pdf->SetFont('','', $default_font_size - 2);
758
+			$pdf->SetFont('', '', $default_font_size - 2);
759 759
 			$pdf->SetXY($posxval, $posy);
760
-			$lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement);
761
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
762
-			$pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
760
+			$lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement);
761
+			$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
762
+			$pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
763 763
 
764
-	        $posy=$pdf->GetY()+3;
764
+	        $posy = $pdf->GetY() + 3;
765 765
 	    }
766 766
 
767 767
       	// Show payment mode
768 768
         if (!empty($object->mode_reglement_code))
769 769
         {
770
-        	$pdf->SetFont('','B', $default_font_size - 2);
770
+        	$pdf->SetFont('', 'B', $default_font_size - 2);
771 771
         	$pdf->SetXY($this->marge_gauche, $posy);
772 772
         	$titre = $outputlangs->transnoentities("PaymentMode").':';
773 773
         	$pdf->MultiCell(80, 5, $titre, 0, 'L');
774 774
 
775
-        	$pdf->SetFont('','', $default_font_size - 2);
775
+        	$pdf->SetFont('', '', $default_font_size - 2);
776 776
         	$pdf->SetXY($posxval, $posy);
777
-        	$lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
778
-        	$pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
777
+        	$lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
778
+        	$pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
779 779
 
780
-        	$posy=$pdf->GetY()+2;
780
+        	$posy = $pdf->GetY() + 2;
781 781
         }
782 782
 
783 783
 
@@ -798,39 +798,39 @@  discard block
 block discarded – undo
798 798
 	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
799 799
 	{
800 800
         // phpcs:enable
801
-		global $conf,$mysoc;
801
+		global $conf, $mysoc;
802 802
 
803 803
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
804 804
 
805 805
         $tab2_top = $posy;
806 806
 		$tab2_hl = 4;
807
-		$pdf->SetFont('','', $default_font_size - 1);
807
+		$pdf->SetFont('', '', $default_font_size - 1);
808 808
 
809 809
 		// Tableau total
810 810
 		$col1x = 120; $col2x = 170;
811 811
 		if ($this->page_largeur < 210) // To work with US executive format
812 812
 		{
813
-			$col2x-=20;
813
+			$col2x -= 20;
814 814
 		}
815 815
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
816 816
 
817
-		$useborder=0;
817
+		$useborder = 0;
818 818
 		$index = 0;
819 819
 
820 820
 		// Total HT
821
-		$pdf->SetFillColor(255,255,255);
821
+		$pdf->SetFillColor(255, 255, 255);
822 822
 		$pdf->SetXY($col1x, $tab2_top + 0);
823
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
823
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
824 824
 
825 825
 		$total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
826 826
 		$pdf->SetXY($col2x, $tab2_top + 0);
827
-		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0)), 0, 'R', 1);
827
+		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, 'R', 1);
828 828
 
829 829
 		// Show VAT by rates and total
830
-		$pdf->SetFillColor(248,248,248);
830
+		$pdf->SetFillColor(248, 248, 248);
831 831
 
832
-		$this->atleastoneratenotnull=0;
833
-		foreach( $this->tva as $tvakey => $tvaval )
832
+		$this->atleastoneratenotnull = 0;
833
+		foreach ($this->tva as $tvakey => $tvaval)
834 834
 		{
835 835
 			if ($tvakey > 0)    // On affiche pas taux 0
836 836
 			{
@@ -839,47 +839,47 @@  discard block
 block discarded – undo
839 839
 				$index++;
840 840
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
841 841
 
842
-				$tvacompl='';
842
+				$tvacompl = '';
843 843
 
844
-				if (preg_match('/\*/',$tvakey))
844
+				if (preg_match('/\*/', $tvakey))
845 845
 				{
846
-					$tvakey=str_replace('*','',$tvakey);
846
+					$tvakey = str_replace('*', '', $tvakey);
847 847
 					$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
848 848
 				}
849 849
 
850
-				$totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
851
-				$totalvat.=vatrate($tvakey,1).$tvacompl;
852
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
850
+				$totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
851
+				$totalvat .= vatrate($tvakey, 1).$tvacompl;
852
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
853 853
 
854 854
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
855 855
 				$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
856 856
 			}
857 857
 		}
858
-		if (! $this->atleastoneratenotnull) // If no vat at all
858
+		if (!$this->atleastoneratenotnull) // If no vat at all
859 859
 		{
860 860
 			$index++;
861 861
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
862
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1);
862
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1);
863 863
 
864 864
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
865 865
 			$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);
866 866
 
867 867
 			// Total LocalTax1
868
-			if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0)
868
+			if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on' && $object->total_localtax1 > 0)
869 869
 			{
870 870
 				$index++;
871 871
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
872
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code), 0, 'L', 1);
872
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code), 0, 'L', 1);
873 873
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
874 874
 				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1);
875 875
 			}
876 876
 
877 877
 			// Total LocalTax2
878
-			if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0)
878
+			if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on' && $object->total_localtax2 > 0)
879 879
 			{
880 880
 				$index++;
881 881
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
882
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code), 0, 'L', 1);
882
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code), 0, 'L', 1);
883 883
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
884 884
 				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1);
885 885
 			}
@@ -889,11 +889,11 @@  discard block
 block discarded – undo
889 889
 			//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
890 890
 			//{
891 891
     			//Local tax 1
892
-			foreach( $this->localtax1 as $localtax_type => $localtax_rate )
892
+			foreach ($this->localtax1 as $localtax_type => $localtax_rate)
893 893
 			{
894
-				if (in_array((string) $localtax_type, array('2','4','6'))) continue;
894
+				if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
895 895
 
896
-				foreach( $localtax_rate as $tvakey => $tvaval )
896
+				foreach ($localtax_rate as $tvakey => $tvaval)
897 897
 				{
898 898
 					if ($tvakey != 0)    // On affiche pas taux 0
899 899
 					{
@@ -902,15 +902,15 @@  discard block
 block discarded – undo
902 902
 						$index++;
903 903
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
904 904
 
905
-						$tvacompl='';
906
-						if (preg_match('/\*/',$tvakey))
905
+						$tvacompl = '';
906
+						if (preg_match('/\*/', $tvakey))
907 907
 						{
908
-							$tvakey=str_replace('*','',$tvakey);
908
+							$tvakey = str_replace('*', '', $tvakey);
909 909
 							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
910 910
 						}
911
-						$totalvat =$outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
912
-						$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
913
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
911
+						$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
912
+						$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
913
+						$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
914 914
 
915 915
 						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
916 916
 						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -921,11 +921,11 @@  discard block
 block discarded – undo
921 921
 			//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
922 922
 			//{
923 923
     			//Local tax 2
924
-			foreach( $this->localtax2 as $localtax_type => $localtax_rate )
924
+			foreach ($this->localtax2 as $localtax_type => $localtax_rate)
925 925
 			{
926
-				if (in_array((string) $localtax_type, array('2','4','6'))) continue;
926
+				if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
927 927
 
928
-				foreach( $localtax_rate as $tvakey => $tvaval )
928
+				foreach ($localtax_rate as $tvakey => $tvaval)
929 929
 				{
930 930
 					if ($tvakey != 0)    // On affiche pas taux 0
931 931
 					{
@@ -934,15 +934,15 @@  discard block
 block discarded – undo
934 934
 						$index++;
935 935
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
936 936
 
937
-						$tvacompl='';
938
-						if (preg_match('/\*/',$tvakey))
937
+						$tvacompl = '';
938
+						if (preg_match('/\*/', $tvakey))
939 939
 						{
940
-							$tvakey=str_replace('*','',$tvakey);
940
+							$tvakey = str_replace('*', '', $tvakey);
941 941
 							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
942 942
 						}
943
-						$totalvat =$outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
944
-						$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
945
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
943
+						$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
944
+						$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
945
+						$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
946 946
 
947 947
 						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
948 948
 						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
@@ -954,23 +954,23 @@  discard block
 block discarded – undo
954 954
 		// Total TTC
955 955
 		$index++;
956 956
 		$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
957
-		$pdf->SetTextColor(0,0,60);
958
-		$pdf->SetFillColor(224,224,224);
959
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
957
+		$pdf->SetTextColor(0, 0, 60);
958
+		$pdf->SetFillColor(224, 224, 224);
959
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
960 960
 
961 961
 		$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
962 962
 		$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
963 963
 		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1);
964
-		$pdf->SetFont('','', $default_font_size - 1);
965
-		$pdf->SetTextColor(0,0,0);
964
+		$pdf->SetFont('', '', $default_font_size - 1);
965
+		$pdf->SetTextColor(0, 0, 0);
966 966
 
967
-        $creditnoteamount=0;
968
-        $depositsamount=0;
967
+        $creditnoteamount = 0;
968
+        $depositsamount = 0;
969 969
 		//$creditnoteamount=$object->getSumCreditNotesUsed();
970 970
 		//$depositsamount=$object->getSumDepositsUsed();
971 971
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
972 972
 		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
973
-		if (! empty($object->paye)) $resteapayer=0;
973
+		if (!empty($object->paye)) $resteapayer = 0;
974 974
 
975 975
 		if ($deja_regle > 0)
976 976
 		{
@@ -978,21 +978,21 @@  discard block
 block discarded – undo
978 978
 		    $index++;
979 979
 
980 980
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
981
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
981
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
982 982
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
983 983
 			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);
984 984
 
985 985
 			$index++;
986
-			$pdf->SetTextColor(0,0,60);
987
-			$pdf->SetFillColor(224,224,224);
986
+			$pdf->SetTextColor(0, 0, 60);
987
+			$pdf->SetFillColor(224, 224, 224);
988 988
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
989
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
989
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
990 990
 
991 991
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
992 992
 			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
993 993
 
994
-			$pdf->SetFont('','', $default_font_size - 1);
995
-			$pdf->SetTextColor(0,0,0);
994
+			$pdf->SetFont('', '', $default_font_size - 1);
995
+			$pdf->SetTextColor(0, 0, 0);
996 996
 		}
997 997
 
998 998
 		$index++;
@@ -1012,43 +1012,43 @@  discard block
 block discarded – undo
1012 1012
 	 *   @param		string		$currency		Currency code
1013 1013
 	 *   @return	void
1014 1014
 	 */
1015
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1015
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1016 1016
 	{
1017 1017
 		global $conf;
1018 1018
 
1019 1019
 		// Force to disable hidetop and hidebottom
1020
-		$hidebottom=0;
1021
-		if ($hidetop) $hidetop=-1;
1020
+		$hidebottom = 0;
1021
+		if ($hidetop) $hidetop = -1;
1022 1022
 
1023 1023
 		$currency = !empty($currency) ? $currency : $conf->currency;
1024 1024
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1025 1025
 
1026 1026
         // Amount in (at tab_top - 1)
1027
-		$pdf->SetTextColor(0,0,0);
1028
-		$pdf->SetFont('','', $default_font_size - 2);
1027
+		$pdf->SetTextColor(0, 0, 0);
1028
+		$pdf->SetFont('', '', $default_font_size - 2);
1029 1029
 
1030 1030
 		if (empty($hidetop))
1031 1031
 		{
1032
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1033
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1032
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1033
+			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1034 1034
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1035 1035
 
1036 1036
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1037
-			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1037
+			if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1038 1038
 		}
1039 1039
 
1040
-		$pdf->SetDrawColor(128,128,128);
1041
-		$pdf->SetFont('','', $default_font_size - 1);
1040
+		$pdf->SetDrawColor(128, 128, 128);
1041
+		$pdf->SetFont('', '', $default_font_size - 1);
1042 1042
 
1043 1043
 		// Output Rect
1044
-		$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect prend une longueur en 3eme param et 4eme param
1044
+		$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
1045 1045
 
1046 1046
 		if (empty($hidetop))
1047 1047
 		{
1048
-			$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);	// line prend une position y en 2eme param et 4eme param
1048
+			$pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line prend une position y en 2eme param et 4eme param
1049 1049
 
1050
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
1051
-			$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1050
+			$pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1051
+			$pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
1052 1052
 		}
1053 1053
 
1054 1054
         if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
@@ -1056,33 +1056,33 @@  discard block
 block discarded – undo
1056 1056
     		$pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height);
1057 1057
 			if (empty($hidetop))
1058 1058
 			{
1059
-    			$pdf->SetXY($this->posxtva-3, $tab_top+1);
1060
-    			$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1059
+    			$pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1060
+    			$pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
1061 1061
 			}
1062 1062
         }
1063 1063
 
1064 1064
 		$pdf->line($this->posxup, $tab_top, $this->posxup, $tab_top + $tab_height);
1065 1065
 		if (empty($hidetop))
1066 1066
 		{
1067
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
1068
-			$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1067
+			$pdf->SetXY($this->posxup - 1, $tab_top + 1);
1068
+			$pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
1069 1069
 		}
1070 1070
 
1071
-		$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1071
+		$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1072 1072
 		if (empty($hidetop))
1073 1073
 		{
1074
-			$pdf->SetXY($this->posxqty-1, $tab_top+1);
1075
-			if($conf->global->PRODUCT_USE_UNITS)
1074
+			$pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1075
+			if ($conf->global->PRODUCT_USE_UNITS)
1076 1076
 			{
1077
-				$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1077
+				$pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1078 1078
 			}
1079 1079
 			else
1080 1080
 			{
1081
-				$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1081
+				$pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1082 1082
 			}
1083 1083
 		}
1084 1084
 
1085
-		if($conf->global->PRODUCT_USE_UNITS) {
1085
+		if ($conf->global->PRODUCT_USE_UNITS) {
1086 1086
 			$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1087 1087
 			if (empty($hidetop)) {
1088 1088
 				$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
@@ -1091,13 +1091,13 @@  discard block
 block discarded – undo
1091 1091
 			}
1092 1092
 		}
1093 1093
 
1094
-		$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1094
+		$pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1095 1095
 		if (empty($hidetop))
1096 1096
 		{
1097 1097
 			if ($this->atleastonediscount)
1098 1098
 			{
1099
-				$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1100
-				$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1099
+				$pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1100
+				$pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
1101 1101
 			}
1102 1102
 		}
1103 1103
 
@@ -1107,8 +1107,8 @@  discard block
 block discarded – undo
1107 1107
 		}
1108 1108
 		if (empty($hidetop))
1109 1109
 		{
1110
-			$pdf->SetXY($this->postotalht-1, $tab_top+1);
1111
-			$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHTShort"),'','C');
1110
+			$pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1111
+			$pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHTShort"), '', 'C');
1112 1112
 		}
1113 1113
 	}
1114 1114
 
@@ -1140,119 +1140,119 @@  discard block
 block discarded – undo
1140 1140
 		}*/
1141 1141
 		//Print content
1142 1142
 
1143
-		$pdf->SetTextColor(0,0,60);
1144
-		$pdf->SetFont('','B',$default_font_size + 3);
1143
+		$pdf->SetTextColor(0, 0, 60);
1144
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1145 1145
 
1146
-		$posx=$this->page_largeur-$this->marge_droite-100;
1147
-		$posy=$this->marge_haute;
1146
+		$posx = $this->page_largeur - $this->marge_droite - 100;
1147
+		$posy = $this->marge_haute;
1148 1148
 
1149
-		$pdf->SetXY($this->marge_gauche,$posy);
1149
+		$pdf->SetXY($this->marge_gauche, $posy);
1150 1150
 
1151 1151
 		// Logo
1152
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1152
+		$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1153 1153
 		if ($this->emetteur->logo)
1154 1154
 		{
1155 1155
 			if (is_readable($logo))
1156 1156
 			{
1157
-			    $height=pdf_getHeightForLogo($logo);
1158
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1157
+			    $height = pdf_getHeightForLogo($logo);
1158
+			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1159 1159
 			}
1160 1160
 			else
1161 1161
 			{
1162
-				$pdf->SetTextColor(200,0,0);
1163
-				$pdf->SetFont('','B', $default_font_size - 2);
1164
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1162
+				$pdf->SetTextColor(200, 0, 0);
1163
+				$pdf->SetFont('', 'B', $default_font_size - 2);
1164
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1165 1165
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
1166 1166
 			}
1167 1167
 		}
1168 1168
 		else
1169 1169
 		{
1170
-			$text=$this->emetteur->name;
1170
+			$text = $this->emetteur->name;
1171 1171
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1172 1172
 		}
1173 1173
 
1174 1174
 		$pdf->SetFont('', 'B', $default_font_size + 3);
1175
-		$pdf->SetXY($posx,$posy);
1176
-		$pdf->SetTextColor(0,0,60);
1177
-		$title=$outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref);
1175
+		$pdf->SetXY($posx, $posy);
1176
+		$pdf->SetTextColor(0, 0, 60);
1177
+		$title = $outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref);
1178 1178
 		$pdf->MultiCell(100, 3, $title, '', 'R');
1179
-		$posy+=1;
1179
+		$posy += 1;
1180 1180
 
1181 1181
 		if ($object->ref_supplier)
1182 1182
 		{
1183
-			$posy+=4;
1184
-			$pdf->SetFont('','B', $default_font_size);
1185
-			$pdf->SetXY($posx,$posy);
1186
-			$pdf->SetTextColor(0,0,60);
1187
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : " . $outputlangs->convToOutputCharset($object->ref_supplier), '', 'R');
1188
-			$posy+=1;
1183
+			$posy += 4;
1184
+			$pdf->SetFont('', 'B', $default_font_size);
1185
+			$pdf->SetXY($posx, $posy);
1186
+			$pdf->SetTextColor(0, 0, 60);
1187
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : ".$outputlangs->convToOutputCharset($object->ref_supplier), '', 'R');
1188
+			$posy += 1;
1189 1189
 		}
1190 1190
 
1191
-		$pdf->SetFont('','', $default_font_size -1);
1191
+		$pdf->SetFont('', '', $default_font_size - 1);
1192 1192
 
1193
-		if (! empty($conf->global->PDF_SHOW_PROJECT))
1193
+		if (!empty($conf->global->PDF_SHOW_PROJECT))
1194 1194
 		{
1195 1195
 			$object->fetch_projet();
1196
-			if (! empty($object->project->ref))
1196
+			if (!empty($object->project->ref))
1197 1197
 			{
1198
-				$posy+=4;
1199
-				$pdf->SetXY($posx,$posy);
1198
+				$posy += 4;
1199
+				$pdf->SetXY($posx, $posy);
1200 1200
 				$langs->load("projects");
1201
-				$pdf->SetTextColor(0,0,60);
1202
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R');
1201
+				$pdf->SetTextColor(0, 0, 60);
1202
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R');
1203 1203
 			}
1204 1204
 		}
1205 1205
 
1206
-		if (! empty($object->date_commande))
1206
+		if (!empty($object->date_commande))
1207 1207
 		{
1208
-			$posy+=5;
1209
-			$pdf->SetXY($posx,$posy);
1210
-			$pdf->SetTextColor(0,0,60);
1211
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date_commande,"day",false,$outputlangs,true), '', 'R');
1208
+			$posy += 5;
1209
+			$pdf->SetXY($posx, $posy);
1210
+			$pdf->SetTextColor(0, 0, 60);
1211
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date_commande, "day", false, $outputlangs, true), '', 'R');
1212 1212
 		}
1213 1213
 		else
1214 1214
 		{
1215
-			$posy+=5;
1216
-			$pdf->SetXY($posx,$posy);
1217
-			$pdf->SetTextColor(255,0,0);
1215
+			$posy += 5;
1216
+			$pdf->SetXY($posx, $posy);
1217
+			$pdf->SetTextColor(255, 0, 0);
1218 1218
 			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderToProcess"), '', 'R');
1219 1219
 		}
1220 1220
 
1221
-		$pdf->SetTextColor(0,0,60);
1222
-		$usehourmin='day';
1223
-		if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin='dayhour';
1224
-		if (! empty($object->date_livraison))
1221
+		$pdf->SetTextColor(0, 0, 60);
1222
+		$usehourmin = 'day';
1223
+		if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin = 'dayhour';
1224
+		if (!empty($object->date_livraison))
1225 1225
 		{
1226
-			$posy+=4;
1227
-			$pdf->SetXY($posx-90,$posy);
1228
-			$pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_livraison,$usehourmin,false,$outputlangs,true), '', 'R');
1226
+			$posy += 4;
1227
+			$pdf->SetXY($posx - 90, $posy);
1228
+			$pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_livraison, $usehourmin, false, $outputlangs, true), '', 'R');
1229 1229
 		}
1230 1230
 
1231 1231
 		if ($object->thirdparty->code_fournisseur)
1232 1232
 		{
1233
-			$posy+=4;
1234
-			$pdf->SetXY($posx,$posy);
1235
-			$pdf->SetTextColor(0,0,60);
1236
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
1233
+			$posy += 4;
1234
+			$pdf->SetXY($posx, $posy);
1235
+			$pdf->SetTextColor(0, 0, 60);
1236
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
1237 1237
 		}
1238 1238
 
1239 1239
 		// Get contact
1240 1240
 		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1241 1241
 		{
1242
-    		$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1242
+    		$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1243 1243
     		if (count($arrayidcontact) > 0)
1244 1244
     		{
1245
-    		    $usertmp=new User($this->db);
1245
+    		    $usertmp = new User($this->db);
1246 1246
     		    $usertmp->fetch($arrayidcontact[0]);
1247
-                $posy+=4;
1248
-                $pdf->SetXY($posx,$posy);
1249
-    		    $pdf->SetTextColor(0,0,60);
1247
+                $posy += 4;
1248
+                $pdf->SetXY($posx, $posy);
1249
+    		    $pdf->SetTextColor(0, 0, 60);
1250 1250
     		    $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
1251 1251
     		}
1252 1252
 		}
1253 1253
 
1254
-		$posy+=1;
1255
-		$pdf->SetTextColor(0,0,60);
1254
+		$posy += 1;
1255
+		$pdf->SetTextColor(0, 0, 60);
1256 1256
 
1257 1257
 		$top_shift = 0;
1258 1258
 		// Show list of linked objects
@@ -1266,53 +1266,53 @@  discard block
 block discarded – undo
1266 1266
 		if ($showaddress)
1267 1267
 		{
1268 1268
 		    // Sender properties
1269
-		    $carac_emetteur='';
1269
+		    $carac_emetteur = '';
1270 1270
 		    // Add internal contact of proposal if defined
1271
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1271
+		    $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1272 1272
 		    if (count($arrayidcontact) > 0)
1273 1273
 		    {
1274 1274
 		        $object->fetch_user($arrayidcontact[0]);
1275
-		        $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1275
+		        $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1276 1276
 		    }
1277 1277
 
1278 1278
 			$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1279 1279
 
1280 1280
 			// Show sender
1281
-			$posy=42+$top_shift;
1282
-			$posx=$this->marge_gauche;
1283
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1284
-			$hautcadre=40;
1281
+			$posy = 42 + $top_shift;
1282
+			$posx = $this->marge_gauche;
1283
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1284
+			$hautcadre = 40;
1285 1285
 
1286 1286
 			// Show sender frame
1287
-			$pdf->SetTextColor(0,0,0);
1288
-			$pdf->SetFont('','', $default_font_size - 2);
1289
-			$pdf->SetXY($posx,$posy-5);
1290
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1291
-			$pdf->SetXY($posx,$posy);
1292
-			$pdf->SetFillColor(230,230,230);
1287
+			$pdf->SetTextColor(0, 0, 0);
1288
+			$pdf->SetFont('', '', $default_font_size - 2);
1289
+			$pdf->SetXY($posx, $posy - 5);
1290
+			$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1291
+			$pdf->SetXY($posx, $posy);
1292
+			$pdf->SetFillColor(230, 230, 230);
1293 1293
 			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1294
-			$pdf->SetTextColor(0,0,60);
1294
+			$pdf->SetTextColor(0, 0, 60);
1295 1295
 
1296 1296
 			// Show sender name
1297
-			$pdf->SetXY($posx+2,$posy+3);
1298
-			$pdf->SetFont('','B', $default_font_size);
1297
+			$pdf->SetXY($posx + 2, $posy + 3);
1298
+			$pdf->SetFont('', 'B', $default_font_size);
1299 1299
 			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1300
-			$posy=$pdf->getY();
1300
+			$posy = $pdf->getY();
1301 1301
 
1302 1302
 			// Show sender information
1303
-			$pdf->SetXY($posx+2,$posy);
1304
-			$pdf->SetFont('','', $default_font_size - 1);
1303
+			$pdf->SetXY($posx + 2, $posy);
1304
+			$pdf->SetFont('', '', $default_font_size - 1);
1305 1305
 			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1306 1306
 
1307 1307
 
1308 1308
 
1309 1309
 			// If BILLING contact defined on order, we use it
1310
-			$usecontact=false;
1311
-			$arrayidcontact=$object->getIdContact('external','BILLING');
1310
+			$usecontact = false;
1311
+			$arrayidcontact = $object->getIdContact('external', 'BILLING');
1312 1312
 			if (count($arrayidcontact) > 0)
1313 1313
 			{
1314
-				$usecontact=true;
1315
-				$result=$object->fetch_contact($arrayidcontact[0]);
1314
+				$usecontact = true;
1315
+				$result = $object->fetch_contact($arrayidcontact[0]);
1316 1316
 			}
1317 1317
 
1318 1318
 			//Recipient name
@@ -1323,34 +1323,34 @@  discard block
 block discarded – undo
1323 1323
 				$thirdparty = $object->thirdparty;
1324 1324
 			}
1325 1325
 
1326
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1326
+			$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1327 1327
 
1328
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object);
1328
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
1329 1329
 
1330 1330
 			// Show recipient
1331
-			$widthrecbox=100;
1332
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1333
-			$posy=42+$top_shift;
1334
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1335
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1331
+			$widthrecbox = 100;
1332
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1333
+			$posy = 42 + $top_shift;
1334
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1335
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1336 1336
 
1337 1337
 			// Show recipient frame
1338
-			$pdf->SetTextColor(0,0,0);
1339
-			$pdf->SetFont('','', $default_font_size - 2);
1340
-			$pdf->SetXY($posx+2,$posy-5);
1341
-			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
1338
+			$pdf->SetTextColor(0, 0, 0);
1339
+			$pdf->SetFont('', '', $default_font_size - 2);
1340
+			$pdf->SetXY($posx + 2, $posy - 5);
1341
+			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1342 1342
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1343 1343
 
1344 1344
 			// Show recipient name
1345
-			$pdf->SetXY($posx+2,$posy+3);
1346
-			$pdf->SetFont('','B', $default_font_size);
1345
+			$pdf->SetXY($posx + 2, $posy + 3);
1346
+			$pdf->SetFont('', 'B', $default_font_size);
1347 1347
 			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1348 1348
 
1349 1349
 			$posy = $pdf->getY();
1350 1350
 
1351 1351
 			// Show recipient information
1352
-			$pdf->SetFont('','', $default_font_size - 1);
1353
-			$pdf->SetXY($posx+2,$posy);
1352
+			$pdf->SetFont('', '', $default_font_size - 1);
1353
+			$pdf->SetXY($posx + 2, $posy);
1354 1354
 			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1355 1355
 		}
1356 1356
 
@@ -1366,10 +1366,10 @@  discard block
 block discarded – undo
1366 1366
 	 *      @param	int			$hidefreetext		1=Hide free text
1367 1367
 	 *      @return	int								Return height of bottom margin including footer text
1368 1368
 	 */
1369
-	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
1369
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1370 1370
 	{
1371 1371
 		global $conf;
1372
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1373
-		return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_ORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1372
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1373
+		return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1374 1374
 	}
1375 1375
 }
Please login to merge, or discard this patch.
Braces   +168 added lines, -85 removed lines patch added patch discarded remove patch
@@ -157,7 +157,10 @@  discard block
 block discarded – undo
157 157
 
158 158
         // Get source company
159 159
 		$this->emetteur=$mysoc;
160
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
160
+		if (empty($this->emetteur->country_code)) {
161
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
162
+		}
163
+		// By default, if was not defined
161 164
 
162 165
 		// Defini position des colonnes
163 166
 		$this->posxdesc=$this->marge_gauche+1;
@@ -176,11 +179,16 @@  discard block
 block discarded – undo
176 179
 			$this->posxqty=145;
177 180
 		}
178 181
 
179
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxup = $this->posxtva; // posxtva is picture position reference
182
+		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
183
+		    $this->posxup = $this->posxtva;
184
+		}
185
+		// posxtva is picture position reference
180 186
 		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
181
-		if ($this->page_largeur < 210) // To work with US executive format
187
+		if ($this->page_largeur < 210) {
188
+		    // To work with US executive format
182 189
 		{
183 190
 			$this->posxpicture-=20;
191
+		}
184 192
 			$this->posxtva-=20;
185 193
 			$this->posxup-=20;
186 194
 			$this->posxqty-=20;
@@ -214,9 +222,13 @@  discard block
 block discarded – undo
214 222
         // phpcs:enable
215 223
 		global $user,$langs,$conf,$hookmanager,$mysoc,$nblignes;
216 224
 
217
-		if (! is_object($outputlangs)) $outputlangs=$langs;
225
+		if (! is_object($outputlangs)) {
226
+		    $outputlangs=$langs;
227
+		}
218 228
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
219
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
229
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
230
+		    $outputlangs->charset_output='ISO-8859-1';
231
+		}
220 232
 
221 233
 		// Load translation files required by the page
222 234
 		$outputlangs->loadLangs(array("main", "orders", "companies", "bills", "dict", "products"));
@@ -229,7 +241,9 @@  discard block
 block discarded – undo
229 241
 		{
230 242
 			for ($i = 0 ; $i < $nblignes ; $i++)
231 243
 			{
232
-				if (empty($object->lines[$i]->fk_product)) continue;
244
+				if (empty($object->lines[$i]->fk_product)) {
245
+				    continue;
246
+				}
233 247
 
234 248
 				$objphoto = new Product($this->db);
235 249
 				$objphoto->fetch($object->lines[$i]->fk_product);
@@ -238,8 +252,7 @@  discard block
 block discarded – undo
238 252
 				{
239 253
 					$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
240 254
 					$dir = $conf->product->dir_output.'/'.$pdir;
241
-				}
242
-				else
255
+				} else
243 256
 				{
244 257
 					$pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
245 258
 					$dir = $conf->product->dir_output.'/'.$pdir;
@@ -254,10 +267,14 @@  discard block
 block discarded – undo
254 267
 					break;
255 268
 				}
256 269
 
257
-				if ($realpath) $realpatharray[$i]=$realpath;
270
+				if ($realpath) {
271
+				    $realpatharray[$i]=$realpath;
272
+				}
258 273
 			}
259 274
 		}
260
-		if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
275
+		if (count($realpatharray) == 0) {
276
+		    $this->posxpicture=$this->posxtva;
277
+		}
261 278
 
262 279
 		if ($conf->fournisseur->commande->dir_output)
263 280
 		{
@@ -274,14 +291,15 @@  discard block
 block discarded – undo
274 291
 			{
275 292
 				$dir = $conf->fournisseur->commande->dir_output;
276 293
 				$file = $dir . "/SPECIMEN.pdf";
277
-			}
278
-			else
294
+			} else
279 295
 			{
280 296
 				$objectref = dol_sanitizeFileName($object->ref);
281 297
 				$objectrefsupplier = dol_sanitizeFileName($object->ref_supplier);
282 298
 				$dir = $conf->fournisseur->commande->dir_output . '/'. $objectref;
283 299
 				$file = $dir . "/" . $objectref . ".pdf";
284
-				if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf";
300
+				if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) {
301
+				    $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf";
302
+				}
285 303
 			}
286 304
 
287 305
 			if (! file_exists($dir))
@@ -313,7 +331,9 @@  discard block
 block discarded – undo
313 331
                 $heightforinfotot = 50;	// Height reserved to output the info and total part
314 332
 		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
315 333
 	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
316
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
334
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) {
335
+	                $heightforfooter+= 6;
336
+	            }
317 337
                 $pdf->SetAutoPageBreak(1,0);
318 338
 
319 339
                 if (class_exists('TCPDF'))
@@ -338,7 +358,9 @@  discard block
 block discarded – undo
338 358
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
339 359
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
340 360
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
341
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
361
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
362
+				    $pdf->SetCompression(false);
363
+				}
342 364
 
343 365
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
344 366
 
@@ -362,7 +384,9 @@  discard block
 block discarded – undo
362 384
 
363 385
 				// New page
364 386
 				$pdf->AddPage();
365
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
387
+				if (! empty($tplidx)) {
388
+				    $pdf->useTemplate($tplidx);
389
+				}
366 390
 				$pagenb++;
367 391
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
368 392
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -423,7 +447,9 @@  discard block
 block discarded – undo
423 447
 
424 448
 					// Define size of image if we need it
425 449
 					$imglinesize=array();
426
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
450
+					if (! empty($realpatharray[$i])) {
451
+					    $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
452
+					}
427 453
 
428 454
 					$pdf->setTopMargin($tab_top_newpage);
429 455
 					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
@@ -434,11 +460,17 @@  discard block
 block discarded – undo
434 460
 					$posYAfterDescription=0;
435 461
 
436 462
 					// We start with Photo of product line
437
-					if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
463
+					if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) {
464
+					    // If photo too high, we moved completely on new page
438 465
 					{
439 466
 						$pdf->AddPage('','',true);
440
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
441
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
467
+					}
468
+						if (! empty($tplidx)) {
469
+						    $pdf->useTemplate($tplidx);
470
+						}
471
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
472
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
473
+						}
442 474
 						$pdf->setPage($pageposbefore+1);
443 475
 
444 476
 						$curY = $tab_top_newpage;
@@ -460,39 +492,44 @@  discard block
 block discarded – undo
460 492
 					if ($posYAfterImage > 0)
461 493
 					{
462 494
 						$descWidth = $this->posxpicture-$curX;
463
-					}
464
-					else
495
+					} else
465 496
 					{
466 497
 						$descWidth = $this->posxtva-$curX;
467 498
 					}
468 499
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1);
469 500
 
470 501
 					$pageposafter=$pdf->getPage();
471
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
502
+					if ($pageposafter > $pageposbefore) {
503
+					    // There is a pagebreak
472 504
 					{
473 505
 						$pdf->rollbackTransaction(true);
506
+					}
474 507
 						$pageposafter=$pageposbefore;
475 508
 						//print $pageposafter.'-'.$pageposbefore;exit;
476 509
 						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
477 510
 						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1);
478 511
 						$posyafter=$pdf->GetY();
479
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
512
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
513
+						    // There is no space left for total+free text
480 514
 						{
481 515
 							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
482 516
 							{
483 517
 								$pdf->AddPage('','',true);
484
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
485
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
518
+						}
519
+								if (! empty($tplidx)) {
520
+								    $pdf->useTemplate($tplidx);
521
+								}
522
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
523
+								    $this->_pagehead($pdf, $object, 0, $outputlangs);
524
+								}
486 525
 								$pdf->setPage($pageposafter+1);
487 526
 							}
488
-						}
489
-						else
527
+						} else
490 528
 						{
491 529
 							// We found a page break
492 530
 							$showpricebeforepagebreak=0;
493 531
 						}
494
-					}
495
-					else	// No pagebreak
532
+					} else	// No pagebreak
496 533
 					{
497 534
 						$pdf->commitTransaction();
498 535
 					}
@@ -530,8 +567,7 @@  discard block
 block discarded – undo
530 567
 					if($conf->global->PRODUCT_USE_UNITS)
531 568
 					{
532 569
 						$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
533
-					}
534
-					else
570
+					} else
535 571
 					{
536 572
 						$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
537 573
 					}
@@ -558,8 +594,11 @@  discard block
 block discarded – undo
558 594
 					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
559 595
 
560 596
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
561
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
562
-					else $tvaligne=$object->lines[$i]->total_tva;
597
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) {
598
+					    $tvaligne=$object->lines[$i]->multicurrency_total_tva;
599
+					} else {
600
+					    $tvaligne=$object->lines[$i]->total_tva;
601
+					}
563 602
 
564 603
 					$localtax1ligne=$object->lines[$i]->total_localtax1;
565 604
 					$localtax2ligne=$object->lines[$i]->total_localtax2;
@@ -568,32 +607,48 @@  discard block
 block discarded – undo
568 607
 					$localtax1_type=$object->lines[$i]->localtax1_type;
569 608
 					$localtax2_type=$object->lines[$i]->localtax2_type;
570 609
 
571
-					if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100;
572
-					if (! empty($object->remise_percent)) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
573
-					if (! empty($object->remise_percent)) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
610
+					if (! empty($object->remise_percent)) {
611
+					    $tvaligne-=($tvaligne*$object->remise_percent)/100;
612
+					}
613
+					if (! empty($object->remise_percent)) {
614
+					    $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
615
+					}
616
+					if (! empty($object->remise_percent)) {
617
+					    $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
618
+					}
574 619
 
575 620
 					$vatrate=(string) $object->lines[$i]->tva_tx;
576 621
 
577 622
 					// Retrieve type from database for backward compatibility with old records
578 623
 					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
579
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
624
+					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) {
625
+					    // and there is local tax
580 626
 					{
581 627
 						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc,$object->thirdparty);
628
+					}
582 629
 						$localtax1_type = $localtaxtmp_array[0];
583 630
 						$localtax2_type = $localtaxtmp_array[2];
584 631
 					}
585 632
 
586 633
 				    // retrieve global local tax
587
-					if ($localtax1_type && $localtax1ligne != 0)
588
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
589
-					if ($localtax2_type && $localtax2ligne != 0)
590
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
634
+					if ($localtax1_type && $localtax1ligne != 0) {
635
+											$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
636
+					}
637
+					if ($localtax2_type && $localtax2ligne != 0) {
638
+											$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
639
+					}
591 640
 
592
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
593
-					if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
641
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
642
+					    $vatrate.='*';
643
+					}
644
+					if (! isset($this->tva[$vatrate])) {
645
+					    $this->tva[$vatrate]=0;
646
+					}
594 647
 					$this->tva[$vatrate] += $tvaligne;
595 648
 
596
-					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
649
+					if ($posYAfterImage > $posYAfterDescription) {
650
+					    $nexY=$posYAfterImage;
651
+					}
597 652
 
598 653
 					// Add line
599 654
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
@@ -614,8 +669,7 @@  discard block
 block discarded – undo
614 669
 						if ($pagenb == 1)
615 670
 						{
616 671
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
617
-						}
618
-						else
672
+						} else
619 673
 						{
620 674
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
621 675
 						}
@@ -623,24 +677,29 @@  discard block
 block discarded – undo
623 677
 						$pagenb++;
624 678
 						$pdf->setPage($pagenb);
625 679
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
626
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
680
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
681
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
682
+						}
627 683
 					}
628 684
 					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
629 685
 					{
630 686
 						if ($pagenb == 1)
631 687
 						{
632 688
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
633
-						}
634
-						else
689
+						} else
635 690
 						{
636 691
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
637 692
 						}
638 693
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
639 694
 						// New page
640 695
 						$pdf->AddPage();
641
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
696
+						if (! empty($tplidx)) {
697
+						    $pdf->useTemplate($tplidx);
698
+						}
642 699
 						$pagenb++;
643
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
700
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
701
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
702
+						}
644 703
 					}
645 704
 				}
646 705
 
@@ -649,8 +708,7 @@  discard block
 block discarded – undo
649 708
 				{
650 709
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
651 710
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
652
-				}
653
-				else
711
+				} else
654 712
 				{
655 713
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
656 714
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
@@ -670,7 +728,9 @@  discard block
 block discarded – undo
670 728
 
671 729
                 // Pied de page
672 730
 				$this->_pagefoot($pdf, $object, $outputlangs);
673
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
731
+				if (method_exists($pdf,'AliasNbPages')) {
732
+				    $pdf->AliasNbPages();
733
+				}
674 734
 
675 735
 				$pdf->Close();
676 736
 
@@ -682,20 +742,19 @@  discard block
 block discarded – undo
682 742
 				global $action;
683 743
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
684 744
 
685
-				if (! empty($conf->global->MAIN_UMASK))
686
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
745
+				if (! empty($conf->global->MAIN_UMASK)) {
746
+								@chmod($file, octdec($conf->global->MAIN_UMASK));
747
+				}
687 748
 
688 749
 				$this->result = array('fullpath'=>$file);
689 750
 
690 751
 				return 1;   // Pas d'erreur
691
-			}
692
-			else
752
+			} else
693 753
 			{
694 754
 				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
695 755
 				return 0;
696 756
 			}
697
-		}
698
-		else
757
+		} else
699 758
 		{
700 759
 			$this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR");
701 760
 			return 0;
@@ -808,10 +867,12 @@  discard block
 block discarded – undo
808 867
 
809 868
 		// Tableau total
810 869
 		$col1x = 120; $col2x = 170;
811
-		if ($this->page_largeur < 210) // To work with US executive format
870
+		if ($this->page_largeur < 210) {
871
+		    // To work with US executive format
812 872
 		{
813 873
 			$col2x-=20;
814 874
 		}
875
+		}
815 876
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
816 877
 
817 878
 		$useborder=0;
@@ -832,9 +893,11 @@  discard block
 block discarded – undo
832 893
 		$this->atleastoneratenotnull=0;
833 894
 		foreach( $this->tva as $tvakey => $tvaval )
834 895
 		{
835
-			if ($tvakey > 0)    // On affiche pas taux 0
896
+			if ($tvakey > 0) {
897
+			    // On affiche pas taux 0
836 898
 			{
837 899
 				$this->atleastoneratenotnull++;
900
+			}
838 901
 
839 902
 				$index++;
840 903
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -855,9 +918,11 @@  discard block
 block discarded – undo
855 918
 				$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
856 919
 			}
857 920
 		}
858
-		if (! $this->atleastoneratenotnull) // If no vat at all
921
+		if (! $this->atleastoneratenotnull) {
922
+		    // If no vat at all
859 923
 		{
860 924
 			$index++;
925
+		}
861 926
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
862 927
 			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1);
863 928
 
@@ -883,23 +948,26 @@  discard block
 block discarded – undo
883 948
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
884 949
 				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1);
885 950
 			}
886
-		}
887
-		else
951
+		} else
888 952
 		{
889 953
 			//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
890 954
 			//{
891 955
     			//Local tax 1
892 956
 			foreach( $this->localtax1 as $localtax_type => $localtax_rate )
893 957
 			{
894
-				if (in_array((string) $localtax_type, array('2','4','6'))) continue;
958
+				if (in_array((string) $localtax_type, array('2','4','6'))) {
959
+				    continue;
960
+				}
895 961
 
896 962
 				foreach( $localtax_rate as $tvakey => $tvaval )
897 963
 				{
898
-					if ($tvakey != 0)    // On affiche pas taux 0
964
+					if ($tvakey != 0) {
965
+					    // On affiche pas taux 0
899 966
 					{
900 967
 						//$this->atleastoneratenotnull++;
901 968
 
902 969
 						$index++;
970
+					}
903 971
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
904 972
 
905 973
 						$tvacompl='';
@@ -923,15 +991,19 @@  discard block
 block discarded – undo
923 991
     			//Local tax 2
924 992
 			foreach( $this->localtax2 as $localtax_type => $localtax_rate )
925 993
 			{
926
-				if (in_array((string) $localtax_type, array('2','4','6'))) continue;
994
+				if (in_array((string) $localtax_type, array('2','4','6'))) {
995
+				    continue;
996
+				}
927 997
 
928 998
 				foreach( $localtax_rate as $tvakey => $tvaval )
929 999
 				{
930
-					if ($tvakey != 0)    // On affiche pas taux 0
1000
+					if ($tvakey != 0) {
1001
+					    // On affiche pas taux 0
931 1002
 					{
932 1003
 						//$this->atleastoneratenotnull++;
933 1004
 
934 1005
 						$index++;
1006
+					}
935 1007
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
936 1008
 
937 1009
 						$tvacompl='';
@@ -970,7 +1042,9 @@  discard block
 block discarded – undo
970 1042
 		//$depositsamount=$object->getSumDepositsUsed();
971 1043
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
972 1044
 		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
973
-		if (! empty($object->paye)) $resteapayer=0;
1045
+		if (! empty($object->paye)) {
1046
+		    $resteapayer=0;
1047
+		}
974 1048
 
975 1049
 		if ($deja_regle > 0)
976 1050
 		{
@@ -1018,7 +1092,9 @@  discard block
 block discarded – undo
1018 1092
 
1019 1093
 		// Force to disable hidetop and hidebottom
1020 1094
 		$hidebottom=0;
1021
-		if ($hidetop) $hidetop=-1;
1095
+		if ($hidetop) {
1096
+		    $hidetop=-1;
1097
+		}
1022 1098
 
1023 1099
 		$currency = !empty($currency) ? $currency : $conf->currency;
1024 1100
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1034,7 +1110,9 @@  discard block
 block discarded – undo
1034 1110
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1035 1111
 
1036 1112
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1037
-			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1113
+			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1114
+			    $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1115
+			}
1038 1116
 		}
1039 1117
 
1040 1118
 		$pdf->SetDrawColor(128,128,128);
@@ -1075,8 +1153,7 @@  discard block
 block discarded – undo
1075 1153
 			if($conf->global->PRODUCT_USE_UNITS)
1076 1154
 			{
1077 1155
 				$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1078
-			}
1079
-			else
1156
+			} else
1080 1157
 			{
1081 1158
 				$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1082 1159
 			}
@@ -1156,16 +1233,14 @@  discard block
 block discarded – undo
1156 1233
 			{
1157 1234
 			    $height=pdf_getHeightForLogo($logo);
1158 1235
 			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1159
-			}
1160
-			else
1236
+			} else
1161 1237
 			{
1162 1238
 				$pdf->SetTextColor(200,0,0);
1163 1239
 				$pdf->SetFont('','B', $default_font_size - 2);
1164 1240
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1165 1241
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
1166 1242
 			}
1167
-		}
1168
-		else
1243
+		} else
1169 1244
 		{
1170 1245
 			$text=$this->emetteur->name;
1171 1246
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1209,8 +1284,7 @@  discard block
 block discarded – undo
1209 1284
 			$pdf->SetXY($posx,$posy);
1210 1285
 			$pdf->SetTextColor(0,0,60);
1211 1286
 			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date_commande,"day",false,$outputlangs,true), '', 'R');
1212
-		}
1213
-		else
1287
+		} else
1214 1288
 		{
1215 1289
 			$posy+=5;
1216 1290
 			$pdf->SetXY($posx,$posy);
@@ -1220,7 +1294,9 @@  discard block
 block discarded – undo
1220 1294
 
1221 1295
 		$pdf->SetTextColor(0,0,60);
1222 1296
 		$usehourmin='day';
1223
-		if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin='dayhour';
1297
+		if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) {
1298
+		    $usehourmin='dayhour';
1299
+		}
1224 1300
 		if (! empty($object->date_livraison))
1225 1301
 		{
1226 1302
 			$posy+=4;
@@ -1280,7 +1356,9 @@  discard block
 block discarded – undo
1280 1356
 			// Show sender
1281 1357
 			$posy=42+$top_shift;
1282 1358
 			$posx=$this->marge_gauche;
1283
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1359
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1360
+			    $posx=$this->page_largeur-$this->marge_droite-80;
1361
+			}
1284 1362
 			$hautcadre=40;
1285 1363
 
1286 1364
 			// Show sender frame
@@ -1329,10 +1407,15 @@  discard block
 block discarded – undo
1329 1407
 
1330 1408
 			// Show recipient
1331 1409
 			$widthrecbox=100;
1332
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1410
+			if ($this->page_largeur < 210) {
1411
+			    $widthrecbox=84;
1412
+			}
1413
+			// To work with US executive format
1333 1414
 			$posy=42+$top_shift;
1334 1415
 			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1335
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1416
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1417
+			    $posx=$this->marge_gauche;
1418
+			}
1336 1419
 
1337 1420
 			// Show recipient frame
1338 1421
 			$pdf->SetTextColor(0,0,0);
Please login to merge, or discard this patch.