Passed
Push — master ( 8f7a8e...7e4a07 )
by Alxarafe
20:11
created
dolibarr/htdocs/core/js/lib_gravatar.js.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,14 +24,14 @@
 block discarded – undo
24 24
 
25 25
 //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');	// Not disabled cause need to load personalized language
26 26
 //if (! defined('NOREQUIREDB'))   define('NOREQUIREDB','1');
27
-if (! defined('NOREQUIRESOC'))    define('NOREQUIRESOC','1');
27
+if (!defined('NOREQUIRESOC'))    define('NOREQUIRESOC', '1');
28 28
 //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');	// Not disabled cause need to do translations
29
-if (! defined('NOCSRFCHECK'))     define('NOCSRFCHECK',1);
30
-if (! defined('NOTOKENRENEWAL'))  define('NOTOKENRENEWAL',1);
31
-if (! defined('NOLOGIN'))         define('NOLOGIN',1);
32
-if (! defined('NOREQUIREMENU'))   define('NOREQUIREMENU',1);
33
-if (! defined('NOREQUIREHTML'))   define('NOREQUIREHTML',1);
34
-if (! defined('NOREQUIREAJAX'))   define('NOREQUIREAJAX','1');
29
+if (!defined('NOCSRFCHECK'))     define('NOCSRFCHECK', 1);
30
+if (!defined('NOTOKENRENEWAL'))  define('NOTOKENRENEWAL', 1);
31
+if (!defined('NOLOGIN'))         define('NOLOGIN', 1);
32
+if (!defined('NOREQUIREMENU'))   define('NOREQUIREMENU', 1);
33
+if (!defined('NOREQUIREHTML'))   define('NOREQUIREHTML', 1);
34
+if (!defined('NOREQUIREAJAX'))   define('NOREQUIREAJAX', '1');
35 35
 
36 36
 session_cache_limiter('public');
37 37
 
Please login to merge, or discard this patch.
Braces   +26 added lines, -9 removed lines patch added patch discarded remove patch
@@ -24,14 +24,28 @@  discard block
 block discarded – undo
24 24
 
25 25
 //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');	// Not disabled cause need to load personalized language
26 26
 //if (! defined('NOREQUIREDB'))   define('NOREQUIREDB','1');
27
-if (! defined('NOREQUIRESOC'))    define('NOREQUIRESOC','1');
27
+if (! defined('NOREQUIRESOC')) {
28
+    define('NOREQUIRESOC','1');
29
+}
28 30
 //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');	// Not disabled cause need to do translations
29
-if (! defined('NOCSRFCHECK'))     define('NOCSRFCHECK',1);
30
-if (! defined('NOTOKENRENEWAL'))  define('NOTOKENRENEWAL',1);
31
-if (! defined('NOLOGIN'))         define('NOLOGIN',1);
32
-if (! defined('NOREQUIREMENU'))   define('NOREQUIREMENU',1);
33
-if (! defined('NOREQUIREHTML'))   define('NOREQUIREHTML',1);
34
-if (! defined('NOREQUIREAJAX'))   define('NOREQUIREAJAX','1');
31
+if (! defined('NOCSRFCHECK')) {
32
+    define('NOCSRFCHECK',1);
33
+}
34
+if (! defined('NOTOKENRENEWAL')) {
35
+    define('NOTOKENRENEWAL',1);
36
+}
37
+if (! defined('NOLOGIN')) {
38
+    define('NOLOGIN',1);
39
+}
40
+if (! defined('NOREQUIREMENU')) {
41
+    define('NOREQUIREMENU',1);
42
+}
43
+if (! defined('NOREQUIREHTML')) {
44
+    define('NOREQUIREHTML',1);
45
+}
46
+if (! defined('NOREQUIREAJAX')) {
47
+    define('NOREQUIREAJAX','1');
48
+}
35 49
 
36 50
 session_cache_limiter('public');
37 51
 
@@ -40,8 +54,11 @@  discard block
 block discarded – undo
40 54
 // Define javascript type
41 55
 top_httphead('text/javascript; charset=UTF-8');
42 56
 // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
43
-if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate');
44
-else header('Cache-Control: no-cache');
57
+if (empty($dolibarr_nocache)) {
58
+    header('Cache-Control: max-age=10800, public, must-revalidate');
59
+} else {
60
+    header('Cache-Control: no-cache');
61
+}
45 62
 
46 63
 ?>
47 64
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/js/timepicker.js.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,13 +21,13 @@  discard block
 block discarded – undo
21 21
  * \brief      File that include javascript functions for timepicker
22 22
  */
23 23
 
24
-if (! defined('NOREQUIRESOC'))    define('NOREQUIRESOC','1');
25
-if (! defined('NOCSRFCHECK'))     define('NOCSRFCHECK',1);
26
-if (! defined('NOTOKENRENEWAL'))  define('NOTOKENRENEWAL',1);
27
-if (! defined('NOLOGIN'))         define('NOLOGIN',1);
28
-if (! defined('NOREQUIREMENU'))   define('NOREQUIREMENU',1);
29
-if (! defined('NOREQUIREHTML'))   define('NOREQUIREHTML',1);
30
-if (! defined('NOREQUIREAJAX'))   define('NOREQUIREAJAX','1');
24
+if (!defined('NOREQUIRESOC'))    define('NOREQUIRESOC', '1');
25
+if (!defined('NOCSRFCHECK'))     define('NOCSRFCHECK', 1);
26
+if (!defined('NOTOKENRENEWAL'))  define('NOTOKENRENEWAL', 1);
27
+if (!defined('NOLOGIN'))         define('NOLOGIN', 1);
28
+if (!defined('NOREQUIREMENU'))   define('NOREQUIREMENU', 1);
29
+if (!defined('NOREQUIREHTML'))   define('NOREQUIREHTML', 1);
30
+if (!defined('NOREQUIREAJAX'))   define('NOREQUIREAJAX', '1');
31 31
 
32 32
 session_cache_limiter('public');
33 33
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		timeFormat: 'HH:mm',
56 56
 		amNames: ['AM', 'A'],
57 57
 		pmNames: ['PM', 'P'],
58
-		isRTL: <?php echo ($langs->trans("DIRECTION")=='rtl'?'true':'false'); ?>
58
+		isRTL: <?php echo ($langs->trans("DIRECTION") == 'rtl' ? 'true' : 'false'); ?>
59 59
 	};
60 60
 	$.timepicker.setDefaults($.timepicker.regional['<?php echo $langs->defaultlang ?>']);
61 61
 });
Please login to merge, or discard this patch.
Braces   +29 added lines, -10 removed lines patch added patch discarded remove patch
@@ -21,13 +21,27 @@  discard block
 block discarded – undo
21 21
  * \brief      File that include javascript functions for timepicker
22 22
  */
23 23
 
24
-if (! defined('NOREQUIRESOC'))    define('NOREQUIRESOC','1');
25
-if (! defined('NOCSRFCHECK'))     define('NOCSRFCHECK',1);
26
-if (! defined('NOTOKENRENEWAL'))  define('NOTOKENRENEWAL',1);
27
-if (! defined('NOLOGIN'))         define('NOLOGIN',1);
28
-if (! defined('NOREQUIREMENU'))   define('NOREQUIREMENU',1);
29
-if (! defined('NOREQUIREHTML'))   define('NOREQUIREHTML',1);
30
-if (! defined('NOREQUIREAJAX'))   define('NOREQUIREAJAX','1');
24
+if (! defined('NOREQUIRESOC')) {
25
+    define('NOREQUIRESOC','1');
26
+}
27
+if (! defined('NOCSRFCHECK')) {
28
+    define('NOCSRFCHECK',1);
29
+}
30
+if (! defined('NOTOKENRENEWAL')) {
31
+    define('NOTOKENRENEWAL',1);
32
+}
33
+if (! defined('NOLOGIN')) {
34
+    define('NOLOGIN',1);
35
+}
36
+if (! defined('NOREQUIREMENU')) {
37
+    define('NOREQUIREMENU',1);
38
+}
39
+if (! defined('NOREQUIREHTML')) {
40
+    define('NOREQUIREHTML',1);
41
+}
42
+if (! defined('NOREQUIREAJAX')) {
43
+    define('NOREQUIREAJAX','1');
44
+}
31 45
 
32 46
 session_cache_limiter('public');
33 47
 
@@ -36,8 +50,11 @@  discard block
 block discarded – undo
36 50
 // Define javascript type
37 51
 top_httphead('text/javascript; charset=UTF-8');
38 52
 // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
39
-if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate');
40
-else header('Cache-Control: no-cache');
53
+if (empty($dolibarr_nocache)) {
54
+    header('Cache-Control: max-age=10800, public, must-revalidate');
55
+} else {
56
+    header('Cache-Control: no-cache');
57
+}
41 58
 ?>
42 59
 
43 60
 // For JQuery Timepicker
@@ -61,4 +78,6 @@  discard block
 block discarded – undo
61 78
 });
62 79
 
63 80
 <?php
64
-if (is_object($db)) $db->close();
81
+if (is_object($db)) {
82
+    $db->close();
83
+}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/actions_linkedfiles.inc.php 3 patches
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -29,41 +29,41 @@  discard block
 block discarded – undo
29 29
 // Submit file/link
30 30
 if (GETPOST('sendit','alpha') && ! empty($conf->global->MAIN_UPLOAD_DOC))
31 31
 {
32
-	if (! empty($_FILES))
33
-	{
34
-		if (is_array($_FILES['userfile']['tmp_name'])) $userfiles=$_FILES['userfile']['tmp_name'];
35
-		else $userfiles=array($_FILES['userfile']['tmp_name']);
32
+    if (! empty($_FILES))
33
+    {
34
+        if (is_array($_FILES['userfile']['tmp_name'])) $userfiles=$_FILES['userfile']['tmp_name'];
35
+        else $userfiles=array($_FILES['userfile']['tmp_name']);
36 36
 
37
-		foreach($userfiles as $key => $userfile)
38
-		{
39
-			if (empty($_FILES['userfile']['tmp_name'][$key]))
40
-			{
41
-				$error++;
42
-				if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2){
43
-					setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors');
44
-				}
45
-				else {
46
-					setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors');
47
-				}
48
-			}
49
-		}
37
+        foreach($userfiles as $key => $userfile)
38
+        {
39
+            if (empty($_FILES['userfile']['tmp_name'][$key]))
40
+            {
41
+                $error++;
42
+                if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2){
43
+                    setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors');
44
+                }
45
+                else {
46
+                    setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors');
47
+                }
48
+            }
49
+        }
50 50
 
51
-		if (! $error)
52
-		{
53
-			// Define if we have to generate thumbs or not
54
-			$generatethumbs = 1;
55
-			if (GETPOST('section_dir')) $generatethumbs=0;
51
+        if (! $error)
52
+        {
53
+            // Define if we have to generate thumbs or not
54
+            $generatethumbs = 1;
55
+            if (GETPOST('section_dir')) $generatethumbs=0;
56 56
 
57
-			if (! empty($upload_dirold) && ! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
58
-			{
59
-				$result = dol_add_file_process($upload_dirold, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs);
60
-			}
61
-			elseif (! empty($upload_dir))
62
-			{
63
-				$result = dol_add_file_process($upload_dir, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs);
64
-			}
65
-		}
66
-	}
57
+            if (! empty($upload_dirold) && ! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
58
+            {
59
+                $result = dol_add_file_process($upload_dirold, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs);
60
+            }
61
+            elseif (! empty($upload_dir))
62
+            {
63
+                $result = dol_add_file_process($upload_dir, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs);
64
+            }
65
+        }
66
+    }
67 67
 }
68 68
 elseif (GETPOST('linkit','none') && ! empty($conf->global->MAIN_UPLOAD_DOC))
69 69
 {
@@ -84,39 +84,39 @@  discard block
 block discarded – undo
84 84
         $urlfile = GETPOST('urlfile', 'alpha', 0, null, null, 1);				// Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
85 85
         if (GETPOST('section', 'alpha')) 	// For a delete from the ECM module, upload_dir is ECM root dir and urlfile contains relative path from upload_dir
86 86
         {
87
-        	$file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile;
87
+            $file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile;
88 88
         }
89 89
         else								// For a delete from the file manager into another module, or from documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile.
90
-		{
91
-       		$urlfile=basename($urlfile);
92
-       		$file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile;
93
-			if (! empty($upload_dirold)) $fileold = $upload_dirold . "/" . $urlfile;
94
-		}
90
+        {
91
+                $urlfile=basename($urlfile);
92
+                $file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile;
93
+            if (! empty($upload_dirold)) $fileold = $upload_dirold . "/" . $urlfile;
94
+        }
95 95
         $linkid = GETPOST('linkid', 'int');
96 96
 
97 97
         if ($urlfile)		// delete of a file
98 98
         {
99
-	        $dir = dirname($file).'/';		// Chemin du dossier contenant l'image d'origine
100
-	        $dirthumb = $dir.'/thumbs/';	// Chemin du dossier contenant la vignette (if file is an image)
99
+            $dir = dirname($file).'/';		// Chemin du dossier contenant l'image d'origine
100
+            $dirthumb = $dir.'/thumbs/';	// Chemin du dossier contenant la vignette (if file is an image)
101 101
 
102
-	        $ret = dol_delete_file($file, 0, 0, 0, (is_object($object)?$object:null));
102
+            $ret = dol_delete_file($file, 0, 0, 0, (is_object($object)?$object:null));
103 103
             if (! empty($fileold)) dol_delete_file($fileold, 0, 0, 0, (is_object($object)?$object:null));     // Delete file using old path
104 104
 
105
-	        // Si elle existe, on efface la vignette
106
-	        if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i',$file,$regs))
107
-	        {
108
-		        $photo_vignette=basename(preg_replace('/'.$regs[0].'/i','',$file).'_small'.$regs[0]);
109
-		        if (file_exists(dol_osencode($dirthumb.$photo_vignette)))
110
-		        {
111
-			        dol_delete_file($dirthumb.$photo_vignette);
112
-		        }
105
+            // Si elle existe, on efface la vignette
106
+            if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i',$file,$regs))
107
+            {
108
+                $photo_vignette=basename(preg_replace('/'.$regs[0].'/i','',$file).'_small'.$regs[0]);
109
+                if (file_exists(dol_osencode($dirthumb.$photo_vignette)))
110
+                {
111
+                    dol_delete_file($dirthumb.$photo_vignette);
112
+                }
113 113
 
114
-		        $photo_vignette=basename(preg_replace('/'.$regs[0].'/i','',$file).'_mini'.$regs[0]);
115
-		        if (file_exists(dol_osencode($dirthumb.$photo_vignette)))
116
-		        {
117
-			        dol_delete_file($dirthumb.$photo_vignette);
118
-		        }
119
-	        }
114
+                $photo_vignette=basename(preg_replace('/'.$regs[0].'/i','',$file).'_mini'.$regs[0]);
115
+                if (file_exists(dol_osencode($dirthumb.$photo_vignette)))
116
+                {
117
+                    dol_delete_file($dirthumb.$photo_vignette);
118
+                }
119
+            }
120 120
 
121 121
             if ($ret) setEventMessages($langs->trans("FileWasRemoved", $urlfile), null, 'mesgs');
122 122
             else setEventMessages($langs->trans("ErrorFailToDeleteFile", $urlfile), null, 'errors');
@@ -143,16 +143,16 @@  discard block
 block discarded – undo
143 143
 
144 144
         if (is_object($object) && $object->id > 0)
145 145
         {
146
-        	if ($backtopage)
147
-        	{
148
-        		header('Location: ' . $backtopage);
149
-        		exit;
150
-        	}
151
-        	else
152
-        	{
153
-        		header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(GETPOST('section_dir','alpha')?'&section_dir='.urlencode(GETPOST('section_dir','alpha')):'').(!empty($withproject)?'&withproject=1':''));
154
-        		exit;
155
-        	}
146
+            if ($backtopage)
147
+            {
148
+                header('Location: ' . $backtopage);
149
+                exit;
150
+            }
151
+            else
152
+            {
153
+                header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(GETPOST('section_dir','alpha')?'&section_dir='.urlencode(GETPOST('section_dir','alpha')):'').(!empty($withproject)?'&withproject=1':''));
154
+                exit;
155
+            }
156 156
         }
157 157
 }
158 158
 elseif ($action == 'confirm_updateline' && GETPOST('save','alpha') && GETPOST('link', 'alpha'))
@@ -183,101 +183,101 @@  discard block
 block discarded – undo
183 183
 }
184 184
 elseif ($action == 'renamefile' && GETPOST('renamefilesave','alpha'))
185 185
 {
186
-	// For documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile.
187
-	if (! empty($upload_dir))
188
-	{
189
-		$filenamefrom=dol_sanitizeFileName(GETPOST('renamefilefrom','alpha'), '_', 0);	// Do not remove accents
190
-		$filenameto=dol_sanitizeFileName(GETPOST('renamefileto','alpha'), '_', 0);		// Do not remove accents
186
+    // For documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile.
187
+    if (! empty($upload_dir))
188
+    {
189
+        $filenamefrom=dol_sanitizeFileName(GETPOST('renamefilefrom','alpha'), '_', 0);	// Do not remove accents
190
+        $filenameto=dol_sanitizeFileName(GETPOST('renamefileto','alpha'), '_', 0);		// Do not remove accents
191 191
 
192 192
         if ($filenamefrom != $filenameto)
193 193
         {
194
-	        // Security:
195
-	        // Disallow file with some extensions. We rename them.
196
-	        // Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code.
197
-	        if (preg_match('/(\.htm|\.html|\.php|\.pl|\.cgi)$/i',$filenameto) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED))
198
-	        {
199
-	            $filenameto.= '.noexe';
200
-	        }
194
+            // Security:
195
+            // Disallow file with some extensions. We rename them.
196
+            // Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code.
197
+            if (preg_match('/(\.htm|\.html|\.php|\.pl|\.cgi)$/i',$filenameto) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED))
198
+            {
199
+                $filenameto.= '.noexe';
200
+            }
201 201
 
202
-	        if ($filenamefrom && $filenameto)
203
-	        {
204
-	            $srcpath = $upload_dir.'/'.$filenamefrom;
205
-	            $destpath = $upload_dir.'/'.$filenameto;
202
+            if ($filenamefrom && $filenameto)
203
+            {
204
+                $srcpath = $upload_dir.'/'.$filenamefrom;
205
+                $destpath = $upload_dir.'/'.$filenameto;
206 206
 
207
-	            $reshook=$hookmanager->initHooks(array('actionlinkedfiles'));
208
-	            $parameters=array('filenamefrom' => $filenamefrom, 'filenameto' => $filenameto, 'upload_dir' => $upload_dir);
209
-	            $reshook=$hookmanager->executeHooks('renameUploadedFile', $parameters, $object);
207
+                $reshook=$hookmanager->initHooks(array('actionlinkedfiles'));
208
+                $parameters=array('filenamefrom' => $filenamefrom, 'filenameto' => $filenameto, 'upload_dir' => $upload_dir);
209
+                $reshook=$hookmanager->executeHooks('renameUploadedFile', $parameters, $object);
210 210
 
211
-	            if (empty($reshook))
212
-	            {
213
-	            	if (! file_exists($destpath))
214
-	            	{
215
-	            		$result = dol_move($srcpath, $destpath);
216
-			            if ($result)
217
-			            {
218
-			            	// Define if we have to generate thumbs or not
219
-			            	$generatethumbs = 1;
220
-			            	// When we rename a file from the file manager in ecm, we must not regenerate thumbs (not a problem, we do pass here)
221
-			            	// When we rename a file from the website module, we must not regenerate thumbs (module = medias in such a case)
222
-			            	// but when we rename from a tab "Documents", we must regenerate thumbs
223
-			            	if (GETPOST('modulepart') == 'medias') $generatethumbs=0;
211
+                if (empty($reshook))
212
+                {
213
+                    if (! file_exists($destpath))
214
+                    {
215
+                        $result = dol_move($srcpath, $destpath);
216
+                        if ($result)
217
+                        {
218
+                            // Define if we have to generate thumbs or not
219
+                            $generatethumbs = 1;
220
+                            // When we rename a file from the file manager in ecm, we must not regenerate thumbs (not a problem, we do pass here)
221
+                            // When we rename a file from the website module, we must not regenerate thumbs (module = medias in such a case)
222
+                            // but when we rename from a tab "Documents", we must regenerate thumbs
223
+                            if (GETPOST('modulepart') == 'medias') $generatethumbs=0;
224 224
 
225
-			            	if ($generatethumbs)
226
-			            	{
227
-			            		if ($object->id)
228
-				            	{
229
-				                	$object->addThumbs($destpath);
230
-				            	}
225
+                            if ($generatethumbs)
226
+                            {
227
+                                if ($object->id)
228
+                                {
229
+                                    $object->addThumbs($destpath);
230
+                                }
231 231
 
232
-				                // TODO Add revert function of addThumbs to remove thumbs with old name
233
-				                //$object->delThumbs($srcpath);
234
-			            	}
232
+                                // TODO Add revert function of addThumbs to remove thumbs with old name
233
+                                //$object->delThumbs($srcpath);
234
+                            }
235 235
 
236
-			                setEventMessages($langs->trans("FileRenamed"), null);
237
-			            }
238
-			            else
239
-			            {
240
-			                $langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now.
241
-			                setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors');
242
-			            }
243
-	            	}
244
-	            	else
245
-	            	{
246
-	            		$langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now.
247
-	            		setEventMessages($langs->trans("ErrorDestinationAlreadyExists", $filenameto), null, 'errors');
248
-	            	}
249
-	            }
250
-	        }
236
+                            setEventMessages($langs->trans("FileRenamed"), null);
237
+                        }
238
+                        else
239
+                        {
240
+                            $langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now.
241
+                            setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors');
242
+                        }
243
+                    }
244
+                    else
245
+                    {
246
+                        $langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now.
247
+                        setEventMessages($langs->trans("ErrorDestinationAlreadyExists", $filenameto), null, 'errors');
248
+                    }
249
+                }
250
+            }
251 251
         }
252 252
     }
253 253
 
254 254
     // Update properties in ECM table
255 255
     if (GETPOST('ecmfileid', 'int') > 0)
256 256
     {
257
-    	$shareenabled = GETPOST('shareenabled', 'alpha');
257
+        $shareenabled = GETPOST('shareenabled', 'alpha');
258 258
 
259
-    	include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
260
-	    $ecmfile=new EcmFiles($db);
261
-	    $result = $ecmfile->fetch(GETPOST('ecmfileid', 'int'));
262
-	    if ($result > 0)
263
-	    {
264
-	    	if ($shareenabled)
265
-		    {
266
-		    	if (empty($ecmfile->share))
267
-		    	{
268
-		    		require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
269
-		    		$ecmfile->share = getRandomPassword(true);
270
-		    	}
271
-		    }
272
-		    else
273
-		    {
274
-		    	$ecmfile->share = '';
275
-		    }
276
-		    $result = $ecmfile->update($user);
277
-		    if ($result < 0)
278
-		    {
279
-		    	setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
280
-		    }
281
-	    }
259
+        include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
260
+        $ecmfile=new EcmFiles($db);
261
+        $result = $ecmfile->fetch(GETPOST('ecmfileid', 'int'));
262
+        if ($result > 0)
263
+        {
264
+            if ($shareenabled)
265
+            {
266
+                if (empty($ecmfile->share))
267
+                {
268
+                    require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
269
+                    $ecmfile->share = getRandomPassword(true);
270
+                }
271
+            }
272
+            else
273
+            {
274
+                $ecmfile->share = '';
275
+            }
276
+            $result = $ecmfile->update($user);
277
+            if ($result < 0)
278
+            {
279
+                setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
280
+            }
281
+        }
282 282
     }
283 283
 }
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -27,19 +27,19 @@  discard block
 block discarded – undo
27 27
 
28 28
 
29 29
 // Submit file/link
30
-if (GETPOST('sendit','alpha') && ! empty($conf->global->MAIN_UPLOAD_DOC))
30
+if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC))
31 31
 {
32
-	if (! empty($_FILES))
32
+	if (!empty($_FILES))
33 33
 	{
34
-		if (is_array($_FILES['userfile']['tmp_name'])) $userfiles=$_FILES['userfile']['tmp_name'];
35
-		else $userfiles=array($_FILES['userfile']['tmp_name']);
34
+		if (is_array($_FILES['userfile']['tmp_name'])) $userfiles = $_FILES['userfile']['tmp_name'];
35
+		else $userfiles = array($_FILES['userfile']['tmp_name']);
36 36
 
37
-		foreach($userfiles as $key => $userfile)
37
+		foreach ($userfiles as $key => $userfile)
38 38
 		{
39 39
 			if (empty($_FILES['userfile']['tmp_name'][$key]))
40 40
 			{
41 41
 				$error++;
42
-				if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2){
42
+				if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2) {
43 43
 					setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors');
44 44
 				}
45 45
 				else {
@@ -48,30 +48,30 @@  discard block
 block discarded – undo
48 48
 			}
49 49
 		}
50 50
 
51
-		if (! $error)
51
+		if (!$error)
52 52
 		{
53 53
 			// Define if we have to generate thumbs or not
54 54
 			$generatethumbs = 1;
55
-			if (GETPOST('section_dir')) $generatethumbs=0;
55
+			if (GETPOST('section_dir')) $generatethumbs = 0;
56 56
 
57
-			if (! empty($upload_dirold) && ! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
57
+			if (!empty($upload_dirold) && !empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
58 58
 			{
59 59
 				$result = dol_add_file_process($upload_dirold, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs);
60 60
 			}
61
-			elseif (! empty($upload_dir))
61
+			elseif (!empty($upload_dir))
62 62
 			{
63 63
 				$result = dol_add_file_process($upload_dir, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs);
64 64
 			}
65 65
 		}
66 66
 	}
67 67
 }
68
-elseif (GETPOST('linkit','none') && ! empty($conf->global->MAIN_UPLOAD_DOC))
68
+elseif (GETPOST('linkit', 'none') && !empty($conf->global->MAIN_UPLOAD_DOC))
69 69
 {
70 70
     $link = GETPOST('link', 'alpha');
71 71
     if ($link)
72 72
     {
73 73
         if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://' && substr($link, 0, 7) != 'file://') {
74
-            $link = 'http://' . $link;
74
+            $link = 'http://'.$link;
75 75
         }
76 76
         dol_add_file_process($upload_dir, 0, 1, 'userfile', null, $link, '', 0);
77 77
     }
@@ -81,37 +81,37 @@  discard block
 block discarded – undo
81 81
 // Delete file/link
82 82
 if ($action == 'confirm_deletefile' && $confirm == 'yes')
83 83
 {
84
-        $urlfile = GETPOST('urlfile', 'alpha', 0, null, null, 1);				// Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
84
+        $urlfile = GETPOST('urlfile', 'alpha', 0, null, null, 1); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
85 85
         if (GETPOST('section', 'alpha')) 	// For a delete from the ECM module, upload_dir is ECM root dir and urlfile contains relative path from upload_dir
86 86
         {
87
-        	$file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile;
87
+        	$file = $upload_dir.(preg_match('/\/$/', $upload_dir) ? '' : '/').$urlfile;
88 88
         }
89 89
         else								// For a delete from the file manager into another module, or from documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile.
90 90
 		{
91
-       		$urlfile=basename($urlfile);
92
-       		$file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile;
93
-			if (! empty($upload_dirold)) $fileold = $upload_dirold . "/" . $urlfile;
91
+       		$urlfile = basename($urlfile);
92
+       		$file = $upload_dir.(preg_match('/\/$/', $upload_dir) ? '' : '/').$urlfile;
93
+			if (!empty($upload_dirold)) $fileold = $upload_dirold."/".$urlfile;
94 94
 		}
95 95
         $linkid = GETPOST('linkid', 'int');
96 96
 
97 97
         if ($urlfile)		// delete of a file
98 98
         {
99
-	        $dir = dirname($file).'/';		// Chemin du dossier contenant l'image d'origine
100
-	        $dirthumb = $dir.'/thumbs/';	// Chemin du dossier contenant la vignette (if file is an image)
99
+	        $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine
100
+	        $dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette (if file is an image)
101 101
 
102
-	        $ret = dol_delete_file($file, 0, 0, 0, (is_object($object)?$object:null));
103
-            if (! empty($fileold)) dol_delete_file($fileold, 0, 0, 0, (is_object($object)?$object:null));     // Delete file using old path
102
+	        $ret = dol_delete_file($file, 0, 0, 0, (is_object($object) ? $object : null));
103
+            if (!empty($fileold)) dol_delete_file($fileold, 0, 0, 0, (is_object($object) ? $object : null)); // Delete file using old path
104 104
 
105 105
 	        // Si elle existe, on efface la vignette
106
-	        if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i',$file,$regs))
106
+	        if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs))
107 107
 	        {
108
-		        $photo_vignette=basename(preg_replace('/'.$regs[0].'/i','',$file).'_small'.$regs[0]);
108
+		        $photo_vignette = basename(preg_replace('/'.$regs[0].'/i', '', $file).'_small'.$regs[0]);
109 109
 		        if (file_exists(dol_osencode($dirthumb.$photo_vignette)))
110 110
 		        {
111 111
 			        dol_delete_file($dirthumb.$photo_vignette);
112 112
 		        }
113 113
 
114
-		        $photo_vignette=basename(preg_replace('/'.$regs[0].'/i','',$file).'_mini'.$regs[0]);
114
+		        $photo_vignette = basename(preg_replace('/'.$regs[0].'/i', '', $file).'_mini'.$regs[0]);
115 115
 		        if (file_exists(dol_osencode($dirthumb.$photo_vignette)))
116 116
 		        {
117 117
 			        dol_delete_file($dirthumb.$photo_vignette);
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         }
124 124
         elseif ($linkid)	// delete of external link
125 125
         {
126
-            require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
126
+            require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
127 127
             $link = new Link($db);
128 128
             $link->id = $linkid;
129 129
             $link->fetch();
@@ -145,19 +145,19 @@  discard block
 block discarded – undo
145 145
         {
146 146
         	if ($backtopage)
147 147
         	{
148
-        		header('Location: ' . $backtopage);
148
+        		header('Location: '.$backtopage);
149 149
         		exit;
150 150
         	}
151 151
         	else
152 152
         	{
153
-        		header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(GETPOST('section_dir','alpha')?'&section_dir='.urlencode(GETPOST('section_dir','alpha')):'').(!empty($withproject)?'&withproject=1':''));
153
+        		header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(GETPOST('section_dir', 'alpha') ? '&section_dir='.urlencode(GETPOST('section_dir', 'alpha')) : '').(!empty($withproject) ? '&withproject=1' : ''));
154 154
         		exit;
155 155
         	}
156 156
         }
157 157
 }
158
-elseif ($action == 'confirm_updateline' && GETPOST('save','alpha') && GETPOST('link', 'alpha'))
158
+elseif ($action == 'confirm_updateline' && GETPOST('save', 'alpha') && GETPOST('link', 'alpha'))
159 159
 {
160
-    require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
160
+    require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
161 161
     $langs->load('link');
162 162
     $link = new Link($db);
163 163
     $link->id = GETPOST('linkid', 'int');
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         $link->url = GETPOST('link', 'alpha');
168 168
         if (substr($link->url, 0, 7) != 'http://' && substr($link->url, 0, 8) != 'https://' && substr($link->url, 0, 7) != 'file://')
169 169
         {
170
-            $link->url = 'http://' . $link->url;
170
+            $link->url = 'http://'.$link->url;
171 171
         }
172 172
         $link->label = GETPOST('label', 'alpha');
173 173
         $res = $link->update($user);
@@ -181,22 +181,22 @@  discard block
 block discarded – undo
181 181
         //error fetching
182 182
     }
183 183
 }
184
-elseif ($action == 'renamefile' && GETPOST('renamefilesave','alpha'))
184
+elseif ($action == 'renamefile' && GETPOST('renamefilesave', 'alpha'))
185 185
 {
186 186
 	// For documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile.
187
-	if (! empty($upload_dir))
187
+	if (!empty($upload_dir))
188 188
 	{
189
-		$filenamefrom=dol_sanitizeFileName(GETPOST('renamefilefrom','alpha'), '_', 0);	// Do not remove accents
190
-		$filenameto=dol_sanitizeFileName(GETPOST('renamefileto','alpha'), '_', 0);		// Do not remove accents
189
+		$filenamefrom = dol_sanitizeFileName(GETPOST('renamefilefrom', 'alpha'), '_', 0); // Do not remove accents
190
+		$filenameto = dol_sanitizeFileName(GETPOST('renamefileto', 'alpha'), '_', 0); // Do not remove accents
191 191
 
192 192
         if ($filenamefrom != $filenameto)
193 193
         {
194 194
 	        // Security:
195 195
 	        // Disallow file with some extensions. We rename them.
196 196
 	        // Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code.
197
-	        if (preg_match('/(\.htm|\.html|\.php|\.pl|\.cgi)$/i',$filenameto) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED))
197
+	        if (preg_match('/(\.htm|\.html|\.php|\.pl|\.cgi)$/i', $filenameto) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED))
198 198
 	        {
199
-	            $filenameto.= '.noexe';
199
+	            $filenameto .= '.noexe';
200 200
 	        }
201 201
 
202 202
 	        if ($filenamefrom && $filenameto)
@@ -204,13 +204,13 @@  discard block
 block discarded – undo
204 204
 	            $srcpath = $upload_dir.'/'.$filenamefrom;
205 205
 	            $destpath = $upload_dir.'/'.$filenameto;
206 206
 
207
-	            $reshook=$hookmanager->initHooks(array('actionlinkedfiles'));
208
-	            $parameters=array('filenamefrom' => $filenamefrom, 'filenameto' => $filenameto, 'upload_dir' => $upload_dir);
209
-	            $reshook=$hookmanager->executeHooks('renameUploadedFile', $parameters, $object);
207
+	            $reshook = $hookmanager->initHooks(array('actionlinkedfiles'));
208
+	            $parameters = array('filenamefrom' => $filenamefrom, 'filenameto' => $filenameto, 'upload_dir' => $upload_dir);
209
+	            $reshook = $hookmanager->executeHooks('renameUploadedFile', $parameters, $object);
210 210
 
211 211
 	            if (empty($reshook))
212 212
 	            {
213
-	            	if (! file_exists($destpath))
213
+	            	if (!file_exists($destpath))
214 214
 	            	{
215 215
 	            		$result = dol_move($srcpath, $destpath);
216 216
 			            if ($result)
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 			            	// When we rename a file from the file manager in ecm, we must not regenerate thumbs (not a problem, we do pass here)
221 221
 			            	// When we rename a file from the website module, we must not regenerate thumbs (module = medias in such a case)
222 222
 			            	// but when we rename from a tab "Documents", we must regenerate thumbs
223
-			            	if (GETPOST('modulepart') == 'medias') $generatethumbs=0;
223
+			            	if (GETPOST('modulepart') == 'medias') $generatethumbs = 0;
224 224
 
225 225
 			            	if ($generatethumbs)
226 226
 			            	{
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
     	$shareenabled = GETPOST('shareenabled', 'alpha');
258 258
 
259 259
     	include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
260
-	    $ecmfile=new EcmFiles($db);
260
+	    $ecmfile = new EcmFiles($db);
261 261
 	    $result = $ecmfile->fetch(GETPOST('ecmfileid', 'int'));
262 262
 	    if ($result > 0)
263 263
 	    {
Please login to merge, or discard this patch.
Braces   +44 added lines, -34 removed lines patch added patch discarded remove patch
@@ -31,8 +31,11 @@  discard block
 block discarded – undo
31 31
 {
32 32
 	if (! empty($_FILES))
33 33
 	{
34
-		if (is_array($_FILES['userfile']['tmp_name'])) $userfiles=$_FILES['userfile']['tmp_name'];
35
-		else $userfiles=array($_FILES['userfile']['tmp_name']);
34
+		if (is_array($_FILES['userfile']['tmp_name'])) {
35
+		    $userfiles=$_FILES['userfile']['tmp_name'];
36
+		} else {
37
+		    $userfiles=array($_FILES['userfile']['tmp_name']);
38
+		}
36 39
 
37 40
 		foreach($userfiles as $key => $userfile)
38 41
 		{
@@ -41,8 +44,7 @@  discard block
 block discarded – undo
41 44
 				$error++;
42 45
 				if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2){
43 46
 					setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors');
44
-				}
45
-				else {
47
+				} else {
46 48
 					setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors');
47 49
 				}
48 50
 			}
@@ -52,20 +54,20 @@  discard block
 block discarded – undo
52 54
 		{
53 55
 			// Define if we have to generate thumbs or not
54 56
 			$generatethumbs = 1;
55
-			if (GETPOST('section_dir')) $generatethumbs=0;
57
+			if (GETPOST('section_dir')) {
58
+			    $generatethumbs=0;
59
+			}
56 60
 
57 61
 			if (! empty($upload_dirold) && ! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
58 62
 			{
59 63
 				$result = dol_add_file_process($upload_dirold, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs);
60
-			}
61
-			elseif (! empty($upload_dir))
64
+			} elseif (! empty($upload_dir))
62 65
 			{
63 66
 				$result = dol_add_file_process($upload_dir, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs);
64 67
 			}
65 68
 		}
66 69
 	}
67
-}
68
-elseif (GETPOST('linkit','none') && ! empty($conf->global->MAIN_UPLOAD_DOC))
70
+} elseif (GETPOST('linkit','none') && ! empty($conf->global->MAIN_UPLOAD_DOC))
69 71
 {
70 72
     $link = GETPOST('link', 'alpha');
71 73
     if ($link)
@@ -82,25 +84,34 @@  discard block
 block discarded – undo
82 84
 if ($action == 'confirm_deletefile' && $confirm == 'yes')
83 85
 {
84 86
         $urlfile = GETPOST('urlfile', 'alpha', 0, null, null, 1);				// Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
85
-        if (GETPOST('section', 'alpha')) 	// For a delete from the ECM module, upload_dir is ECM root dir and urlfile contains relative path from upload_dir
87
+        if (GETPOST('section', 'alpha')) {
88
+            // For a delete from the ECM module, upload_dir is ECM root dir and urlfile contains relative path from upload_dir
86 89
         {
87 90
         	$file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile;
88 91
         }
89
-        else								// For a delete from the file manager into another module, or from documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile.
92
+        } else								// For a delete from the file manager into another module, or from documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile.
90 93
 		{
91 94
        		$urlfile=basename($urlfile);
92 95
        		$file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile;
93
-			if (! empty($upload_dirold)) $fileold = $upload_dirold . "/" . $urlfile;
96
+			if (! empty($upload_dirold)) {
97
+			    $fileold = $upload_dirold . "/" . $urlfile;
98
+			}
94 99
 		}
95 100
         $linkid = GETPOST('linkid', 'int');
96 101
 
97
-        if ($urlfile)		// delete of a file
102
+        if ($urlfile) {
103
+            // delete of a file
98 104
         {
99
-	        $dir = dirname($file).'/';		// Chemin du dossier contenant l'image d'origine
105
+	        $dir = dirname($file).'/';
106
+        }
107
+        // Chemin du dossier contenant l'image d'origine
100 108
 	        $dirthumb = $dir.'/thumbs/';	// Chemin du dossier contenant la vignette (if file is an image)
101 109
 
102 110
 	        $ret = dol_delete_file($file, 0, 0, 0, (is_object($object)?$object:null));
103
-            if (! empty($fileold)) dol_delete_file($fileold, 0, 0, 0, (is_object($object)?$object:null));     // Delete file using old path
111
+            if (! empty($fileold)) {
112
+                dol_delete_file($fileold, 0, 0, 0, (is_object($object)?$object:null));
113
+            }
114
+            // Delete file using old path
104 115
 
105 116
 	        // Si elle existe, on efface la vignette
106 117
 	        if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i',$file,$regs))
@@ -118,12 +129,16 @@  discard block
 block discarded – undo
118 129
 		        }
119 130
 	        }
120 131
 
121
-            if ($ret) setEventMessages($langs->trans("FileWasRemoved", $urlfile), null, 'mesgs');
122
-            else setEventMessages($langs->trans("ErrorFailToDeleteFile", $urlfile), null, 'errors');
123
-        }
124
-        elseif ($linkid)	// delete of external link
132
+            if ($ret) {
133
+                setEventMessages($langs->trans("FileWasRemoved", $urlfile), null, 'mesgs');
134
+            } else {
135
+                setEventMessages($langs->trans("ErrorFailToDeleteFile", $urlfile), null, 'errors');
136
+            }
137
+        } elseif ($linkid) {
138
+            // delete of external link
125 139
         {
126 140
             require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
141
+        }
127 142
             $link = new Link($db);
128 143
             $link->id = $linkid;
129 144
             $link->fetch();
@@ -147,15 +162,13 @@  discard block
 block discarded – undo
147 162
         	{
148 163
         		header('Location: ' . $backtopage);
149 164
         		exit;
150
-        	}
151
-        	else
165
+        	} else
152 166
         	{
153 167
         		header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(GETPOST('section_dir','alpha')?'&section_dir='.urlencode(GETPOST('section_dir','alpha')):'').(!empty($withproject)?'&withproject=1':''));
154 168
         		exit;
155 169
         	}
156 170
         }
157
-}
158
-elseif ($action == 'confirm_updateline' && GETPOST('save','alpha') && GETPOST('link', 'alpha'))
171
+} elseif ($action == 'confirm_updateline' && GETPOST('save','alpha') && GETPOST('link', 'alpha'))
159 172
 {
160 173
     require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
161 174
     $langs->load('link');
@@ -175,13 +188,11 @@  discard block
 block discarded – undo
175 188
         {
176 189
             setEventMessages($langs->trans("ErrorFailedToUpdateLink", $link->label), null, 'mesgs');
177 190
         }
178
-    }
179
-    else
191
+    } else
180 192
     {
181 193
         //error fetching
182 194
     }
183
-}
184
-elseif ($action == 'renamefile' && GETPOST('renamefilesave','alpha'))
195
+} elseif ($action == 'renamefile' && GETPOST('renamefilesave','alpha'))
185 196
 {
186 197
 	// For documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile.
187 198
 	if (! empty($upload_dir))
@@ -220,7 +231,9 @@  discard block
 block discarded – undo
220 231
 			            	// When we rename a file from the file manager in ecm, we must not regenerate thumbs (not a problem, we do pass here)
221 232
 			            	// When we rename a file from the website module, we must not regenerate thumbs (module = medias in such a case)
222 233
 			            	// but when we rename from a tab "Documents", we must regenerate thumbs
223
-			            	if (GETPOST('modulepart') == 'medias') $generatethumbs=0;
234
+			            	if (GETPOST('modulepart') == 'medias') {
235
+			            	    $generatethumbs=0;
236
+			            	}
224 237
 
225 238
 			            	if ($generatethumbs)
226 239
 			            	{
@@ -234,14 +247,12 @@  discard block
 block discarded – undo
234 247
 			            	}
235 248
 
236 249
 			                setEventMessages($langs->trans("FileRenamed"), null);
237
-			            }
238
-			            else
250
+			            } else
239 251
 			            {
240 252
 			                $langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now.
241 253
 			                setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors');
242 254
 			            }
243
-	            	}
244
-	            	else
255
+	            	} else
245 256
 	            	{
246 257
 	            		$langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now.
247 258
 	            		setEventMessages($langs->trans("ErrorDestinationAlreadyExists", $filenameto), null, 'errors');
@@ -268,8 +279,7 @@  discard block
 block discarded – undo
268 279
 		    		require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
269 280
 		    		$ecmfile->share = getRandomPassword(true);
270 281
 		    	}
271
-		    }
272
-		    else
282
+		    } else
273 283
 		    {
274 284
 		    	$ecmfile->share = '';
275 285
 		    }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modFTP.class.php 2 patches
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -33,96 +33,96 @@
 block discarded – undo
33 33
 class modFTP extends DolibarrModules
34 34
 {
35 35
 
36
-   /**
37
-	 *   Constructor. Define names, constants, directories, boxes, permissions
38
-	 *
39
-	 *   @param      DoliDB		$db      Database handler
40
-    */
41
-	function __construct($db)
42
-	{
43
-		$this->db = $db;
44
-
45
-		// Id for module (must be unique).
46
-		// Use here a free id.
47
-		$this->numero = 2800;
48
-
49
-		// Family can be 'crm','financial','hr','projects','product','ecm','technic','other'
50
-		// It is used to sort modules in module setup page
51
-		$this->family = "interface";
52
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
-		$this->name = preg_replace('/^mod/i','',get_class($this));
54
-		// Module description used if translation string 'ModuleXXXDesc' not found (XXX is id value)
55
-		$this->description = "FTP Client";
56
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57
-		$this->version = 'dolibarr';
58
-		// Key used in llx_const table to save module status enabled/disabled (XXX is id value)
59
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
-		// Name of png file (without png) used for this module
61
-		$this->picto='dir';
62
-
63
-		// Data directories to create when module is enabled
64
-		$this->dirs = array("/ftp/temp");
65
-
66
-		// Langs file within the module
67
-		$this->langfiles = array("ftp");
68
-
69
-		// Config pages. Put here list of php page names stored in admmin directory used to setup module
70
-		$this->config_page_url = array('ftpclient.php@ftp');
71
-
72
-		// Dependencies
73
-		$this->depends = array();		// List of modules id that must be enabled if this module is enabled
74
-		$this->requiredby = array();	// List of modules id to disable if this one is disabled
75
-
76
-		// Constants
77
-		$this->const = array(
78
-		    1=>array('FTP_CONNECT_WITH_SSL','chaine','0','Use FTPS for FTP module', 1, 'current', 1),
79
-		    2=>array('FTP_CONNECT_WITH_SFTP','chaine','0','Use SFTP for FTP module', 1, 'current', 1)
80
-		);			// List of parameters
81
-
82
-		// Boxes
83
-		$this->boxes = array();			// List of boxes
84
-		$r=0;
85
-
86
-		// Add here list of php file(s) stored in core/boxes that contains class to show a box.
87
-		// Example:
36
+    /**
37
+     *   Constructor. Define names, constants, directories, boxes, permissions
38
+     *
39
+     *   @param      DoliDB		$db      Database handler
40
+     */
41
+    function __construct($db)
42
+    {
43
+        $this->db = $db;
44
+
45
+        // Id for module (must be unique).
46
+        // Use here a free id.
47
+        $this->numero = 2800;
48
+
49
+        // Family can be 'crm','financial','hr','projects','product','ecm','technic','other'
50
+        // It is used to sort modules in module setup page
51
+        $this->family = "interface";
52
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
+        $this->name = preg_replace('/^mod/i','',get_class($this));
54
+        // Module description used if translation string 'ModuleXXXDesc' not found (XXX is id value)
55
+        $this->description = "FTP Client";
56
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57
+        $this->version = 'dolibarr';
58
+        // Key used in llx_const table to save module status enabled/disabled (XXX is id value)
59
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
+        // Name of png file (without png) used for this module
61
+        $this->picto='dir';
62
+
63
+        // Data directories to create when module is enabled
64
+        $this->dirs = array("/ftp/temp");
65
+
66
+        // Langs file within the module
67
+        $this->langfiles = array("ftp");
68
+
69
+        // Config pages. Put here list of php page names stored in admmin directory used to setup module
70
+        $this->config_page_url = array('ftpclient.php@ftp');
71
+
72
+        // Dependencies
73
+        $this->depends = array();		// List of modules id that must be enabled if this module is enabled
74
+        $this->requiredby = array();	// List of modules id to disable if this one is disabled
75
+
76
+        // Constants
77
+        $this->const = array(
78
+            1=>array('FTP_CONNECT_WITH_SSL','chaine','0','Use FTPS for FTP module', 1, 'current', 1),
79
+            2=>array('FTP_CONNECT_WITH_SFTP','chaine','0','Use SFTP for FTP module', 1, 'current', 1)
80
+        );			// List of parameters
81
+
82
+        // Boxes
83
+        $this->boxes = array();			// List of boxes
84
+        $r=0;
85
+
86
+        // Add here list of php file(s) stored in core/boxes that contains class to show a box.
87
+        // Example:
88 88
         //$this->boxes[$r][1] = "myboxa.php";
89
-    	//$r++;
89
+        //$r++;
90 90
         //$this->boxes[$r][1] = "myboxb.php";
91
-    	//$r++;
92
-
93
-		// Permissions
94
-		$this->rights_class = 'ftp';	// Permission key
95
-		$this->rights = array();		// Permission array used by this module
96
-
97
-		$r++;
98
-		$this->rights[$r][0] = 2801;
99
-		$this->rights[$r][1] = 'Use FTP client in read mode (browse and download only)';
100
-		$this->rights[$r][2] = 'r';
101
-		$this->rights[$r][3] = 0;
102
-		$this->rights[$r][4] = 'read';
103
-
104
-		$r++;
105
-		$this->rights[$r][0] = 2802;
106
-		$this->rights[$r][1] = 'Use FTP client in write mode (delete or upload files)';
107
-		$this->rights[$r][2] = 'w';
108
-		$this->rights[$r][3] = 0;
109
-		$this->rights[$r][4] = 'write';
110
-
111
-
112
-		// Menus
113
-		//-------
114
-		$this->menu[$r]=array('fk_menu'=>0,
115
-							  'type'=>'top',
116
-							  'titre'=>'FTP',
117
-							  'mainmenu'=>'ftp',
118
-							  'url'=>'/ftp/index.php',
119
-							  'langs'=>'ftp',
120
-							  'position'=>100,
121
-                              'enabled'=>'$conf->ftp->enabled',
122
-		                      'perms'=>'$user->rights->ftp->read || $user->rights->ftp->write || $user->rights->ftp->setup',
123
-							  'target'=>'',
124
-							  'user'=>2);			// 0=Menu for internal users, 1=external users, 2=both
125
-		$r++;
126
-	}
91
+        //$r++;
92
+
93
+        // Permissions
94
+        $this->rights_class = 'ftp';	// Permission key
95
+        $this->rights = array();		// Permission array used by this module
96
+
97
+        $r++;
98
+        $this->rights[$r][0] = 2801;
99
+        $this->rights[$r][1] = 'Use FTP client in read mode (browse and download only)';
100
+        $this->rights[$r][2] = 'r';
101
+        $this->rights[$r][3] = 0;
102
+        $this->rights[$r][4] = 'read';
103
+
104
+        $r++;
105
+        $this->rights[$r][0] = 2802;
106
+        $this->rights[$r][1] = 'Use FTP client in write mode (delete or upload files)';
107
+        $this->rights[$r][2] = 'w';
108
+        $this->rights[$r][3] = 0;
109
+        $this->rights[$r][4] = 'write';
110
+
111
+
112
+        // Menus
113
+        //-------
114
+        $this->menu[$r]=array('fk_menu'=>0,
115
+                                'type'=>'top',
116
+                                'titre'=>'FTP',
117
+                                'mainmenu'=>'ftp',
118
+                                'url'=>'/ftp/index.php',
119
+                                'langs'=>'ftp',
120
+                                'position'=>100,
121
+                                'enabled'=>'$conf->ftp->enabled',
122
+                                'perms'=>'$user->rights->ftp->read || $user->rights->ftp->write || $user->rights->ftp->setup',
123
+                                'target'=>'',
124
+                                'user'=>2);			// 0=Menu for internal users, 1=external users, 2=both
125
+        $r++;
126
+    }
127 127
 }
128 128
 
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *      \brief      Description and activation file for module FTP
25 25
  */
26 26
 
27
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
27
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
28 28
 
29 29
 
30 30
 /**
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		// It is used to sort modules in module setup page
51 51
 		$this->family = "interface";
52 52
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
-		$this->name = preg_replace('/^mod/i','',get_class($this));
53
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
54 54
 		// Module description used if translation string 'ModuleXXXDesc' not found (XXX is id value)
55 55
 		$this->description = "FTP Client";
56 56
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		// Key used in llx_const table to save module status enabled/disabled (XXX is id value)
59 59
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60 60
 		// Name of png file (without png) used for this module
61
-		$this->picto='dir';
61
+		$this->picto = 'dir';
62 62
 
63 63
 		// Data directories to create when module is enabled
64 64
 		$this->dirs = array("/ftp/temp");
@@ -70,18 +70,18 @@  discard block
 block discarded – undo
70 70
 		$this->config_page_url = array('ftpclient.php@ftp');
71 71
 
72 72
 		// Dependencies
73
-		$this->depends = array();		// List of modules id that must be enabled if this module is enabled
74
-		$this->requiredby = array();	// List of modules id to disable if this one is disabled
73
+		$this->depends = array(); // List of modules id that must be enabled if this module is enabled
74
+		$this->requiredby = array(); // List of modules id to disable if this one is disabled
75 75
 
76 76
 		// Constants
77 77
 		$this->const = array(
78
-		    1=>array('FTP_CONNECT_WITH_SSL','chaine','0','Use FTPS for FTP module', 1, 'current', 1),
79
-		    2=>array('FTP_CONNECT_WITH_SFTP','chaine','0','Use SFTP for FTP module', 1, 'current', 1)
80
-		);			// List of parameters
78
+		    1=>array('FTP_CONNECT_WITH_SSL', 'chaine', '0', 'Use FTPS for FTP module', 1, 'current', 1),
79
+		    2=>array('FTP_CONNECT_WITH_SFTP', 'chaine', '0', 'Use SFTP for FTP module', 1, 'current', 1)
80
+		); // List of parameters
81 81
 
82 82
 		// Boxes
83
-		$this->boxes = array();			// List of boxes
84
-		$r=0;
83
+		$this->boxes = array(); // List of boxes
84
+		$r = 0;
85 85
 
86 86
 		// Add here list of php file(s) stored in core/boxes that contains class to show a box.
87 87
 		// Example:
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
     	//$r++;
92 92
 
93 93
 		// Permissions
94
-		$this->rights_class = 'ftp';	// Permission key
95
-		$this->rights = array();		// Permission array used by this module
94
+		$this->rights_class = 'ftp'; // Permission key
95
+		$this->rights = array(); // Permission array used by this module
96 96
 
97 97
 		$r++;
98 98
 		$this->rights[$r][0] = 2801;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 
112 112
 		// Menus
113 113
 		//-------
114
-		$this->menu[$r]=array('fk_menu'=>0,
114
+		$this->menu[$r] = array('fk_menu'=>0,
115 115
 							  'type'=>'top',
116 116
 							  'titre'=>'FTP',
117 117
 							  'mainmenu'=>'ftp',
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                               'enabled'=>'$conf->ftp->enabled',
122 122
 		                      'perms'=>'$user->rights->ftp->read || $user->rights->ftp->write || $user->rights->ftp->setup',
123 123
 							  'target'=>'',
124
-							  'user'=>2);			// 0=Menu for internal users, 1=external users, 2=both
124
+							  'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
125 125
 		$r++;
126 126
 	}
127 127
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php 3 patches
Indentation   +910 added lines, -910 removed lines patch added patch discarded remove patch
@@ -51,154 +51,154 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public $description;
53 53
 
54
-	/**
54
+    /**
55 55
      * @var string document type
56 56
      */
57 57
     public $type;
58 58
 
59
-	/**
59
+    /**
60 60
      * @var array() Minimum version of PHP required by module.
61
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
61
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
62 62
      */
63
-	public $phpmin = array(5, 4);
63
+    public $phpmin = array(5, 4);
64 64
 
65
-	/**
65
+    /**
66 66
      * Dolibarr version of the loaded document
67 67
      * @public string
68 68
      */
69
-	public $version = 'dolibarr';
69
+    public $version = 'dolibarr';
70 70
 
71
-	/**
71
+    /**
72 72
      * @var int page_largeur
73 73
      */
74 74
     public $page_largeur;
75 75
 
76
-	/**
76
+    /**
77 77
      * @var int page_hauteur
78 78
      */
79 79
     public $page_hauteur;
80 80
 
81
-	/**
81
+    /**
82 82
      * @var array format
83 83
      */
84 84
     public $format;
85 85
 
86
-	/**
86
+    /**
87 87
      * @var int marge_gauche
88 88
      */
89
-	public $marge_gauche;
89
+    public $marge_gauche;
90 90
 
91
-	/**
91
+    /**
92 92
      * @var int marge_droite
93 93
      */
94
-	public $marge_droite;
94
+    public $marge_droite;
95 95
 
96
-	/**
96
+    /**
97 97
      * @var int marge_haute
98 98
      */
99
-	public $marge_haute;
99
+    public $marge_haute;
100 100
 
101
-	/**
101
+    /**
102 102
      * @var int marge_basse
103 103
      */
104
-	public $marge_basse;
105
-
106
-	/**
107
-	 * Issuer
108
-	 * @var Company object that emits
109
-	 */
110
-	public $emetteur;
111
-
112
-
113
-	/**
114
-	 *	Constructor
115
-	 *
116
-	 *	@param	DoliDB	$db		Database handler
117
-	 */
118
-	function __construct($db=0)
119
-	{
120
-		global $conf,$langs,$mysoc;
121
-
122
-		$this->db = $db;
123
-		$this->name = "rouget";
124
-		$this->description = $langs->trans("DocumentModelStandardPDF");
125
-
126
-		$this->type = 'pdf';
127
-		$formatarray=pdf_getFormat();
128
-		$this->page_largeur = $formatarray['width'];
129
-		$this->page_hauteur = $formatarray['height'];
130
-		$this->format = array($this->page_largeur,$this->page_hauteur);
131
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
132
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
133
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
134
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
135
-
136
-		$this->option_logo = 1;
137
-
138
-		// Get source company
139
-		$this->emetteur=$mysoc;
140
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
141
-
142
-		// Define position of columns
143
-		$this->posxdesc=$this->marge_gauche+1;
144
-		$this->posxweightvol=$this->page_largeur - $this->marge_droite - 78;
145
-		$this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56;
146
-		$this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28;
147
-		$this->posxpuht=$this->page_largeur - $this->marge_droite;
148
-
149
-		if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) {	// Show also the prices
150
-			$this->posxweightvol=$this->page_largeur - $this->marge_droite - 118;
151
-			$this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96;
152
-			$this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68;
153
-			$this->posxpuht=$this->page_largeur - $this->marge_droite - 40;
154
-			$this->posxtotalht=$this->page_largeur - $this->marge_droite - 20;
155
-		}
156
-
157
-		$this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
158
-
159
-		if ($this->page_largeur < 210) // To work with US executive format
160
-		{
161
-		    $this->posxweightvol-=20;
162
-		    $this->posxpicture-=20;
163
-		    $this->posxqtyordered-=20;
164
-		    $this->posxqtytoship-=20;
165
-		}
104
+    public $marge_basse;
166 105
 
167
-		if (! empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
168
-		{
169
-		    $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
170
-		    $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
171
-		    $this->posxqtyordered = $this->posxqtytoship;
172
-		}
173
-	}
174
-
175
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
176
-	/**
177
-	 *	Function to build pdf onto disk
178
-	 *
179
-	 *	@param		Object		$object			Object expedition to generate (or id if old method)
180
-	 *	@param		Translate	$outputlangs		Lang output object
106
+    /**
107
+     * Issuer
108
+     * @var Company object that emits
109
+     */
110
+    public $emetteur;
111
+
112
+
113
+    /**
114
+     *	Constructor
115
+     *
116
+     *	@param	DoliDB	$db		Database handler
117
+     */
118
+    function __construct($db=0)
119
+    {
120
+        global $conf,$langs,$mysoc;
121
+
122
+        $this->db = $db;
123
+        $this->name = "rouget";
124
+        $this->description = $langs->trans("DocumentModelStandardPDF");
125
+
126
+        $this->type = 'pdf';
127
+        $formatarray=pdf_getFormat();
128
+        $this->page_largeur = $formatarray['width'];
129
+        $this->page_hauteur = $formatarray['height'];
130
+        $this->format = array($this->page_largeur,$this->page_hauteur);
131
+        $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
132
+        $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
133
+        $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
134
+        $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
135
+
136
+        $this->option_logo = 1;
137
+
138
+        // Get source company
139
+        $this->emetteur=$mysoc;
140
+        if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
141
+
142
+        // Define position of columns
143
+        $this->posxdesc=$this->marge_gauche+1;
144
+        $this->posxweightvol=$this->page_largeur - $this->marge_droite - 78;
145
+        $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56;
146
+        $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28;
147
+        $this->posxpuht=$this->page_largeur - $this->marge_droite;
148
+
149
+        if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) {	// Show also the prices
150
+            $this->posxweightvol=$this->page_largeur - $this->marge_droite - 118;
151
+            $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96;
152
+            $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68;
153
+            $this->posxpuht=$this->page_largeur - $this->marge_droite - 40;
154
+            $this->posxtotalht=$this->page_largeur - $this->marge_droite - 20;
155
+        }
156
+
157
+        $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
158
+
159
+        if ($this->page_largeur < 210) // To work with US executive format
160
+        {
161
+            $this->posxweightvol-=20;
162
+            $this->posxpicture-=20;
163
+            $this->posxqtyordered-=20;
164
+            $this->posxqtytoship-=20;
165
+        }
166
+
167
+        if (! empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
168
+        {
169
+            $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
170
+            $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
171
+            $this->posxqtyordered = $this->posxqtytoship;
172
+        }
173
+    }
174
+
175
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
176
+    /**
177
+     *	Function to build pdf onto disk
178
+     *
179
+     *	@param		Object		$object			Object expedition to generate (or id if old method)
180
+     *	@param		Translate	$outputlangs		Lang output object
181 181
      *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
182 182
      *  @param		int			$hidedetails		Do not show line details
183 183
      *  @param		int			$hidedesc			Do not show desc
184 184
      *  @param		int			$hideref			Do not show ref
185 185
      *  @return     int         	    			1=OK, 0=KO
186
-	 */
187
-	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
188
-	{
189
-		// phpcs:enable
190
-		global $user,$conf,$langs,$hookmanager;
186
+     */
187
+    function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
188
+    {
189
+        // phpcs:enable
190
+        global $user,$conf,$langs,$hookmanager;
191 191
 
192
-		$object->fetch_thirdparty();
192
+        $object->fetch_thirdparty();
193 193
 
194
-		if (! is_object($outputlangs)) $outputlangs=$langs;
195
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
196
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
194
+        if (! is_object($outputlangs)) $outputlangs=$langs;
195
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
196
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
197 197
 
198
-		// Load traductions files requiredby by page
199
-		$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
198
+        // Load traductions files requiredby by page
199
+        $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
200 200
 
201
-		$nblignes = count($object->lines);
201
+        $nblignes = count($object->lines);
202 202
 
203 203
         // Loop on each lines to detect if there is at least one image to show
204 204
         $realpatharray=array();
@@ -210,13 +210,13 @@  discard block
 block discarded – undo
210 210
             {
211 211
                 if (empty($object->lines[$i]->fk_product)) continue;
212 212
 
213
-				$objphoto = new Product($this->db);
214
-				$objphoto->fetch($object->lines[$i]->fk_product);
213
+                $objphoto = new Product($this->db);
214
+                $objphoto->fetch($object->lines[$i]->fk_product);
215 215
 
216
-				$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
217
-				$dir = $conf->product->dir_output.'/'.$pdir;
216
+                $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
217
+                $dir = $conf->product->dir_output.'/'.$pdir;
218 218
 
219
-				$realpath='';
219
+                $realpath='';
220 220
 
221 221
                 foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
222 222
                         {
@@ -246,52 +246,52 @@  discard block
 block discarded – undo
246 246
 
247 247
         if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol;
248 248
 
249
-		if ($conf->expedition->dir_output)
250
-		{
251
-			// Definition de $dir et $file
252
-			if ($object->specimen)
253
-			{
254
-				$dir = $conf->expedition->dir_output."/sending";
255
-				$file = $dir . "/SPECIMEN.pdf";
256
-			}
257
-			else
258
-			{
259
-				$expref = dol_sanitizeFileName($object->ref);
260
-				$dir = $conf->expedition->dir_output."/sending/" . $expref;
261
-				$file = $dir . "/" . $expref . ".pdf";
262
-			}
263
-
264
-			if (! file_exists($dir))
265
-			{
266
-				if (dol_mkdir($dir) < 0)
267
-				{
268
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
269
-					return 0;
270
-				}
271
-			}
272
-
273
-			if (file_exists($dir))
274
-			{
275
-				// Add pdfgeneration hook
276
-				if (! is_object($hookmanager))
277
-				{
278
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
279
-					$hookmanager=new HookManager($this->db);
280
-				}
281
-				$hookmanager->initHooks(array('pdfgeneration'));
282
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
283
-				global $action;
284
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
285
-
286
-				// Set nblignes with the new facture lines content after hook
287
-				$nblignes = count($object->lines);
288
-
289
-				$pdf=pdf_getInstance($this->format);
290
-				$default_font_size = pdf_getPDFFontSize($outputlangs);
291
-				$heightforinfotot = 8;	// Height reserved to output the info and total part
292
-		        $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
293
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
294
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
249
+        if ($conf->expedition->dir_output)
250
+        {
251
+            // Definition de $dir et $file
252
+            if ($object->specimen)
253
+            {
254
+                $dir = $conf->expedition->dir_output."/sending";
255
+                $file = $dir . "/SPECIMEN.pdf";
256
+            }
257
+            else
258
+            {
259
+                $expref = dol_sanitizeFileName($object->ref);
260
+                $dir = $conf->expedition->dir_output."/sending/" . $expref;
261
+                $file = $dir . "/" . $expref . ".pdf";
262
+            }
263
+
264
+            if (! file_exists($dir))
265
+            {
266
+                if (dol_mkdir($dir) < 0)
267
+                {
268
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
269
+                    return 0;
270
+                }
271
+            }
272
+
273
+            if (file_exists($dir))
274
+            {
275
+                // Add pdfgeneration hook
276
+                if (! is_object($hookmanager))
277
+                {
278
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
279
+                    $hookmanager=new HookManager($this->db);
280
+                }
281
+                $hookmanager->initHooks(array('pdfgeneration'));
282
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
283
+                global $action;
284
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
285
+
286
+                // Set nblignes with the new facture lines content after hook
287
+                $nblignes = count($object->lines);
288
+
289
+                $pdf=pdf_getInstance($this->format);
290
+                $default_font_size = pdf_getPDFFontSize($outputlangs);
291
+                $heightforinfotot = 8;	// Height reserved to output the info and total part
292
+                $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
293
+                $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
294
+                if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
295 295
                 $pdf->SetAutoPageBreak(1,0);
296 296
 
297 297
                 if (class_exists('TCPDF'))
@@ -307,814 +307,814 @@  discard block
 block discarded – undo
307 307
                     $tplidx = $pdf->importPage(1);
308 308
                 }
309 309
 
310
-				$pdf->Open();
311
-				$pagenb=0;
312
-				$pdf->SetDrawColor(128,128,128);
313
-
314
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
315
-
316
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
317
-				$pdf->SetSubject($outputlangs->transnoentities("Shipment"));
318
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
319
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
320
-				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
321
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
322
-
323
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
324
-
325
-				// New page
326
-				$pdf->AddPage();
327
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
328
-				$pagenb++;
329
-				$this->_pagehead($pdf, $object, 1, $outputlangs);
330
-				$pdf->SetFont('','', $default_font_size - 1);
331
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
332
-				$pdf->SetTextColor(0,0,0);
333
-
334
-				$tab_top = 90;
335
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
336
-				$tab_height = 130;
337
-				$tab_height_newpage = 150;
338
-
339
-				// Incoterm
340
-				$height_incoterms = 0;
341
-				if ($conf->incoterm->enabled)
342
-				{
343
-					$desc_incoterms = $object->getIncotermsForPDF();
344
-					if ($desc_incoterms)
345
-					{
346
-						$tab_top = 88;
347
-
348
-						$pdf->SetFont('','', $default_font_size - 1);
349
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
350
-						$nexY = $pdf->GetY();
351
-						$height_incoterms=$nexY-$tab_top;
352
-
353
-						// Rect prend une longueur en 3eme param
354
-						$pdf->SetDrawColor(192,192,192);
355
-						$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
356
-
357
-						$tab_top = $nexY+6;
358
-						$height_incoterms += 4;
359
-					}
360
-				}
361
-
362
-				if (! empty($object->note_public) || ! empty($object->tracking_number))
363
-				{
364
-					$tab_top = 88 + $height_incoterms;
365
-					$tab_top_alt = $tab_top;
366
-
367
-					$pdf->SetFont('','B', $default_font_size - 2);
368
-					$pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, 0, 1, false, true, 'L');
369
-
370
-					$tab_top_alt = $pdf->GetY();
371
-					//$tab_top_alt += 1;
372
-
373
-					// Tracking number
374
-					if (! empty($object->tracking_number))
375
-					{
376
-						$object->getUrlTrackingStatus($object->tracking_number);
377
-						if (! empty($object->tracking_url))
378
-						{
379
-							if ($object->shipping_method_id > 0)
380
-							{
381
-								// Get code using getLabelFromKey
382
-								$code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code');
383
-								$label='';
384
-								if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>";
385
-								$label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
386
-								//var_dump($object->tracking_url != $object->tracking_number);exit;
387
-								if ($object->tracking_url != $object->tracking_number)
388
-								{
389
-									$label.=" : ";
390
-									$label.=$object->tracking_url;
391
-								}
392
-								$pdf->SetFont('','B', $default_font_size - 2);
393
-								$pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top_alt, $label, 0, 1, false, true, 'L');
394
-
395
-								$tab_top_alt = $pdf->GetY();
396
-							}
397
-						}
398
-					}
399
-
400
-					// Notes
401
-					if (! empty($object->note_public))
402
-					{
403
-						$pdf->SetFont('','', $default_font_size - 1);   // Dans boucle pour gerer multi-page
404
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1);
405
-					}
406
-
407
-					$nexY = $pdf->GetY();
408
-					$height_note=$nexY-$tab_top;
409
-
410
-					// Rect prend une longueur en 3eme param
411
-					$pdf->SetDrawColor(192,192,192);
412
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
413
-
414
-					$tab_height = $tab_height - $height_note;
415
-					$tab_top = $nexY+6;
416
-				}
417
-				else
418
-				{
419
-					$height_note=0;
420
-				}
421
-
422
-				$iniY = $tab_top + 7;
423
-				$curY = $tab_top + 7;
424
-				$nexY = $tab_top + 7;
425
-
426
-				// Loop on each lines
427
-				for ($i = 0; $i < $nblignes; $i++)
428
-				{
429
-					$curY = $nexY;
430
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
431
-					$pdf->SetTextColor(0,0,0);
432
-
433
-					// Define size of image if we need it
434
-					$imglinesize=array();
435
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
436
-
437
-					$pdf->setTopMargin($tab_top_newpage);
438
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
439
-					$pageposbefore=$pdf->getPage();
440
-
441
-					$showpricebeforepagebreak=1;
442
-					$posYAfterImage=0;
443
-					$posYAfterDescription=0;
444
-
445
-					// We start with Photo of product line
446
-					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
447
-					{
448
-						$pdf->AddPage('','',true);
449
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
450
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
451
-						$pdf->setPage($pageposbefore+1);
452
-
453
-						$curY = $tab_top_newpage;
454
-						$showpricebeforepagebreak=0;
455
-					}
456
-
457
-					if (isset($imglinesize['width']) && isset($imglinesize['height']))
458
-					{
459
-						$curX = $this->posxpicture-1;
460
-						$pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
461
-						// $pdf->Image does not increase value return by getY, so we save it manually
462
-						$posYAfterImage=$curY+$imglinesize['height'];
463
-					}
464
-
465
-					// Description of product line
466
-					$curX = $this->posxdesc-1;
467
-
468
-					$pdf->startTransaction();
469
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
470
-
471
-					$pageposafter=$pdf->getPage();
472
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
473
-					{
474
-						$pdf->rollbackTransaction(true);
475
-						$pageposafter=$pageposbefore;
476
-						//print $pageposafter.'-'.$pageposbefore;exit;
477
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
478
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
479
-
480
-						$pageposafter=$pdf->getPage();
481
-						$posyafter=$pdf->GetY();
482
-						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
483
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
484
-						{
485
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
486
-							{
487
-								$pdf->AddPage('','',true);
488
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
489
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
490
-								$pdf->setPage($pageposafter+1);
491
-							}
492
-						}
493
-						else
494
-						{
495
-							// We found a page break
496
-							$showpricebeforepagebreak=0;
497
-						}
498
-					}
499
-					else	// No pagebreak
500
-					{
501
-						$pdf->commitTransaction();
502
-					}
503
-					$posYAfterDescription=$pdf->GetY();
504
-
505
-					$nexY = $pdf->GetY();
506
-					$pageposafter=$pdf->getPage();
507
-
508
-					$pdf->setPage($pageposbefore);
509
-					$pdf->setTopMargin($this->marge_haute);
510
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
511
-
512
-					// We suppose that a too long description or photo were moved completely on next page
513
-					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
514
-						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
515
-					}
516
-
517
-					// We suppose that a too long description is moved completely on next page
518
-					if ($pageposafter > $pageposbefore) {
519
-						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
520
-					}
521
-
522
-					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
523
-
524
-					$pdf->SetXY($this->posxweightvol, $curY);
525
-					$weighttxt='';
526
-					if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight)
527
-					{
528
-					    $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units,"weight");
529
-					}
530
-					$voltxt='';
531
-					if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume)
532
-					{
533
-					    $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0,"volume");
534
-					}
535
-
536
-					if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME))
537
-					{
538
-						$pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt, 0, 0, false, true, 'C');
539
-						//$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C');
540
-					}
541
-
542
-					if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
543
-					{
544
-					   $pdf->SetXY($this->posxqtyordered, $curY);
545
-					   $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C');
546
-					}
547
-
548
-					if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP))
549
-					{
550
-						$pdf->SetXY($this->posxqtytoship, $curY);
551
-						$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped,'','C');
552
-					}
553
-
554
-					if(!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT))
555
-					{
556
-						$pdf->SetXY($this->posxpuht, $curY);
557
-						$pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R');
558
-
559
-						$pdf->SetXY($this->posxtotalht, $curY);
560
-						$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs),'','R');
561
-					}
562
-
563
-					$nexY+=3;
564
-					if ($weighttxt && $voltxt) $nexY+=2;
565
-
566
-					// Add line
567
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
568
-					{
569
-						$pdf->setPage($pageposafter);
570
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
571
-						//$pdf->SetDrawColor(190,190,200);
572
-						$pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1);
573
-						$pdf->SetLineStyle(array('dash'=>0));
574
-					}
575
-
576
-					// Detect if some page were added automatically and output _tableau for past pages
577
-					while ($pagenb < $pageposafter)
578
-					{
579
-						$pdf->setPage($pagenb);
580
-						if ($pagenb == 1)
581
-						{
582
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
583
-						}
584
-						else
585
-						{
586
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
587
-						}
588
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
589
-						$pagenb++;
590
-						$pdf->setPage($pagenb);
591
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
592
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
593
-					}
594
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
595
-					{
596
-						if ($pagenb == 1)
597
-						{
598
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
599
-						}
600
-						else
601
-						{
602
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
603
-						}
604
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
605
-						// New page
606
-						$pdf->AddPage();
607
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
608
-						$pagenb++;
609
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
610
-					}
611
-				}
612
-
613
-				// Show square
614
-				if ($pagenb == 1)
615
-				{
616
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
617
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
618
-				}
619
-				else
620
-				{
621
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
622
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
623
-				}
624
-
625
-				// Affiche zone totaux
626
-				$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
627
-
628
-				// Pied de page
629
-				$this->_pagefoot($pdf,$object,$outputlangs);
630
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
631
-
632
-				$pdf->Close();
633
-
634
-				$pdf->Output($file,'F');
635
-
636
-				// Add pdfgeneration hook
637
-				$hookmanager->initHooks(array('pdfgeneration'));
638
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
639
-				global $action;
640
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
641
-
642
-				if (! empty($conf->global->MAIN_UMASK))
643
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
644
-
645
-				$this->result = array('fullpath'=>$file);
646
-
647
-				return 1;	// No error
648
-			}
649
-			else
650
-			{
651
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
652
-				return 0;
653
-			}
654
-		}
655
-		else
656
-		{
657
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
658
-			return 0;
659
-		}
660
-	}
661
-
662
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
663
-	/**
664
-	 *	Show total to pay
665
-	 *
666
-	 *	@param	PDF			$pdf           Object PDF
667
-	 *	@param  Facture		$object         Object invoice
668
-	 *	@param  int			$deja_regle     Montant deja regle
669
-	 *	@param	int			$posy			Position depart
670
-	 *	@param	Translate	$outputlangs	Objet langs
671
-	 *	@return int							Position pour suite
672
-	 */
673
-	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
674
-	{
675
-		// phpcs:enable
676
-		global $conf,$mysoc;
310
+                $pdf->Open();
311
+                $pagenb=0;
312
+                $pdf->SetDrawColor(128,128,128);
313
+
314
+                if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
315
+
316
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
317
+                $pdf->SetSubject($outputlangs->transnoentities("Shipment"));
318
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
319
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
320
+                $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
321
+                if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
322
+
323
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
324
+
325
+                // New page
326
+                $pdf->AddPage();
327
+                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
328
+                $pagenb++;
329
+                $this->_pagehead($pdf, $object, 1, $outputlangs);
330
+                $pdf->SetFont('','', $default_font_size - 1);
331
+                $pdf->MultiCell(0, 3, '');		// Set interline to 3
332
+                $pdf->SetTextColor(0,0,0);
333
+
334
+                $tab_top = 90;
335
+                $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
336
+                $tab_height = 130;
337
+                $tab_height_newpage = 150;
338
+
339
+                // Incoterm
340
+                $height_incoterms = 0;
341
+                if ($conf->incoterm->enabled)
342
+                {
343
+                    $desc_incoterms = $object->getIncotermsForPDF();
344
+                    if ($desc_incoterms)
345
+                    {
346
+                        $tab_top = 88;
347
+
348
+                        $pdf->SetFont('','', $default_font_size - 1);
349
+                        $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
350
+                        $nexY = $pdf->GetY();
351
+                        $height_incoterms=$nexY-$tab_top;
352
+
353
+                        // Rect prend une longueur en 3eme param
354
+                        $pdf->SetDrawColor(192,192,192);
355
+                        $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
356
+
357
+                        $tab_top = $nexY+6;
358
+                        $height_incoterms += 4;
359
+                    }
360
+                }
361
+
362
+                if (! empty($object->note_public) || ! empty($object->tracking_number))
363
+                {
364
+                    $tab_top = 88 + $height_incoterms;
365
+                    $tab_top_alt = $tab_top;
366
+
367
+                    $pdf->SetFont('','B', $default_font_size - 2);
368
+                    $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, 0, 1, false, true, 'L');
369
+
370
+                    $tab_top_alt = $pdf->GetY();
371
+                    //$tab_top_alt += 1;
372
+
373
+                    // Tracking number
374
+                    if (! empty($object->tracking_number))
375
+                    {
376
+                        $object->getUrlTrackingStatus($object->tracking_number);
377
+                        if (! empty($object->tracking_url))
378
+                        {
379
+                            if ($object->shipping_method_id > 0)
380
+                            {
381
+                                // Get code using getLabelFromKey
382
+                                $code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code');
383
+                                $label='';
384
+                                if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>";
385
+                                $label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
386
+                                //var_dump($object->tracking_url != $object->tracking_number);exit;
387
+                                if ($object->tracking_url != $object->tracking_number)
388
+                                {
389
+                                    $label.=" : ";
390
+                                    $label.=$object->tracking_url;
391
+                                }
392
+                                $pdf->SetFont('','B', $default_font_size - 2);
393
+                                $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top_alt, $label, 0, 1, false, true, 'L');
394
+
395
+                                $tab_top_alt = $pdf->GetY();
396
+                            }
397
+                        }
398
+                    }
399
+
400
+                    // Notes
401
+                    if (! empty($object->note_public))
402
+                    {
403
+                        $pdf->SetFont('','', $default_font_size - 1);   // Dans boucle pour gerer multi-page
404
+                        $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1);
405
+                    }
406
+
407
+                    $nexY = $pdf->GetY();
408
+                    $height_note=$nexY-$tab_top;
409
+
410
+                    // Rect prend une longueur en 3eme param
411
+                    $pdf->SetDrawColor(192,192,192);
412
+                    $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
413
+
414
+                    $tab_height = $tab_height - $height_note;
415
+                    $tab_top = $nexY+6;
416
+                }
417
+                else
418
+                {
419
+                    $height_note=0;
420
+                }
421
+
422
+                $iniY = $tab_top + 7;
423
+                $curY = $tab_top + 7;
424
+                $nexY = $tab_top + 7;
425
+
426
+                // Loop on each lines
427
+                for ($i = 0; $i < $nblignes; $i++)
428
+                {
429
+                    $curY = $nexY;
430
+                    $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
431
+                    $pdf->SetTextColor(0,0,0);
432
+
433
+                    // Define size of image if we need it
434
+                    $imglinesize=array();
435
+                    if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
436
+
437
+                    $pdf->setTopMargin($tab_top_newpage);
438
+                    $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
439
+                    $pageposbefore=$pdf->getPage();
440
+
441
+                    $showpricebeforepagebreak=1;
442
+                    $posYAfterImage=0;
443
+                    $posYAfterDescription=0;
444
+
445
+                    // We start with Photo of product line
446
+                    if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
447
+                    {
448
+                        $pdf->AddPage('','',true);
449
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
450
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
451
+                        $pdf->setPage($pageposbefore+1);
452
+
453
+                        $curY = $tab_top_newpage;
454
+                        $showpricebeforepagebreak=0;
455
+                    }
456
+
457
+                    if (isset($imglinesize['width']) && isset($imglinesize['height']))
458
+                    {
459
+                        $curX = $this->posxpicture-1;
460
+                        $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
461
+                        // $pdf->Image does not increase value return by getY, so we save it manually
462
+                        $posYAfterImage=$curY+$imglinesize['height'];
463
+                    }
464
+
465
+                    // Description of product line
466
+                    $curX = $this->posxdesc-1;
467
+
468
+                    $pdf->startTransaction();
469
+                    pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
470
+
471
+                    $pageposafter=$pdf->getPage();
472
+                    if ($pageposafter > $pageposbefore)	// There is a pagebreak
473
+                    {
474
+                        $pdf->rollbackTransaction(true);
475
+                        $pageposafter=$pageposbefore;
476
+                        //print $pageposafter.'-'.$pageposbefore;exit;
477
+                        $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
478
+                        pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
479
+
480
+                        $pageposafter=$pdf->getPage();
481
+                        $posyafter=$pdf->GetY();
482
+                        //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
483
+                        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
484
+                        {
485
+                            if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
486
+                            {
487
+                                $pdf->AddPage('','',true);
488
+                                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
489
+                                if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
490
+                                $pdf->setPage($pageposafter+1);
491
+                            }
492
+                        }
493
+                        else
494
+                        {
495
+                            // We found a page break
496
+                            $showpricebeforepagebreak=0;
497
+                        }
498
+                    }
499
+                    else	// No pagebreak
500
+                    {
501
+                        $pdf->commitTransaction();
502
+                    }
503
+                    $posYAfterDescription=$pdf->GetY();
504
+
505
+                    $nexY = $pdf->GetY();
506
+                    $pageposafter=$pdf->getPage();
507
+
508
+                    $pdf->setPage($pageposbefore);
509
+                    $pdf->setTopMargin($this->marge_haute);
510
+                    $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
511
+
512
+                    // We suppose that a too long description or photo were moved completely on next page
513
+                    if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
514
+                        $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
515
+                    }
516
+
517
+                    // We suppose that a too long description is moved completely on next page
518
+                    if ($pageposafter > $pageposbefore) {
519
+                        $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
520
+                    }
521
+
522
+                    $pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
523
+
524
+                    $pdf->SetXY($this->posxweightvol, $curY);
525
+                    $weighttxt='';
526
+                    if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight)
527
+                    {
528
+                        $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units,"weight");
529
+                    }
530
+                    $voltxt='';
531
+                    if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume)
532
+                    {
533
+                        $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0,"volume");
534
+                    }
535
+
536
+                    if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME))
537
+                    {
538
+                        $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt, 0, 0, false, true, 'C');
539
+                        //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C');
540
+                    }
541
+
542
+                    if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
543
+                    {
544
+                        $pdf->SetXY($this->posxqtyordered, $curY);
545
+                        $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C');
546
+                    }
547
+
548
+                    if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP))
549
+                    {
550
+                        $pdf->SetXY($this->posxqtytoship, $curY);
551
+                        $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped,'','C');
552
+                    }
553
+
554
+                    if(!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT))
555
+                    {
556
+                        $pdf->SetXY($this->posxpuht, $curY);
557
+                        $pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R');
558
+
559
+                        $pdf->SetXY($this->posxtotalht, $curY);
560
+                        $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs),'','R');
561
+                    }
562
+
563
+                    $nexY+=3;
564
+                    if ($weighttxt && $voltxt) $nexY+=2;
565
+
566
+                    // Add line
567
+                    if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
568
+                    {
569
+                        $pdf->setPage($pageposafter);
570
+                        $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
571
+                        //$pdf->SetDrawColor(190,190,200);
572
+                        $pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1);
573
+                        $pdf->SetLineStyle(array('dash'=>0));
574
+                    }
575
+
576
+                    // Detect if some page were added automatically and output _tableau for past pages
577
+                    while ($pagenb < $pageposafter)
578
+                    {
579
+                        $pdf->setPage($pagenb);
580
+                        if ($pagenb == 1)
581
+                        {
582
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
583
+                        }
584
+                        else
585
+                        {
586
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
587
+                        }
588
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
589
+                        $pagenb++;
590
+                        $pdf->setPage($pagenb);
591
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
592
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
593
+                    }
594
+                    if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
595
+                    {
596
+                        if ($pagenb == 1)
597
+                        {
598
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
599
+                        }
600
+                        else
601
+                        {
602
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
603
+                        }
604
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
605
+                        // New page
606
+                        $pdf->AddPage();
607
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
608
+                        $pagenb++;
609
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
610
+                    }
611
+                }
612
+
613
+                // Show square
614
+                if ($pagenb == 1)
615
+                {
616
+                    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
617
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
618
+                }
619
+                else
620
+                {
621
+                    $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
622
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
623
+                }
624
+
625
+                // Affiche zone totaux
626
+                $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
627
+
628
+                // Pied de page
629
+                $this->_pagefoot($pdf,$object,$outputlangs);
630
+                if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
631
+
632
+                $pdf->Close();
633
+
634
+                $pdf->Output($file,'F');
635
+
636
+                // Add pdfgeneration hook
637
+                $hookmanager->initHooks(array('pdfgeneration'));
638
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
639
+                global $action;
640
+                $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
641
+
642
+                if (! empty($conf->global->MAIN_UMASK))
643
+                @chmod($file, octdec($conf->global->MAIN_UMASK));
644
+
645
+                $this->result = array('fullpath'=>$file);
646
+
647
+                return 1;	// No error
648
+            }
649
+            else
650
+            {
651
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
652
+                return 0;
653
+            }
654
+        }
655
+        else
656
+        {
657
+            $this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
658
+            return 0;
659
+        }
660
+    }
661
+
662
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
663
+    /**
664
+     *	Show total to pay
665
+     *
666
+     *	@param	PDF			$pdf           Object PDF
667
+     *	@param  Facture		$object         Object invoice
668
+     *	@param  int			$deja_regle     Montant deja regle
669
+     *	@param	int			$posy			Position depart
670
+     *	@param	Translate	$outputlangs	Objet langs
671
+     *	@return int							Position pour suite
672
+     */
673
+    function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
674
+    {
675
+        // phpcs:enable
676
+        global $conf,$mysoc;
677 677
 
678 678
         $sign=1;
679 679
 
680 680
         $default_font_size = pdf_getPDFFontSize($outputlangs);
681 681
 
682
-		$tab2_top = $posy;
683
-		$tab2_hl = 4;
684
-		$pdf->SetFont('','B', $default_font_size - 1);
682
+        $tab2_top = $posy;
683
+        $tab2_hl = 4;
684
+        $pdf->SetFont('','B', $default_font_size - 1);
685 685
 
686
-		// Tableau total
687
-		$col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol;
688
-		/*if ($this->page_largeur < 210) // To work with US executive format
686
+        // Tableau total
687
+        $col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol;
688
+        /*if ($this->page_largeur < 210) // To work with US executive format
689 689
 		{
690 690
 			$col2x-=20;
691 691
 		}*/
692
-		if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
693
-		else $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
694
-
695
-		$useborder=0;
696
-		$index = 0;
697
-
698
-		$totalWeighttoshow='';
699
-		$totalVolumetoshow='';
700
-
701
-		// Load dim data
702
-		$tmparray=$object->getTotalWeightVolume();
703
-		$totalWeight=$tmparray['weight'];
704
-		$totalVolume=$tmparray['volume'];
705
-		$totalOrdered=$tmparray['ordered'];
706
-		$totalToShip=$tmparray['toship'];
707
-		// Set trueVolume and volume_units not currently stored into database
708
-		if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
709
-		{
710
-		    $object->trueVolume=price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
711
-		    $object->volume_units=$object->size_units * 3;
712
-		}
692
+        if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
693
+        else $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
694
+
695
+        $useborder=0;
696
+        $index = 0;
697
+
698
+        $totalWeighttoshow='';
699
+        $totalVolumetoshow='';
700
+
701
+        // Load dim data
702
+        $tmparray=$object->getTotalWeightVolume();
703
+        $totalWeight=$tmparray['weight'];
704
+        $totalVolume=$tmparray['volume'];
705
+        $totalOrdered=$tmparray['ordered'];
706
+        $totalToShip=$tmparray['toship'];
707
+        // Set trueVolume and volume_units not currently stored into database
708
+        if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
709
+        {
710
+            $object->trueVolume=price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
711
+            $object->volume_units=$object->size_units * 3;
712
+        }
713 713
 
714
-		if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
715
-		if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
716
-		if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
717
-		if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
714
+        if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
715
+        if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
716
+        if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
717
+        if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
718 718
 
719
-    	$pdf->SetFillColor(255,255,255);
720
-    	$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
721
-    	$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
719
+        $pdf->SetFillColor(255,255,255);
720
+        $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
721
+        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
722 722
 
723 723
         if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
724 724
         {
725 725
             $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
726
-        	$pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1);
726
+            $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1);
727 727
         }
728 728
 
729 729
         if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP))
730 730
         {
731
-        	$pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
732
-        	$pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
731
+            $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
732
+            $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
733 733
         }
734 734
 
735
-		if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT))
736
-		{
737
-	    	$pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
738
-	    	$pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
735
+        if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT))
736
+        {
737
+            $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
738
+            $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
739 739
 
740
-	    	$pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
741
-	    	$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1);
742
-		}
740
+            $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
741
+            $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1);
742
+        }
743 743
 
744
-		if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME))
745
-		{
746
-			// Total Weight
747
-			if ($totalWeighttoshow)
748
-			{
749
-	    		$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
750
-	    		$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
751
-
752
-	    		$index++;
753
-			}
754
-			if ($totalVolumetoshow)
755
-			{
756
-	    		$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
757
-	    		$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
758
-
759
-			    $index++;
760
-			}
761
-			if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++;
762
-		}
763
-
764
-		$pdf->SetTextColor(0,0,0);
765
-
766
-		return ($tab2_top + ($tab2_hl * $index));
767
-	}
768
-
769
-	/**
770
-	 *   Show table for lines
771
-	 *
772
-	 *   @param		PDF			$pdf     		Object PDF
773
-	 *   @param		string		$tab_top		Top position of table
774
-	 *   @param		string		$tab_height		Height of table (rectangle)
775
-	 *   @param		int			$nexY			Y
776
-	 *   @param		Translate	$outputlangs	Langs object
777
-	 *   @param		int			$hidetop		Hide top bar of array
778
-	 *   @param		int			$hidebottom		Hide bottom bar of array
779
-	 *   @return	void
780
-	 */
781
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
782
-	{
783
-		global $conf;
784
-
785
-		// Force to disable hidetop and hidebottom
786
-		$hidebottom=0;
787
-		if ($hidetop) $hidetop=-1;
788
-
789
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
790
-
791
-		// Amount in (at tab_top - 1)
792
-		$pdf->SetTextColor(0,0,0);
793
-		$pdf->SetFont('','',$default_font_size - 2);
794
-
795
-		// Output Rect
796
-		$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
797
-
798
-		$pdf->SetDrawColor(128,128,128);
799
-		$pdf->SetFont('','', $default_font_size - 1);
800
-
801
-		if (empty($hidetop))
802
-		{
803
-			$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);
744
+        if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME))
745
+        {
746
+            // Total Weight
747
+            if ($totalWeighttoshow)
748
+            {
749
+                $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
750
+                $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
804 751
 
805
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
806
-			$pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L');
807
-		}
752
+                $index++;
753
+            }
754
+            if ($totalVolumetoshow)
755
+            {
756
+                $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
757
+                $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
808 758
 
809
-		if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME))
810
-		{
811
-			$pdf->line($this->posxweightvol-1, $tab_top, $this->posxweightvol-1, $tab_top + $tab_height);
812
-			if (empty($hidetop))
813
-			{
814
-				$pdf->SetXY($this->posxweightvol-1, $tab_top+1);
815
-				$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C');
816
-			}
817
-		}
759
+                $index++;
760
+            }
761
+            if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++;
762
+        }
763
+
764
+        $pdf->SetTextColor(0,0,0);
765
+
766
+        return ($tab2_top + ($tab2_hl * $index));
767
+    }
768
+
769
+    /**
770
+     *   Show table for lines
771
+     *
772
+     *   @param		PDF			$pdf     		Object PDF
773
+     *   @param		string		$tab_top		Top position of table
774
+     *   @param		string		$tab_height		Height of table (rectangle)
775
+     *   @param		int			$nexY			Y
776
+     *   @param		Translate	$outputlangs	Langs object
777
+     *   @param		int			$hidetop		Hide top bar of array
778
+     *   @param		int			$hidebottom		Hide bottom bar of array
779
+     *   @return	void
780
+     */
781
+    function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
782
+    {
783
+        global $conf;
784
+
785
+        // Force to disable hidetop and hidebottom
786
+        $hidebottom=0;
787
+        if ($hidetop) $hidetop=-1;
788
+
789
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
790
+
791
+        // Amount in (at tab_top - 1)
792
+        $pdf->SetTextColor(0,0,0);
793
+        $pdf->SetFont('','',$default_font_size - 2);
794
+
795
+        // Output Rect
796
+        $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
797
+
798
+        $pdf->SetDrawColor(128,128,128);
799
+        $pdf->SetFont('','', $default_font_size - 1);
800
+
801
+        if (empty($hidetop))
802
+        {
803
+            $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);
804
+
805
+            $pdf->SetXY($this->posxdesc-1, $tab_top+1);
806
+            $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L');
807
+        }
808
+
809
+        if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME))
810
+        {
811
+            $pdf->line($this->posxweightvol-1, $tab_top, $this->posxweightvol-1, $tab_top + $tab_height);
812
+            if (empty($hidetop))
813
+            {
814
+                $pdf->SetXY($this->posxweightvol-1, $tab_top+1);
815
+                $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C');
816
+            }
817
+        }
818 818
 
819 819
         if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
820 820
         {
821 821
             $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height);
822
-    		if (empty($hidetop))
823
-    		{
824
-    			$pdf->SetXY($this->posxqtyordered-1, $tab_top+1);
825
-    			$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C');
826
-    		}
822
+            if (empty($hidetop))
823
+            {
824
+                $pdf->SetXY($this->posxqtyordered-1, $tab_top+1);
825
+                $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C');
826
+            }
827 827
         }
828 828
 
829 829
         if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP))
830 830
         {
831
-			$pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height);
832
-			if (empty($hidetop))
833
-			{
834
-				$pdf->SetXY($this->posxqtytoship, $tab_top+1);
835
-				$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"),'','C');
836
-			}
831
+            $pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height);
832
+            if (empty($hidetop))
833
+            {
834
+                $pdf->SetXY($this->posxqtytoship, $tab_top+1);
835
+                $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"),'','C');
836
+            }
837 837
         }
838 838
 
839
-		if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) {
840
-
841
-			$pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height);
842
-			if (empty($hidetop))
843
-			{
844
-				$pdf->SetXY($this->posxpuht-1, $tab_top+1);
845
-				$pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"),'','C');
846
-			}
847
-
848
-			$pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height);
849
-			if (empty($hidetop))
850
-			{
851
-				$pdf->SetXY($this->posxtotalht-1, $tab_top+1);
852
-				$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"),'','C');
853
-			}
854
-		}
855
-	}
856
-
857
-	/**
858
-	 *  Show top header of page.
859
-	 *
860
-	 *  @param	PDF			$pdf     		Object PDF
861
-	 *  @param  Object		$object     	Object to show
862
-	 *  @param  int	    	$showaddress    0=no, 1=yes
863
-	 *  @param  Translate	$outputlangs	Object lang for output
864
-	 *  @return	void
865
-	 */
866
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
867
-	{
868
-		global $conf,$langs,$mysoc;
869
-
870
-		$langs->load("orders");
871
-
872
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
873
-
874
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
875
-
876
-		// Show Draft Watermark
877
-		if($object->statut==0 && (! empty($conf->global->SHIPPING_DRAFT_WATERMARK)) )
878
-		{
879
-            		pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SHIPPING_DRAFT_WATERMARK);
880
-		}
839
+        if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) {
881 840
 
882
-		//Prepare la suite
883
-		$pdf->SetTextColor(0,0,60);
884
-		$pdf->SetFont('','B', $default_font_size + 3);
841
+            $pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height);
842
+            if (empty($hidetop))
843
+            {
844
+                $pdf->SetXY($this->posxpuht-1, $tab_top+1);
845
+                $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"),'','C');
846
+            }
885 847
 
886
-		$w = 110;
848
+            $pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height);
849
+            if (empty($hidetop))
850
+            {
851
+                $pdf->SetXY($this->posxtotalht-1, $tab_top+1);
852
+                $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"),'','C');
853
+            }
854
+        }
855
+    }
887 856
 
888
-		$posy=$this->marge_haute;
889
-		$posx=$this->page_largeur-$this->marge_droite-$w;
857
+    /**
858
+     *  Show top header of page.
859
+     *
860
+     *  @param	PDF			$pdf     		Object PDF
861
+     *  @param  Object		$object     	Object to show
862
+     *  @param  int	    	$showaddress    0=no, 1=yes
863
+     *  @param  Translate	$outputlangs	Object lang for output
864
+     *  @return	void
865
+     */
866
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
867
+    {
868
+        global $conf,$langs,$mysoc;
890 869
 
891
-		$pdf->SetXY($this->marge_gauche,$posy);
870
+        $langs->load("orders");
892 871
 
893
-		// Logo
894
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
895
-		if ($this->emetteur->logo)
896
-		{
897
-			if (is_readable($logo))
898
-			{
899
-			    $height=pdf_getHeightForLogo($logo);
900
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
901
-			}
902
-			else
903
-			{
904
-				$pdf->SetTextColor(200,0,0);
905
-				$pdf->SetFont('','B', $default_font_size - 2);
906
-				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
907
-				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
908
-			}
909
-		}
910
-		else
911
-		{
912
-			$text=$this->emetteur->name;
913
-			$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
914
-		}
872
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
915 873
 
916
-		// Show barcode
917
-		if (! empty($conf->barcode->enabled))
918
-		{
919
-			$posx=105;
920
-		}
921
-		else
922
-		{
923
-			$posx=$this->marge_gauche+3;
924
-		}
925
-		//$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
926
-		if (! empty($conf->barcode->enabled))
927
-		{
928
-			// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
929
-			//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
930
-			//$pdf->Image($logo,10, 5, 0, 24);
931
-		}
874
+        pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
932 875
 
933
-		$pdf->SetDrawColor(128,128,128);
934
-		if (! empty($conf->barcode->enabled))
935
-		{
936
-			// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
937
-			//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
938
-			//$pdf->Image($logo,10, 5, 0, 24);
939
-		}
876
+        // Show Draft Watermark
877
+        if($object->statut==0 && (! empty($conf->global->SHIPPING_DRAFT_WATERMARK)) )
878
+        {
879
+                    pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SHIPPING_DRAFT_WATERMARK);
880
+        }
881
+
882
+        //Prepare la suite
883
+        $pdf->SetTextColor(0,0,60);
884
+        $pdf->SetFont('','B', $default_font_size + 3);
885
+
886
+        $w = 110;
887
+
888
+        $posy=$this->marge_haute;
889
+        $posx=$this->page_largeur-$this->marge_droite-$w;
940 890
 
891
+        $pdf->SetXY($this->marge_gauche,$posy);
941 892
 
942
-		$posx=$this->page_largeur - $w - $this->marge_droite;
943
-		$posy=$this->marge_haute;
893
+        // Logo
894
+        $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
895
+        if ($this->emetteur->logo)
896
+        {
897
+            if (is_readable($logo))
898
+            {
899
+                $height=pdf_getHeightForLogo($logo);
900
+                $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
901
+            }
902
+            else
903
+            {
904
+                $pdf->SetTextColor(200,0,0);
905
+                $pdf->SetFont('','B', $default_font_size - 2);
906
+                $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
907
+                $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
908
+            }
909
+        }
910
+        else
911
+        {
912
+            $text=$this->emetteur->name;
913
+            $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
914
+        }
944 915
 
945
-		$pdf->SetFont('','B', $default_font_size + 2);
946
-		$pdf->SetXY($posx,$posy);
947
-		$pdf->SetTextColor(0,0,60);
948
-		$title=$outputlangs->transnoentities("SendingSheet");
949
-		$pdf->MultiCell($w, 4, $title, '', 'R');
916
+        // Show barcode
917
+        if (! empty($conf->barcode->enabled))
918
+        {
919
+            $posx=105;
920
+        }
921
+        else
922
+        {
923
+            $posx=$this->marge_gauche+3;
924
+        }
925
+        //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
926
+        if (! empty($conf->barcode->enabled))
927
+        {
928
+            // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
929
+            //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
930
+            //$pdf->Image($logo,10, 5, 0, 24);
931
+        }
950 932
 
951
-		$pdf->SetFont('','', $default_font_size + 1);
933
+        $pdf->SetDrawColor(128,128,128);
934
+        if (! empty($conf->barcode->enabled))
935
+        {
936
+            // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
937
+            //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
938
+            //$pdf->Image($logo,10, 5, 0, 24);
939
+        }
952 940
 
953
-		$posy+=5;
954 941
 
955
-		$pdf->SetXY($posx,$posy);
956
-		$pdf->SetTextColor(0,0,60);
957
-		$pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R');
942
+        $posx=$this->page_largeur - $w - $this->marge_droite;
943
+        $posy=$this->marge_haute;
958 944
 
959
-		// Date planned delivery
960
-		if (! empty($object->date_delivery))
961
-		{
962
-    			$posy+=4;
963
-    			$pdf->SetXY($posx,$posy);
964
-    			$pdf->SetTextColor(0,0,60);
965
-    			$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R');
966
-		}
945
+        $pdf->SetFont('','B', $default_font_size + 2);
946
+        $pdf->SetXY($posx,$posy);
947
+        $pdf->SetTextColor(0,0,60);
948
+        $title=$outputlangs->transnoentities("SendingSheet");
949
+        $pdf->MultiCell($w, 4, $title, '', 'R');
967 950
 
968
-		if (! empty($object->thirdparty->code_client))
969
-		{
970
-			$posy+=4;
971
-			$pdf->SetXY($posx,$posy);
972
-			$pdf->SetTextColor(0,0,60);
973
-			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
974
-		}
951
+        $pdf->SetFont('','', $default_font_size + 1);
975 952
 
953
+        $posy+=5;
976 954
 
977
-		$pdf->SetFont('','', $default_font_size + 3);
978
-		$Yoff=25;
955
+        $pdf->SetXY($posx,$posy);
956
+        $pdf->SetTextColor(0,0,60);
957
+        $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R');
979 958
 
980
-		// Add list of linked orders
981
-		$origin 	= $object->origin;
982
-		$origin_id 	= $object->origin_id;
959
+        // Date planned delivery
960
+        if (! empty($object->date_delivery))
961
+        {
962
+                $posy+=4;
963
+                $pdf->SetXY($posx,$posy);
964
+                $pdf->SetTextColor(0,0,60);
965
+                $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R');
966
+        }
983 967
 
984
-	    // TODO move to external function
985
-		if (! empty($conf->$origin->enabled))     // commonly $origin='commande'
986
-		{
987
-			$outputlangs->load('orders');
988
-
989
-			$classname = ucfirst($origin);
990
-			$linkedobject = new $classname($this->db);
991
-			$result=$linkedobject->fetch($origin_id);
992
-			if ($result >= 0)
993
-			{
994
-			    //$linkedobject->fetchObjectLinked()   Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
995
-
996
-				$pdf->SetFont('','', $default_font_size - 2);
997
-				$text=$linkedobject->ref;
998
-				if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')';
999
-				$Yoff = $Yoff+8;
1000
-				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff);
1001
-				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R');
1002
-				$Yoff = $Yoff+3;
1003
-				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff);
1004
-				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date,"day",false,$outputlangs,true), 0, 'R');
1005
-			}
1006
-		}
1007
-
1008
-		if ($showaddress)
1009
-		{
1010
-			// Sender properties
1011
-			$carac_emetteur='';
1012
-		 	// Add internal contact of origin element if defined
1013
-			$arrayidcontact=array();
1014
-			if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL');
1015
-		 	if (count($arrayidcontact) > 0)
1016
-		 	{
1017
-		 		$object->fetch_user(reset($arrayidcontact));
1018
-		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1019
-		 	}
1020
-
1021
-		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1022
-
1023
-			// Show sender
1024
-			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1025
-			$posx=$this->marge_gauche;
1026
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1027
-
1028
-			$hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1029
-			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1030
-
1031
-			// Show sender frame
1032
-			$pdf->SetTextColor(0,0,0);
1033
-			$pdf->SetFont('','', $default_font_size - 2);
1034
-			$pdf->SetXY($posx,$posy-5);
1035
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("Sender").":", 0, 'L');
1036
-			$pdf->SetXY($posx,$posy);
1037
-			$pdf->SetFillColor(230,230,230);
1038
-			$pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
1039
-			$pdf->SetTextColor(0,0,60);
1040
-			$pdf->SetFillColor(255,255,255);
1041
-
1042
-			// Show sender name
1043
-			$pdf->SetXY($posx+2,$posy+3);
1044
-			$pdf->SetFont('','B',$default_font_size);
1045
-			$pdf->MultiCell($widthrecbox-2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1046
-			$posy=$pdf->getY();
1047
-
1048
-			// Show sender information
1049
-			$pdf->SetXY($posx+2,$posy);
1050
-			$pdf->SetFont('','', $default_font_size - 1);
1051
-			$pdf->MultiCell($widthrecbox-2, 4, $carac_emetteur, 0, 'L');
1052
-
1053
-
1054
-			// If SHIPPING contact defined, we use it
1055
-			$usecontact=false;
1056
-			$arrayidcontact=$object->$origin->getIdContact('external','SHIPPING');
1057
-			if (count($arrayidcontact) > 0)
1058
-			{
1059
-				$usecontact=true;
1060
-				$result=$object->fetch_contact($arrayidcontact[0]);
1061
-			}
1062
-
1063
-			//Recipient name
1064
-			// On peut utiliser le nom de la societe du contact
1065
-			if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1066
-				$thirdparty = $object->contact;
1067
-			} else {
1068
-				$thirdparty = $object->thirdparty;
1069
-			}
1070
-
1071
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1072
-
1073
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,(!empty($object->contact)?$object->contact:null),$usecontact,'targetwithdetails',$object);
1074
-
1075
-			// Show recipient
1076
-			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1077
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1078
-			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1079
-			$posx=$this->page_largeur - $this->marge_droite - $widthrecbox;
1080
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1081
-
1082
-			// Show recipient frame
1083
-			$pdf->SetTextColor(0,0,0);
1084
-			$pdf->SetFont('','', $default_font_size - 2);
1085
-			$pdf->SetXY($posx+2,$posy-5);
1086
-			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L');
1087
-			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1088
-
1089
-			// Show recipient name
1090
-			$pdf->SetXY($posx+2,$posy+3);
1091
-			$pdf->SetFont('','B', $default_font_size);
1092
-			$pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
1093
-
1094
-			$posy = $pdf->getY();
1095
-
1096
-			// Show recipient information
1097
-			$pdf->SetFont('','', $default_font_size - 1);
1098
-			$pdf->SetXY($posx+2,$posy);
1099
-			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1100
-		}
1101
-
1102
-		$pdf->SetTextColor(0,0,0);
1103
-	}
1104
-
1105
-	/**
1106
-	 *   	Show footer of page. Need this->emetteur object
968
+        if (! empty($object->thirdparty->code_client))
969
+        {
970
+            $posy+=4;
971
+            $pdf->SetXY($posx,$posy);
972
+            $pdf->SetTextColor(0,0,60);
973
+            $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
974
+        }
975
+
976
+
977
+        $pdf->SetFont('','', $default_font_size + 3);
978
+        $Yoff=25;
979
+
980
+        // Add list of linked orders
981
+        $origin 	= $object->origin;
982
+        $origin_id 	= $object->origin_id;
983
+
984
+        // TODO move to external function
985
+        if (! empty($conf->$origin->enabled))     // commonly $origin='commande'
986
+        {
987
+            $outputlangs->load('orders');
988
+
989
+            $classname = ucfirst($origin);
990
+            $linkedobject = new $classname($this->db);
991
+            $result=$linkedobject->fetch($origin_id);
992
+            if ($result >= 0)
993
+            {
994
+                //$linkedobject->fetchObjectLinked()   Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
995
+
996
+                $pdf->SetFont('','', $default_font_size - 2);
997
+                $text=$linkedobject->ref;
998
+                if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')';
999
+                $Yoff = $Yoff+8;
1000
+                $pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff);
1001
+                $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R');
1002
+                $Yoff = $Yoff+3;
1003
+                $pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff);
1004
+                $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date,"day",false,$outputlangs,true), 0, 'R');
1005
+            }
1006
+        }
1007
+
1008
+        if ($showaddress)
1009
+        {
1010
+            // Sender properties
1011
+            $carac_emetteur='';
1012
+                // Add internal contact of origin element if defined
1013
+            $arrayidcontact=array();
1014
+            if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL');
1015
+                if (count($arrayidcontact) > 0)
1016
+                {
1017
+                    $object->fetch_user(reset($arrayidcontact));
1018
+                    $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1019
+                }
1020
+
1021
+                $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1022
+
1023
+            // Show sender
1024
+            $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1025
+            $posx=$this->marge_gauche;
1026
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1027
+
1028
+            $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1029
+            $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1030
+
1031
+            // Show sender frame
1032
+            $pdf->SetTextColor(0,0,0);
1033
+            $pdf->SetFont('','', $default_font_size - 2);
1034
+            $pdf->SetXY($posx,$posy-5);
1035
+            $pdf->MultiCell(66,5, $outputlangs->transnoentities("Sender").":", 0, 'L');
1036
+            $pdf->SetXY($posx,$posy);
1037
+            $pdf->SetFillColor(230,230,230);
1038
+            $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
1039
+            $pdf->SetTextColor(0,0,60);
1040
+            $pdf->SetFillColor(255,255,255);
1041
+
1042
+            // Show sender name
1043
+            $pdf->SetXY($posx+2,$posy+3);
1044
+            $pdf->SetFont('','B',$default_font_size);
1045
+            $pdf->MultiCell($widthrecbox-2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1046
+            $posy=$pdf->getY();
1047
+
1048
+            // Show sender information
1049
+            $pdf->SetXY($posx+2,$posy);
1050
+            $pdf->SetFont('','', $default_font_size - 1);
1051
+            $pdf->MultiCell($widthrecbox-2, 4, $carac_emetteur, 0, 'L');
1052
+
1053
+
1054
+            // If SHIPPING contact defined, we use it
1055
+            $usecontact=false;
1056
+            $arrayidcontact=$object->$origin->getIdContact('external','SHIPPING');
1057
+            if (count($arrayidcontact) > 0)
1058
+            {
1059
+                $usecontact=true;
1060
+                $result=$object->fetch_contact($arrayidcontact[0]);
1061
+            }
1062
+
1063
+            //Recipient name
1064
+            // On peut utiliser le nom de la societe du contact
1065
+            if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1066
+                $thirdparty = $object->contact;
1067
+            } else {
1068
+                $thirdparty = $object->thirdparty;
1069
+            }
1070
+
1071
+            $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1072
+
1073
+            $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,(!empty($object->contact)?$object->contact:null),$usecontact,'targetwithdetails',$object);
1074
+
1075
+            // Show recipient
1076
+            $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1077
+            if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1078
+            $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1079
+            $posx=$this->page_largeur - $this->marge_droite - $widthrecbox;
1080
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1081
+
1082
+            // Show recipient frame
1083
+            $pdf->SetTextColor(0,0,0);
1084
+            $pdf->SetFont('','', $default_font_size - 2);
1085
+            $pdf->SetXY($posx+2,$posy-5);
1086
+            $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L');
1087
+            $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1088
+
1089
+            // Show recipient name
1090
+            $pdf->SetXY($posx+2,$posy+3);
1091
+            $pdf->SetFont('','B', $default_font_size);
1092
+            $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
1093
+
1094
+            $posy = $pdf->getY();
1095
+
1096
+            // Show recipient information
1097
+            $pdf->SetFont('','', $default_font_size - 1);
1098
+            $pdf->SetXY($posx+2,$posy);
1099
+            $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1100
+        }
1101
+
1102
+        $pdf->SetTextColor(0,0,0);
1103
+    }
1104
+
1105
+    /**
1106
+     *   	Show footer of page. Need this->emetteur object
1107 1107
      *
1108
-	 *   	@param	PDF			$pdf     			PDF
1109
-	 * 		@param	Object		$object				Object to show
1110
-	 *      @param	Translate	$outputlangs		Object lang for output
1111
-	 *      @param	int			$hidefreetext		1=Hide free text
1112
-	 *      @return	int								Return height of bottom margin including footer text
1113
-	 */
1114
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1115
-	{
1116
-		global $conf;
1117
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1118
-		return pdf_pagefoot($pdf,$outputlangs,'SHIPPING_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1119
-	}
1108
+     *   	@param	PDF			$pdf     			PDF
1109
+     * 		@param	Object		$object				Object to show
1110
+     *      @param	Translate	$outputlangs		Object lang for output
1111
+     *      @param	int			$hidefreetext		1=Hide free text
1112
+     *      @return	int								Return height of bottom margin including footer text
1113
+     */
1114
+    function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1115
+    {
1116
+        global $conf;
1117
+        $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1118
+        return pdf_pagefoot($pdf,$outputlangs,'SHIPPING_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1119
+    }
1120 1120
 }
Please login to merge, or discard this patch.
Spacing   +312 added lines, -312 removed lines patch added patch discarded remove patch
@@ -115,56 +115,56 @@  discard block
 block discarded – undo
115 115
 	 *
116 116
 	 *	@param	DoliDB	$db		Database handler
117 117
 	 */
118
-	function __construct($db=0)
118
+	function __construct($db = 0)
119 119
 	{
120
-		global $conf,$langs,$mysoc;
120
+		global $conf, $langs, $mysoc;
121 121
 
122 122
 		$this->db = $db;
123 123
 		$this->name = "rouget";
124 124
 		$this->description = $langs->trans("DocumentModelStandardPDF");
125 125
 
126 126
 		$this->type = 'pdf';
127
-		$formatarray=pdf_getFormat();
127
+		$formatarray = pdf_getFormat();
128 128
 		$this->page_largeur = $formatarray['width'];
129 129
 		$this->page_hauteur = $formatarray['height'];
130
-		$this->format = array($this->page_largeur,$this->page_hauteur);
131
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
132
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
133
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
134
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
130
+		$this->format = array($this->page_largeur, $this->page_hauteur);
131
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
132
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
133
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
134
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
135 135
 
136 136
 		$this->option_logo = 1;
137 137
 
138 138
 		// Get source company
139
-		$this->emetteur=$mysoc;
140
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
139
+		$this->emetteur = $mysoc;
140
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
141 141
 
142 142
 		// Define position of columns
143
-		$this->posxdesc=$this->marge_gauche+1;
144
-		$this->posxweightvol=$this->page_largeur - $this->marge_droite - 78;
145
-		$this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56;
146
-		$this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28;
147
-		$this->posxpuht=$this->page_largeur - $this->marge_droite;
143
+		$this->posxdesc = $this->marge_gauche + 1;
144
+		$this->posxweightvol = $this->page_largeur - $this->marge_droite - 78;
145
+		$this->posxqtyordered = $this->page_largeur - $this->marge_droite - 56;
146
+		$this->posxqtytoship = $this->page_largeur - $this->marge_droite - 28;
147
+		$this->posxpuht = $this->page_largeur - $this->marge_droite;
148 148
 
149 149
 		if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) {	// Show also the prices
150
-			$this->posxweightvol=$this->page_largeur - $this->marge_droite - 118;
151
-			$this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96;
152
-			$this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68;
153
-			$this->posxpuht=$this->page_largeur - $this->marge_droite - 40;
154
-			$this->posxtotalht=$this->page_largeur - $this->marge_droite - 20;
150
+			$this->posxweightvol = $this->page_largeur - $this->marge_droite - 118;
151
+			$this->posxqtyordered = $this->page_largeur - $this->marge_droite - 96;
152
+			$this->posxqtytoship = $this->page_largeur - $this->marge_droite - 68;
153
+			$this->posxpuht = $this->page_largeur - $this->marge_droite - 40;
154
+			$this->posxtotalht = $this->page_largeur - $this->marge_droite - 20;
155 155
 		}
156 156
 
157
-		$this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
157
+		$this->posxpicture = $this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
158 158
 
159 159
 		if ($this->page_largeur < 210) // To work with US executive format
160 160
 		{
161
-		    $this->posxweightvol-=20;
162
-		    $this->posxpicture-=20;
163
-		    $this->posxqtyordered-=20;
164
-		    $this->posxqtytoship-=20;
161
+		    $this->posxweightvol -= 20;
162
+		    $this->posxpicture -= 20;
163
+		    $this->posxqtyordered -= 20;
164
+		    $this->posxqtytoship -= 20;
165 165
 		}
166 166
 
167
-		if (! empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
167
+		if (!empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
168 168
 		{
169 169
 		    $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
170 170
 		    $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
@@ -184,16 +184,16 @@  discard block
 block discarded – undo
184 184
      *  @param		int			$hideref			Do not show ref
185 185
      *  @return     int         	    			1=OK, 0=KO
186 186
 	 */
187
-	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
187
+	function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
188 188
 	{
189 189
 		// phpcs:enable
190
-		global $user,$conf,$langs,$hookmanager;
190
+		global $user, $conf, $langs, $hookmanager;
191 191
 
192 192
 		$object->fetch_thirdparty();
193 193
 
194
-		if (! is_object($outputlangs)) $outputlangs=$langs;
194
+		if (!is_object($outputlangs)) $outputlangs = $langs;
195 195
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
196
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
196
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
197 197
 
198 198
 		// Load traductions files requiredby by page
199 199
 		$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
@@ -201,50 +201,50 @@  discard block
 block discarded – undo
201 201
 		$nblignes = count($object->lines);
202 202
 
203 203
         // Loop on each lines to detect if there is at least one image to show
204
-        $realpatharray=array();
205
-        if (! empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
204
+        $realpatharray = array();
205
+        if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
206 206
         {
207 207
             $objphoto = new Product($this->db);
208 208
 
209
-            for ($i = 0 ; $i < $nblignes ; $i++)
209
+            for ($i = 0; $i < $nblignes; $i++)
210 210
             {
211 211
                 if (empty($object->lines[$i]->fk_product)) continue;
212 212
 
213 213
 				$objphoto = new Product($this->db);
214 214
 				$objphoto->fetch($object->lines[$i]->fk_product);
215 215
 
216
-				$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
216
+				$pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
217 217
 				$dir = $conf->product->dir_output.'/'.$pdir;
218 218
 
219
-				$realpath='';
219
+				$realpath = '';
220 220
 
221
-                foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
221
+                foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
222 222
                         {
223 223
                             if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
224 224
                             {
225 225
                                 if ($obj['photo_vignette'])
226 226
                                 {
227
-                                    $filename= $obj['photo_vignette'];
227
+                                    $filename = $obj['photo_vignette'];
228 228
                                 }
229 229
                                 else
230 230
                                 {
231
-                                    $filename=$obj['photo'];
231
+                                    $filename = $obj['photo'];
232 232
                                 }
233 233
                             }
234 234
                             else
235 235
                             {
236
-                                $filename=$obj['photo'];
236
+                                $filename = $obj['photo'];
237 237
                             }
238 238
 
239 239
                             $realpath = $dir.$filename;
240 240
                             break;
241 241
                 }
242 242
 
243
-                if ($realpath) $realpatharray[$i]=$realpath;
243
+                if ($realpath) $realpatharray[$i] = $realpath;
244 244
             }
245 245
         }
246 246
 
247
-        if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol;
247
+        if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
248 248
 
249 249
 		if ($conf->expedition->dir_output)
250 250
 		{
@@ -252,20 +252,20 @@  discard block
 block discarded – undo
252 252
 			if ($object->specimen)
253 253
 			{
254 254
 				$dir = $conf->expedition->dir_output."/sending";
255
-				$file = $dir . "/SPECIMEN.pdf";
255
+				$file = $dir."/SPECIMEN.pdf";
256 256
 			}
257 257
 			else
258 258
 			{
259 259
 				$expref = dol_sanitizeFileName($object->ref);
260
-				$dir = $conf->expedition->dir_output."/sending/" . $expref;
261
-				$file = $dir . "/" . $expref . ".pdf";
260
+				$dir = $conf->expedition->dir_output."/sending/".$expref;
261
+				$file = $dir."/".$expref.".pdf";
262 262
 			}
263 263
 
264
-			if (! file_exists($dir))
264
+			if (!file_exists($dir))
265 265
 			{
266 266
 				if (dol_mkdir($dir) < 0)
267 267
 				{
268
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
268
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
269 269
 					return 0;
270 270
 				}
271 271
 			}
@@ -273,26 +273,26 @@  discard block
 block discarded – undo
273 273
 			if (file_exists($dir))
274 274
 			{
275 275
 				// Add pdfgeneration hook
276
-				if (! is_object($hookmanager))
276
+				if (!is_object($hookmanager))
277 277
 				{
278 278
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
279
-					$hookmanager=new HookManager($this->db);
279
+					$hookmanager = new HookManager($this->db);
280 280
 				}
281 281
 				$hookmanager->initHooks(array('pdfgeneration'));
282
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
282
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
283 283
 				global $action;
284
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
284
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
285 285
 
286 286
 				// Set nblignes with the new facture lines content after hook
287 287
 				$nblignes = count($object->lines);
288 288
 
289
-				$pdf=pdf_getInstance($this->format);
289
+				$pdf = pdf_getInstance($this->format);
290 290
 				$default_font_size = pdf_getPDFFontSize($outputlangs);
291
-				$heightforinfotot = 8;	// Height reserved to output the info and total part
292
-		        $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
293
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
294
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
295
-                $pdf->SetAutoPageBreak(1,0);
291
+				$heightforinfotot = 8; // Height reserved to output the info and total part
292
+		        $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
293
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
294
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
295
+                $pdf->SetAutoPageBreak(1, 0);
296 296
 
297 297
                 if (class_exists('TCPDF'))
298 298
                 {
@@ -301,38 +301,38 @@  discard block
 block discarded – undo
301 301
                 }
302 302
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
303 303
                 // Set path to the background PDF File
304
-                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
304
+                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
305 305
                 {
306 306
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
307 307
                     $tplidx = $pdf->importPage(1);
308 308
                 }
309 309
 
310 310
 				$pdf->Open();
311
-				$pagenb=0;
312
-				$pdf->SetDrawColor(128,128,128);
311
+				$pagenb = 0;
312
+				$pdf->SetDrawColor(128, 128, 128);
313 313
 
314
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
314
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
315 315
 
316 316
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
317 317
 				$pdf->SetSubject($outputlangs->transnoentities("Shipment"));
318 318
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
319 319
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
320 320
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
321
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
321
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
322 322
 
323
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
323
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
324 324
 
325 325
 				// New page
326 326
 				$pdf->AddPage();
327
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
327
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
328 328
 				$pagenb++;
329 329
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
330
-				$pdf->SetFont('','', $default_font_size - 1);
331
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
332
-				$pdf->SetTextColor(0,0,0);
330
+				$pdf->SetFont('', '', $default_font_size - 1);
331
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
332
+				$pdf->SetTextColor(0, 0, 0);
333 333
 
334 334
 				$tab_top = 90;
335
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
335
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
336 336
 				$tab_height = 130;
337 337
 				$tab_height_newpage = 150;
338 338
 
@@ -345,52 +345,52 @@  discard block
 block discarded – undo
345 345
 					{
346 346
 						$tab_top = 88;
347 347
 
348
-						$pdf->SetFont('','', $default_font_size - 1);
349
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
348
+						$pdf->SetFont('', '', $default_font_size - 1);
349
+						$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
350 350
 						$nexY = $pdf->GetY();
351
-						$height_incoterms=$nexY-$tab_top;
351
+						$height_incoterms = $nexY - $tab_top;
352 352
 
353 353
 						// Rect prend une longueur en 3eme param
354
-						$pdf->SetDrawColor(192,192,192);
355
-						$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
354
+						$pdf->SetDrawColor(192, 192, 192);
355
+						$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
356 356
 
357
-						$tab_top = $nexY+6;
357
+						$tab_top = $nexY + 6;
358 358
 						$height_incoterms += 4;
359 359
 					}
360 360
 				}
361 361
 
362
-				if (! empty($object->note_public) || ! empty($object->tracking_number))
362
+				if (!empty($object->note_public) || !empty($object->tracking_number))
363 363
 				{
364 364
 					$tab_top = 88 + $height_incoterms;
365 365
 					$tab_top_alt = $tab_top;
366 366
 
367
-					$pdf->SetFont('','B', $default_font_size - 2);
368
-					$pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, 0, 1, false, true, 'L');
367
+					$pdf->SetFont('', 'B', $default_font_size - 2);
368
+					$pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L');
369 369
 
370 370
 					$tab_top_alt = $pdf->GetY();
371 371
 					//$tab_top_alt += 1;
372 372
 
373 373
 					// Tracking number
374
-					if (! empty($object->tracking_number))
374
+					if (!empty($object->tracking_number))
375 375
 					{
376 376
 						$object->getUrlTrackingStatus($object->tracking_number);
377
-						if (! empty($object->tracking_url))
377
+						if (!empty($object->tracking_url))
378 378
 						{
379 379
 							if ($object->shipping_method_id > 0)
380 380
 							{
381 381
 								// Get code using getLabelFromKey
382
-								$code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code');
383
-								$label='';
384
-								if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>";
385
-								$label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
382
+								$code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
383
+								$label = '';
384
+								if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")."<br>";
385
+								$label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
386 386
 								//var_dump($object->tracking_url != $object->tracking_number);exit;
387 387
 								if ($object->tracking_url != $object->tracking_number)
388 388
 								{
389
-									$label.=" : ";
390
-									$label.=$object->tracking_url;
389
+									$label .= " : ";
390
+									$label .= $object->tracking_url;
391 391
 								}
392
-								$pdf->SetFont('','B', $default_font_size - 2);
393
-								$pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top_alt, $label, 0, 1, false, true, 'L');
392
+								$pdf->SetFont('', 'B', $default_font_size - 2);
393
+								$pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L');
394 394
 
395 395
 								$tab_top_alt = $pdf->GetY();
396 396
 							}
@@ -398,25 +398,25 @@  discard block
 block discarded – undo
398 398
 					}
399 399
 
400 400
 					// Notes
401
-					if (! empty($object->note_public))
401
+					if (!empty($object->note_public))
402 402
 					{
403
-						$pdf->SetFont('','', $default_font_size - 1);   // Dans boucle pour gerer multi-page
404
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1);
403
+						$pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page
404
+						$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1);
405 405
 					}
406 406
 
407 407
 					$nexY = $pdf->GetY();
408
-					$height_note=$nexY-$tab_top;
408
+					$height_note = $nexY - $tab_top;
409 409
 
410 410
 					// Rect prend une longueur en 3eme param
411
-					$pdf->SetDrawColor(192,192,192);
412
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
411
+					$pdf->SetDrawColor(192, 192, 192);
412
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
413 413
 
414 414
 					$tab_height = $tab_height - $height_note;
415
-					$tab_top = $nexY+6;
415
+					$tab_top = $nexY + 6;
416 416
 				}
417 417
 				else
418 418
 				{
419
-					$height_note=0;
419
+					$height_note = 0;
420 420
 				}
421 421
 
422 422
 				$iniY = $tab_top + 7;
@@ -427,87 +427,87 @@  discard block
 block discarded – undo
427 427
 				for ($i = 0; $i < $nblignes; $i++)
428 428
 				{
429 429
 					$curY = $nexY;
430
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
431
-					$pdf->SetTextColor(0,0,0);
430
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
431
+					$pdf->SetTextColor(0, 0, 0);
432 432
 
433 433
 					// Define size of image if we need it
434
-					$imglinesize=array();
435
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
434
+					$imglinesize = array();
435
+					if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
436 436
 
437 437
 					$pdf->setTopMargin($tab_top_newpage);
438
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
439
-					$pageposbefore=$pdf->getPage();
438
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
439
+					$pageposbefore = $pdf->getPage();
440 440
 
441
-					$showpricebeforepagebreak=1;
442
-					$posYAfterImage=0;
443
-					$posYAfterDescription=0;
441
+					$showpricebeforepagebreak = 1;
442
+					$posYAfterImage = 0;
443
+					$posYAfterDescription = 0;
444 444
 
445 445
 					// We start with Photo of product line
446
-					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
446
+					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// If photo too high, we moved completely on new page
447 447
 					{
448
-						$pdf->AddPage('','',true);
449
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
448
+						$pdf->AddPage('', '', true);
449
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
450 450
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
451
-						$pdf->setPage($pageposbefore+1);
451
+						$pdf->setPage($pageposbefore + 1);
452 452
 
453 453
 						$curY = $tab_top_newpage;
454
-						$showpricebeforepagebreak=0;
454
+						$showpricebeforepagebreak = 0;
455 455
 					}
456 456
 
457 457
 					if (isset($imglinesize['width']) && isset($imglinesize['height']))
458 458
 					{
459
-						$curX = $this->posxpicture-1;
460
-						$pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
459
+						$curX = $this->posxpicture - 1;
460
+						$pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
461 461
 						// $pdf->Image does not increase value return by getY, so we save it manually
462
-						$posYAfterImage=$curY+$imglinesize['height'];
462
+						$posYAfterImage = $curY + $imglinesize['height'];
463 463
 					}
464 464
 
465 465
 					// Description of product line
466
-					$curX = $this->posxdesc-1;
466
+					$curX = $this->posxdesc - 1;
467 467
 
468 468
 					$pdf->startTransaction();
469
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
469
+					pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
470 470
 
471
-					$pageposafter=$pdf->getPage();
471
+					$pageposafter = $pdf->getPage();
472 472
 					if ($pageposafter > $pageposbefore)	// There is a pagebreak
473 473
 					{
474 474
 						$pdf->rollbackTransaction(true);
475
-						$pageposafter=$pageposbefore;
475
+						$pageposafter = $pageposbefore;
476 476
 						//print $pageposafter.'-'.$pageposbefore;exit;
477
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
478
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
477
+						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
478
+						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
479 479
 
480
-						$pageposafter=$pdf->getPage();
481
-						$posyafter=$pdf->GetY();
480
+						$pageposafter = $pdf->getPage();
481
+						$posyafter = $pdf->GetY();
482 482
 						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
483
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
483
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
484 484
 						{
485
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
485
+							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
486 486
 							{
487
-								$pdf->AddPage('','',true);
488
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
487
+								$pdf->AddPage('', '', true);
488
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
489 489
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
490
-								$pdf->setPage($pageposafter+1);
490
+								$pdf->setPage($pageposafter + 1);
491 491
 							}
492 492
 						}
493 493
 						else
494 494
 						{
495 495
 							// We found a page break
496
-							$showpricebeforepagebreak=0;
496
+							$showpricebeforepagebreak = 0;
497 497
 						}
498 498
 					}
499 499
 					else	// No pagebreak
500 500
 					{
501 501
 						$pdf->commitTransaction();
502 502
 					}
503
-					$posYAfterDescription=$pdf->GetY();
503
+					$posYAfterDescription = $pdf->GetY();
504 504
 
505 505
 					$nexY = $pdf->GetY();
506
-					$pageposafter=$pdf->getPage();
506
+					$pageposafter = $pdf->getPage();
507 507
 
508 508
 					$pdf->setPage($pageposbefore);
509 509
 					$pdf->setTopMargin($this->marge_haute);
510
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
510
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
511 511
 
512 512
 					// We suppose that a too long description or photo were moved completely on next page
513 513
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
@@ -519,57 +519,57 @@  discard block
 block discarded – undo
519 519
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
520 520
 					}
521 521
 
522
-					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
522
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
523 523
 
524 524
 					$pdf->SetXY($this->posxweightvol, $curY);
525
-					$weighttxt='';
525
+					$weighttxt = '';
526 526
 					if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight)
527 527
 					{
528
-					    $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units,"weight");
528
+					    $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units, "weight");
529 529
 					}
530
-					$voltxt='';
530
+					$voltxt = '';
531 531
 					if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume)
532 532
 					{
533
-					    $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0,"volume");
533
+					    $voltxt = round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->volume_units ? $object->lines[$i]->volume_units : 0, "volume");
534 534
 					}
535 535
 
536 536
 					if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME))
537 537
 					{
538
-						$pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt, 0, 0, false, true, 'C');
538
+						$pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ? '<br>' : '').$voltxt, 0, 0, false, true, 'C');
539 539
 						//$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C');
540 540
 					}
541 541
 
542 542
 					if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
543 543
 					{
544 544
 					   $pdf->SetXY($this->posxqtyordered, $curY);
545
-					   $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C');
545
+					   $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C');
546 546
 					}
547 547
 
548 548
 					if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP))
549 549
 					{
550 550
 						$pdf->SetXY($this->posxqtytoship, $curY);
551
-						$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped,'','C');
551
+						$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped, '', 'C');
552 552
 					}
553 553
 
554
-					if(!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT))
554
+					if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT))
555 555
 					{
556 556
 						$pdf->SetXY($this->posxpuht, $curY);
557
-						$pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R');
557
+						$pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R');
558 558
 
559 559
 						$pdf->SetXY($this->posxtotalht, $curY);
560
-						$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs),'','R');
560
+						$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs), '', 'R');
561 561
 					}
562 562
 
563
-					$nexY+=3;
564
-					if ($weighttxt && $voltxt) $nexY+=2;
563
+					$nexY += 3;
564
+					if ($weighttxt && $voltxt) $nexY += 2;
565 565
 
566 566
 					// Add line
567
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
567
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
568 568
 					{
569 569
 						$pdf->setPage($pageposafter);
570
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
570
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
571 571
 						//$pdf->SetDrawColor(190,190,200);
572
-						$pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1);
572
+						$pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1);
573 573
 						$pdf->SetLineStyle(array('dash'=>0));
574 574
 					}
575 575
 
@@ -585,13 +585,13 @@  discard block
 block discarded – undo
585 585
 						{
586 586
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
587 587
 						}
588
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
588
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
589 589
 						$pagenb++;
590 590
 						$pdf->setPage($pagenb);
591
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
591
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
592 592
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
593 593
 					}
594
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
594
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
595 595
 					{
596 596
 						if ($pagenb == 1)
597 597
 						{
@@ -601,10 +601,10 @@  discard block
 block discarded – undo
601 601
 						{
602 602
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
603 603
 						}
604
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
604
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
605 605
 						// New page
606 606
 						$pdf->AddPage();
607
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
607
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
608 608
 						$pagenb++;
609 609
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
610 610
 					}
@@ -614,47 +614,47 @@  discard block
 block discarded – undo
614 614
 				if ($pagenb == 1)
615 615
 				{
616 616
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
617
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
617
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
618 618
 				}
619 619
 				else
620 620
 				{
621 621
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
622
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
622
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
623 623
 				}
624 624
 
625 625
 				// Affiche zone totaux
626
-				$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
626
+				$posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
627 627
 
628 628
 				// Pied de page
629
-				$this->_pagefoot($pdf,$object,$outputlangs);
630
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
629
+				$this->_pagefoot($pdf, $object, $outputlangs);
630
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
631 631
 
632 632
 				$pdf->Close();
633 633
 
634
-				$pdf->Output($file,'F');
634
+				$pdf->Output($file, 'F');
635 635
 
636 636
 				// Add pdfgeneration hook
637 637
 				$hookmanager->initHooks(array('pdfgeneration'));
638
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
638
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
639 639
 				global $action;
640
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
640
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
641 641
 
642
-				if (! empty($conf->global->MAIN_UMASK))
642
+				if (!empty($conf->global->MAIN_UMASK))
643 643
 				@chmod($file, octdec($conf->global->MAIN_UMASK));
644 644
 
645 645
 				$this->result = array('fullpath'=>$file);
646 646
 
647
-				return 1;	// No error
647
+				return 1; // No error
648 648
 			}
649 649
 			else
650 650
 			{
651
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
651
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
652 652
 				return 0;
653 653
 			}
654 654
 		}
655 655
 		else
656 656
 		{
657
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
657
+			$this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
658 658
 			return 0;
659 659
 		}
660 660
 	}
@@ -673,18 +673,18 @@  discard block
 block discarded – undo
673 673
 	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
674 674
 	{
675 675
 		// phpcs:enable
676
-		global $conf,$mysoc;
676
+		global $conf, $mysoc;
677 677
 
678
-        $sign=1;
678
+        $sign = 1;
679 679
 
680 680
         $default_font_size = pdf_getPDFFontSize($outputlangs);
681 681
 
682 682
 		$tab2_top = $posy;
683 683
 		$tab2_hl = 4;
684
-		$pdf->SetFont('','B', $default_font_size - 1);
684
+		$pdf->SetFont('', 'B', $default_font_size - 1);
685 685
 
686 686
 		// Tableau total
687
-		$col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol;
687
+		$col1x = $this->posxweightvol - 50; $col2x = $this->posxweightvol;
688 688
 		/*if ($this->page_largeur < 210) // To work with US executive format
689 689
 		{
690 690
 			$col2x-=20;
@@ -692,33 +692,33 @@  discard block
 block discarded – undo
692 692
 		if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
693 693
 		else $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
694 694
 
695
-		$useborder=0;
695
+		$useborder = 0;
696 696
 		$index = 0;
697 697
 
698
-		$totalWeighttoshow='';
699
-		$totalVolumetoshow='';
698
+		$totalWeighttoshow = '';
699
+		$totalVolumetoshow = '';
700 700
 
701 701
 		// Load dim data
702
-		$tmparray=$object->getTotalWeightVolume();
703
-		$totalWeight=$tmparray['weight'];
704
-		$totalVolume=$tmparray['volume'];
705
-		$totalOrdered=$tmparray['ordered'];
706
-		$totalToShip=$tmparray['toship'];
702
+		$tmparray = $object->getTotalWeightVolume();
703
+		$totalWeight = $tmparray['weight'];
704
+		$totalVolume = $tmparray['volume'];
705
+		$totalOrdered = $tmparray['ordered'];
706
+		$totalToShip = $tmparray['toship'];
707 707
 		// Set trueVolume and volume_units not currently stored into database
708 708
 		if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
709 709
 		{
710
-		    $object->trueVolume=price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
711
-		    $object->volume_units=$object->size_units * 3;
710
+		    $object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
711
+		    $object->volume_units = $object->size_units * 3;
712 712
 		}
713 713
 
714
-		if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
715
-		if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
716
-		if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
717
-		if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
714
+		if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
715
+		if ($totalVolume != '') $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
716
+		if ($object->trueWeight) $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
717
+		if ($object->trueVolume) $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
718 718
 
719
-    	$pdf->SetFillColor(255,255,255);
719
+    	$pdf->SetFillColor(255, 255, 255);
720 720
     	$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
721
-    	$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
721
+    	$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
722 722
 
723 723
         if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
724 724
         {
@@ -758,10 +758,10 @@  discard block
 block discarded – undo
758 758
 
759 759
 			    $index++;
760 760
 			}
761
-			if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++;
761
+			if (!$totalWeighttoshow && !$totalVolumetoshow) $index++;
762 762
 		}
763 763
 
764
-		$pdf->SetTextColor(0,0,0);
764
+		$pdf->SetTextColor(0, 0, 0);
765 765
 
766 766
 		return ($tab2_top + ($tab2_hl * $index));
767 767
 	}
@@ -778,78 +778,78 @@  discard block
 block discarded – undo
778 778
 	 *   @param		int			$hidebottom		Hide bottom bar of array
779 779
 	 *   @return	void
780 780
 	 */
781
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
781
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
782 782
 	{
783 783
 		global $conf;
784 784
 
785 785
 		// Force to disable hidetop and hidebottom
786
-		$hidebottom=0;
787
-		if ($hidetop) $hidetop=-1;
786
+		$hidebottom = 0;
787
+		if ($hidetop) $hidetop = -1;
788 788
 
789 789
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
790 790
 
791 791
 		// Amount in (at tab_top - 1)
792
-		$pdf->SetTextColor(0,0,0);
793
-		$pdf->SetFont('','',$default_font_size - 2);
792
+		$pdf->SetTextColor(0, 0, 0);
793
+		$pdf->SetFont('', '', $default_font_size - 2);
794 794
 
795 795
 		// Output Rect
796
-		$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
796
+		$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
797 797
 
798
-		$pdf->SetDrawColor(128,128,128);
799
-		$pdf->SetFont('','', $default_font_size - 1);
798
+		$pdf->SetDrawColor(128, 128, 128);
799
+		$pdf->SetFont('', '', $default_font_size - 1);
800 800
 
801 801
 		if (empty($hidetop))
802 802
 		{
803
-			$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);
803
+			$pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
804 804
 
805
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
805
+			$pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
806 806
 			$pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L');
807 807
 		}
808 808
 
809 809
 		if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME))
810 810
 		{
811
-			$pdf->line($this->posxweightvol-1, $tab_top, $this->posxweightvol-1, $tab_top + $tab_height);
811
+			$pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height);
812 812
 			if (empty($hidetop))
813 813
 			{
814
-				$pdf->SetXY($this->posxweightvol-1, $tab_top+1);
815
-				$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C');
814
+				$pdf->SetXY($this->posxweightvol - 1, $tab_top + 1);
815
+				$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"), '', 'C');
816 816
 			}
817 817
 		}
818 818
 
819 819
         if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
820 820
         {
821
-            $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height);
821
+            $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
822 822
     		if (empty($hidetop))
823 823
     		{
824
-    			$pdf->SetXY($this->posxqtyordered-1, $tab_top+1);
825
-    			$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C');
824
+    			$pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
825
+    			$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C');
826 826
     		}
827 827
         }
828 828
 
829 829
         if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP))
830 830
         {
831
-			$pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height);
831
+			$pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
832 832
 			if (empty($hidetop))
833 833
 			{
834
-				$pdf->SetXY($this->posxqtytoship, $tab_top+1);
835
-				$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"),'','C');
834
+				$pdf->SetXY($this->posxqtytoship, $tab_top + 1);
835
+				$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"), '', 'C');
836 836
 			}
837 837
         }
838 838
 
839 839
 		if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) {
840 840
 
841
-			$pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height);
841
+			$pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height);
842 842
 			if (empty($hidetop))
843 843
 			{
844
-				$pdf->SetXY($this->posxpuht-1, $tab_top+1);
845
-				$pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"),'','C');
844
+				$pdf->SetXY($this->posxpuht - 1, $tab_top + 1);
845
+				$pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
846 846
 			}
847 847
 
848
-			$pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height);
848
+			$pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height);
849 849
 			if (empty($hidetop))
850 850
 			{
851
-				$pdf->SetXY($this->posxtotalht-1, $tab_top+1);
852
-				$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"),'','C');
851
+				$pdf->SetXY($this->posxtotalht - 1, $tab_top + 1);
852
+				$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
853 853
 			}
854 854
 		}
855 855
 	}
@@ -865,73 +865,73 @@  discard block
 block discarded – undo
865 865
 	 */
866 866
 	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
867 867
 	{
868
-		global $conf,$langs,$mysoc;
868
+		global $conf, $langs, $mysoc;
869 869
 
870 870
 		$langs->load("orders");
871 871
 
872 872
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
873 873
 
874
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
874
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
875 875
 
876 876
 		// Show Draft Watermark
877
-		if($object->statut==0 && (! empty($conf->global->SHIPPING_DRAFT_WATERMARK)) )
877
+		if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK)))
878 878
 		{
879
-            		pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SHIPPING_DRAFT_WATERMARK);
879
+            		pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK);
880 880
 		}
881 881
 
882 882
 		//Prepare la suite
883
-		$pdf->SetTextColor(0,0,60);
884
-		$pdf->SetFont('','B', $default_font_size + 3);
883
+		$pdf->SetTextColor(0, 0, 60);
884
+		$pdf->SetFont('', 'B', $default_font_size + 3);
885 885
 
886 886
 		$w = 110;
887 887
 
888
-		$posy=$this->marge_haute;
889
-		$posx=$this->page_largeur-$this->marge_droite-$w;
888
+		$posy = $this->marge_haute;
889
+		$posx = $this->page_largeur - $this->marge_droite - $w;
890 890
 
891
-		$pdf->SetXY($this->marge_gauche,$posy);
891
+		$pdf->SetXY($this->marge_gauche, $posy);
892 892
 
893 893
 		// Logo
894
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
894
+		$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
895 895
 		if ($this->emetteur->logo)
896 896
 		{
897 897
 			if (is_readable($logo))
898 898
 			{
899
-			    $height=pdf_getHeightForLogo($logo);
900
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
899
+			    $height = pdf_getHeightForLogo($logo);
900
+			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
901 901
 			}
902 902
 			else
903 903
 			{
904
-				$pdf->SetTextColor(200,0,0);
905
-				$pdf->SetFont('','B', $default_font_size - 2);
906
-				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
904
+				$pdf->SetTextColor(200, 0, 0);
905
+				$pdf->SetFont('', 'B', $default_font_size - 2);
906
+				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
907 907
 				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
908 908
 			}
909 909
 		}
910 910
 		else
911 911
 		{
912
-			$text=$this->emetteur->name;
912
+			$text = $this->emetteur->name;
913 913
 			$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
914 914
 		}
915 915
 
916 916
 		// Show barcode
917
-		if (! empty($conf->barcode->enabled))
917
+		if (!empty($conf->barcode->enabled))
918 918
 		{
919
-			$posx=105;
919
+			$posx = 105;
920 920
 		}
921 921
 		else
922 922
 		{
923
-			$posx=$this->marge_gauche+3;
923
+			$posx = $this->marge_gauche + 3;
924 924
 		}
925 925
 		//$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
926
-		if (! empty($conf->barcode->enabled))
926
+		if (!empty($conf->barcode->enabled))
927 927
 		{
928 928
 			// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
929 929
 			//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
930 930
 			//$pdf->Image($logo,10, 5, 0, 24);
931 931
 		}
932 932
 
933
-		$pdf->SetDrawColor(128,128,128);
934
-		if (! empty($conf->barcode->enabled))
933
+		$pdf->SetDrawColor(128, 128, 128);
934
+		if (!empty($conf->barcode->enabled))
935 935
 		{
936 936
 			// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
937 937
 			//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
@@ -939,125 +939,125 @@  discard block
 block discarded – undo
939 939
 		}
940 940
 
941 941
 
942
-		$posx=$this->page_largeur - $w - $this->marge_droite;
943
-		$posy=$this->marge_haute;
942
+		$posx = $this->page_largeur - $w - $this->marge_droite;
943
+		$posy = $this->marge_haute;
944 944
 
945
-		$pdf->SetFont('','B', $default_font_size + 2);
946
-		$pdf->SetXY($posx,$posy);
947
-		$pdf->SetTextColor(0,0,60);
948
-		$title=$outputlangs->transnoentities("SendingSheet");
945
+		$pdf->SetFont('', 'B', $default_font_size + 2);
946
+		$pdf->SetXY($posx, $posy);
947
+		$pdf->SetTextColor(0, 0, 60);
948
+		$title = $outputlangs->transnoentities("SendingSheet");
949 949
 		$pdf->MultiCell($w, 4, $title, '', 'R');
950 950
 
951
-		$pdf->SetFont('','', $default_font_size + 1);
951
+		$pdf->SetFont('', '', $default_font_size + 1);
952 952
 
953
-		$posy+=5;
953
+		$posy += 5;
954 954
 
955
-		$pdf->SetXY($posx,$posy);
956
-		$pdf->SetTextColor(0,0,60);
957
-		$pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R');
955
+		$pdf->SetXY($posx, $posy);
956
+		$pdf->SetTextColor(0, 0, 60);
957
+		$pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending")." : ".$object->ref, '', 'R');
958 958
 
959 959
 		// Date planned delivery
960
-		if (! empty($object->date_delivery))
960
+		if (!empty($object->date_delivery))
961 961
 		{
962
-    			$posy+=4;
963
-    			$pdf->SetXY($posx,$posy);
964
-    			$pdf->SetTextColor(0,0,60);
965
-    			$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R');
962
+    			$posy += 4;
963
+    			$pdf->SetXY($posx, $posy);
964
+    			$pdf->SetTextColor(0, 0, 60);
965
+    			$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
966 966
 		}
967 967
 
968
-		if (! empty($object->thirdparty->code_client))
968
+		if (!empty($object->thirdparty->code_client))
969 969
 		{
970
-			$posy+=4;
971
-			$pdf->SetXY($posx,$posy);
972
-			$pdf->SetTextColor(0,0,60);
973
-			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
970
+			$posy += 4;
971
+			$pdf->SetXY($posx, $posy);
972
+			$pdf->SetTextColor(0, 0, 60);
973
+			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
974 974
 		}
975 975
 
976 976
 
977
-		$pdf->SetFont('','', $default_font_size + 3);
978
-		$Yoff=25;
977
+		$pdf->SetFont('', '', $default_font_size + 3);
978
+		$Yoff = 25;
979 979
 
980 980
 		// Add list of linked orders
981
-		$origin 	= $object->origin;
982
-		$origin_id 	= $object->origin_id;
981
+		$origin = $object->origin;
982
+		$origin_id = $object->origin_id;
983 983
 
984 984
 	    // TODO move to external function
985
-		if (! empty($conf->$origin->enabled))     // commonly $origin='commande'
985
+		if (!empty($conf->$origin->enabled))     // commonly $origin='commande'
986 986
 		{
987 987
 			$outputlangs->load('orders');
988 988
 
989 989
 			$classname = ucfirst($origin);
990 990
 			$linkedobject = new $classname($this->db);
991
-			$result=$linkedobject->fetch($origin_id);
991
+			$result = $linkedobject->fetch($origin_id);
992 992
 			if ($result >= 0)
993 993
 			{
994 994
 			    //$linkedobject->fetchObjectLinked()   Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
995 995
 
996
-				$pdf->SetFont('','', $default_font_size - 2);
997
-				$text=$linkedobject->ref;
998
-				if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')';
999
-				$Yoff = $Yoff+8;
1000
-				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff);
1001
-				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R');
1002
-				$Yoff = $Yoff+3;
1003
-				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff);
1004
-				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date,"day",false,$outputlangs,true), 0, 'R');
996
+				$pdf->SetFont('', '', $default_font_size - 2);
997
+				$text = $linkedobject->ref;
998
+				if ($linkedobject->ref_client) $text .= ' ('.$linkedobject->ref_client.')';
999
+				$Yoff = $Yoff + 8;
1000
+				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1001
+				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), 0, 'R');
1002
+				$Yoff = $Yoff + 3;
1003
+				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1004
+				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R');
1005 1005
 			}
1006 1006
 		}
1007 1007
 
1008 1008
 		if ($showaddress)
1009 1009
 		{
1010 1010
 			// Sender properties
1011
-			$carac_emetteur='';
1011
+			$carac_emetteur = '';
1012 1012
 		 	// Add internal contact of origin element if defined
1013
-			$arrayidcontact=array();
1014
-			if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL');
1013
+			$arrayidcontact = array();
1014
+			if (!empty($origin) && is_object($object->$origin)) $arrayidcontact = $object->$origin->getIdContact('internal', 'SALESREPFOLL');
1015 1015
 		 	if (count($arrayidcontact) > 0)
1016 1016
 		 	{
1017 1017
 		 		$object->fetch_user(reset($arrayidcontact));
1018
-		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1018
+		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1019 1019
 		 	}
1020 1020
 
1021 1021
 		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1022 1022
 
1023 1023
 			// Show sender
1024
-			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1025
-			$posx=$this->marge_gauche;
1026
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1024
+			$posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1025
+			$posx = $this->marge_gauche;
1026
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1027 1027
 
1028
-			$hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1029
-			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1028
+			$hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1029
+			$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1030 1030
 
1031 1031
 			// Show sender frame
1032
-			$pdf->SetTextColor(0,0,0);
1033
-			$pdf->SetFont('','', $default_font_size - 2);
1034
-			$pdf->SetXY($posx,$posy-5);
1035
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("Sender").":", 0, 'L');
1036
-			$pdf->SetXY($posx,$posy);
1037
-			$pdf->SetFillColor(230,230,230);
1032
+			$pdf->SetTextColor(0, 0, 0);
1033
+			$pdf->SetFont('', '', $default_font_size - 2);
1034
+			$pdf->SetXY($posx, $posy - 5);
1035
+			$pdf->MultiCell(66, 5, $outputlangs->transnoentities("Sender").":", 0, 'L');
1036
+			$pdf->SetXY($posx, $posy);
1037
+			$pdf->SetFillColor(230, 230, 230);
1038 1038
 			$pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
1039
-			$pdf->SetTextColor(0,0,60);
1040
-			$pdf->SetFillColor(255,255,255);
1039
+			$pdf->SetTextColor(0, 0, 60);
1040
+			$pdf->SetFillColor(255, 255, 255);
1041 1041
 
1042 1042
 			// Show sender name
1043
-			$pdf->SetXY($posx+2,$posy+3);
1044
-			$pdf->SetFont('','B',$default_font_size);
1045
-			$pdf->MultiCell($widthrecbox-2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1046
-			$posy=$pdf->getY();
1043
+			$pdf->SetXY($posx + 2, $posy + 3);
1044
+			$pdf->SetFont('', 'B', $default_font_size);
1045
+			$pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1046
+			$posy = $pdf->getY();
1047 1047
 
1048 1048
 			// Show sender information
1049
-			$pdf->SetXY($posx+2,$posy);
1050
-			$pdf->SetFont('','', $default_font_size - 1);
1051
-			$pdf->MultiCell($widthrecbox-2, 4, $carac_emetteur, 0, 'L');
1049
+			$pdf->SetXY($posx + 2, $posy);
1050
+			$pdf->SetFont('', '', $default_font_size - 1);
1051
+			$pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
1052 1052
 
1053 1053
 
1054 1054
 			// If SHIPPING contact defined, we use it
1055
-			$usecontact=false;
1056
-			$arrayidcontact=$object->$origin->getIdContact('external','SHIPPING');
1055
+			$usecontact = false;
1056
+			$arrayidcontact = $object->$origin->getIdContact('external', 'SHIPPING');
1057 1057
 			if (count($arrayidcontact) > 0)
1058 1058
 			{
1059
-				$usecontact=true;
1060
-				$result=$object->fetch_contact($arrayidcontact[0]);
1059
+				$usecontact = true;
1060
+				$result = $object->fetch_contact($arrayidcontact[0]);
1061 1061
 			}
1062 1062
 
1063 1063
 			//Recipient name
@@ -1068,38 +1068,38 @@  discard block
 block discarded – undo
1068 1068
 				$thirdparty = $object->thirdparty;
1069 1069
 			}
1070 1070
 
1071
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1071
+			$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1072 1072
 
1073
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,(!empty($object->contact)?$object->contact:null),$usecontact,'targetwithdetails',$object);
1073
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
1074 1074
 
1075 1075
 			// Show recipient
1076
-			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1077
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1078
-			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1079
-			$posx=$this->page_largeur - $this->marge_droite - $widthrecbox;
1080
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1076
+			$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1077
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1078
+			$posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1079
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1080
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1081 1081
 
1082 1082
 			// Show recipient frame
1083
-			$pdf->SetTextColor(0,0,0);
1084
-			$pdf->SetFont('','', $default_font_size - 2);
1085
-			$pdf->SetXY($posx+2,$posy-5);
1083
+			$pdf->SetTextColor(0, 0, 0);
1084
+			$pdf->SetFont('', '', $default_font_size - 2);
1085
+			$pdf->SetXY($posx + 2, $posy - 5);
1086 1086
 			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L');
1087 1087
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1088 1088
 
1089 1089
 			// Show recipient name
1090
-			$pdf->SetXY($posx+2,$posy+3);
1091
-			$pdf->SetFont('','B', $default_font_size);
1090
+			$pdf->SetXY($posx + 2, $posy + 3);
1091
+			$pdf->SetFont('', 'B', $default_font_size);
1092 1092
 			$pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
1093 1093
 
1094 1094
 			$posy = $pdf->getY();
1095 1095
 
1096 1096
 			// Show recipient information
1097
-			$pdf->SetFont('','', $default_font_size - 1);
1098
-			$pdf->SetXY($posx+2,$posy);
1097
+			$pdf->SetFont('', '', $default_font_size - 1);
1098
+			$pdf->SetXY($posx + 2, $posy);
1099 1099
 			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1100 1100
 		}
1101 1101
 
1102
-		$pdf->SetTextColor(0,0,0);
1102
+		$pdf->SetTextColor(0, 0, 0);
1103 1103
 	}
1104 1104
 
1105 1105
 	/**
@@ -1111,10 +1111,10 @@  discard block
 block discarded – undo
1111 1111
 	 *      @param	int			$hidefreetext		1=Hide free text
1112 1112
 	 *      @return	int								Return height of bottom margin including footer text
1113 1113
 	 */
1114
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1114
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1115 1115
 	{
1116 1116
 		global $conf;
1117
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1118
-		return pdf_pagefoot($pdf,$outputlangs,'SHIPPING_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1117
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1118
+		return pdf_pagefoot($pdf, $outputlangs, 'SHIPPING_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1119 1119
 	}
1120 1120
 }
Please login to merge, or discard this patch.
Braces   +138 added lines, -70 removed lines patch added patch discarded remove patch
@@ -137,7 +137,10 @@  discard block
 block discarded – undo
137 137
 
138 138
 		// Get source company
139 139
 		$this->emetteur=$mysoc;
140
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
140
+		if (! $this->emetteur->country_code) {
141
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
142
+		}
143
+		// By default if not defined
141 144
 
142 145
 		// Define position of columns
143 146
 		$this->posxdesc=$this->marge_gauche+1;
@@ -156,9 +159,11 @@  discard block
 block discarded – undo
156 159
 
157 160
 		$this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
158 161
 
159
-		if ($this->page_largeur < 210) // To work with US executive format
162
+		if ($this->page_largeur < 210) {
163
+		    // To work with US executive format
160 164
 		{
161 165
 		    $this->posxweightvol-=20;
166
+		}
162 167
 		    $this->posxpicture-=20;
163 168
 		    $this->posxqtyordered-=20;
164 169
 		    $this->posxqtytoship-=20;
@@ -191,9 +196,13 @@  discard block
 block discarded – undo
191 196
 
192 197
 		$object->fetch_thirdparty();
193 198
 
194
-		if (! is_object($outputlangs)) $outputlangs=$langs;
199
+		if (! is_object($outputlangs)) {
200
+		    $outputlangs=$langs;
201
+		}
195 202
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
196
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
203
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
204
+		    $outputlangs->charset_output='ISO-8859-1';
205
+		}
197 206
 
198 207
 		// Load traductions files requiredby by page
199 208
 		$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
@@ -208,7 +217,9 @@  discard block
 block discarded – undo
208 217
 
209 218
             for ($i = 0 ; $i < $nblignes ; $i++)
210 219
             {
211
-                if (empty($object->lines[$i]->fk_product)) continue;
220
+                if (empty($object->lines[$i]->fk_product)) {
221
+                    continue;
222
+                }
212 223
 
213 224
 				$objphoto = new Product($this->db);
214 225
 				$objphoto->fetch($object->lines[$i]->fk_product);
@@ -220,18 +231,18 @@  discard block
 block discarded – undo
220 231
 
221 232
                 foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
222 233
                         {
223
-                            if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
234
+                            if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
235
+                                // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
224 236
                             {
225 237
                                 if ($obj['photo_vignette'])
226 238
                                 {
227 239
                                     $filename= $obj['photo_vignette'];
228
-                                }
229
-                                else
240
+                            }
241
+                                } else
230 242
                                 {
231 243
                                     $filename=$obj['photo'];
232 244
                                 }
233
-                            }
234
-                            else
245
+                            } else
235 246
                             {
236 247
                                 $filename=$obj['photo'];
237 248
                             }
@@ -240,11 +251,15 @@  discard block
 block discarded – undo
240 251
                             break;
241 252
                 }
242 253
 
243
-                if ($realpath) $realpatharray[$i]=$realpath;
254
+                if ($realpath) {
255
+                    $realpatharray[$i]=$realpath;
256
+                }
244 257
             }
245 258
         }
246 259
 
247
-        if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol;
260
+        if (count($realpatharray) == 0) {
261
+            $this->posxpicture=$this->posxweightvol;
262
+        }
248 263
 
249 264
 		if ($conf->expedition->dir_output)
250 265
 		{
@@ -253,8 +268,7 @@  discard block
 block discarded – undo
253 268
 			{
254 269
 				$dir = $conf->expedition->dir_output."/sending";
255 270
 				$file = $dir . "/SPECIMEN.pdf";
256
-			}
257
-			else
271
+			} else
258 272
 			{
259 273
 				$expref = dol_sanitizeFileName($object->ref);
260 274
 				$dir = $conf->expedition->dir_output."/sending/" . $expref;
@@ -291,7 +305,9 @@  discard block
 block discarded – undo
291 305
 				$heightforinfotot = 8;	// Height reserved to output the info and total part
292 306
 		        $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
293 307
 	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
294
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
308
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) {
309
+	                $heightforfooter+= 6;
310
+	            }
295 311
                 $pdf->SetAutoPageBreak(1,0);
296 312
 
297 313
                 if (class_exists('TCPDF'))
@@ -311,20 +327,26 @@  discard block
 block discarded – undo
311 327
 				$pagenb=0;
312 328
 				$pdf->SetDrawColor(128,128,128);
313 329
 
314
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
330
+				if (method_exists($pdf,'AliasNbPages')) {
331
+				    $pdf->AliasNbPages();
332
+				}
315 333
 
316 334
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
317 335
 				$pdf->SetSubject($outputlangs->transnoentities("Shipment"));
318 336
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
319 337
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
320 338
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
321
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
339
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
340
+				    $pdf->SetCompression(false);
341
+				}
322 342
 
323 343
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
324 344
 
325 345
 				// New page
326 346
 				$pdf->AddPage();
327
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
347
+				if (! empty($tplidx)) {
348
+				    $pdf->useTemplate($tplidx);
349
+				}
328 350
 				$pagenb++;
329 351
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
330 352
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -381,7 +403,9 @@  discard block
 block discarded – undo
381 403
 								// Get code using getLabelFromKey
382 404
 								$code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code');
383 405
 								$label='';
384
-								if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>";
406
+								if ($object->tracking_url != $object->tracking_number) {
407
+								    $label.=$outputlangs->trans("LinkToTrackYourPackage")."<br>";
408
+								}
385 409
 								$label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
386 410
 								//var_dump($object->tracking_url != $object->tracking_number);exit;
387 411
 								if ($object->tracking_url != $object->tracking_number)
@@ -413,8 +437,7 @@  discard block
 block discarded – undo
413 437
 
414 438
 					$tab_height = $tab_height - $height_note;
415 439
 					$tab_top = $nexY+6;
416
-				}
417
-				else
440
+				} else
418 441
 				{
419 442
 					$height_note=0;
420 443
 				}
@@ -432,7 +455,9 @@  discard block
 block discarded – undo
432 455
 
433 456
 					// Define size of image if we need it
434 457
 					$imglinesize=array();
435
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
458
+					if (! empty($realpatharray[$i])) {
459
+					    $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
460
+					}
436 461
 
437 462
 					$pdf->setTopMargin($tab_top_newpage);
438 463
 					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
@@ -443,11 +468,17 @@  discard block
 block discarded – undo
443 468
 					$posYAfterDescription=0;
444 469
 
445 470
 					// We start with Photo of product line
446
-					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
471
+					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) {
472
+					    // If photo too high, we moved completely on new page
447 473
 					{
448 474
 						$pdf->AddPage('','',true);
449
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
450
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
475
+					}
476
+						if (! empty($tplidx)) {
477
+						    $pdf->useTemplate($tplidx);
478
+						}
479
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
480
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
481
+						}
451 482
 						$pdf->setPage($pageposbefore+1);
452 483
 
453 484
 						$curY = $tab_top_newpage;
@@ -469,9 +500,11 @@  discard block
 block discarded – undo
469 500
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
470 501
 
471 502
 					$pageposafter=$pdf->getPage();
472
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
503
+					if ($pageposafter > $pageposbefore) {
504
+					    // There is a pagebreak
473 505
 					{
474 506
 						$pdf->rollbackTransaction(true);
507
+					}
475 508
 						$pageposafter=$pageposbefore;
476 509
 						//print $pageposafter.'-'.$pageposbefore;exit;
477 510
 						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -480,23 +513,27 @@  discard block
 block discarded – undo
480 513
 						$pageposafter=$pdf->getPage();
481 514
 						$posyafter=$pdf->GetY();
482 515
 						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
483
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
516
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
517
+						    // There is no space left for total+free text
484 518
 						{
485 519
 							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
486 520
 							{
487 521
 								$pdf->AddPage('','',true);
488
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
489
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
522
+						}
523
+								if (! empty($tplidx)) {
524
+								    $pdf->useTemplate($tplidx);
525
+								}
526
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
527
+								    $this->_pagehead($pdf, $object, 0, $outputlangs);
528
+								}
490 529
 								$pdf->setPage($pageposafter+1);
491 530
 							}
492
-						}
493
-						else
531
+						} else
494 532
 						{
495 533
 							// We found a page break
496 534
 							$showpricebeforepagebreak=0;
497 535
 						}
498
-					}
499
-					else	// No pagebreak
536
+					} else	// No pagebreak
500 537
 					{
501 538
 						$pdf->commitTransaction();
502 539
 					}
@@ -561,7 +598,9 @@  discard block
 block discarded – undo
561 598
 					}
562 599
 
563 600
 					$nexY+=3;
564
-					if ($weighttxt && $voltxt) $nexY+=2;
601
+					if ($weighttxt && $voltxt) {
602
+					    $nexY+=2;
603
+					}
565 604
 
566 605
 					// Add line
567 606
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
@@ -580,8 +619,7 @@  discard block
 block discarded – undo
580 619
 						if ($pagenb == 1)
581 620
 						{
582 621
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
583
-						}
584
-						else
622
+						} else
585 623
 						{
586 624
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
587 625
 						}
@@ -589,24 +627,29 @@  discard block
 block discarded – undo
589 627
 						$pagenb++;
590 628
 						$pdf->setPage($pagenb);
591 629
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
592
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
630
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
631
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
632
+						}
593 633
 					}
594 634
 					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
595 635
 					{
596 636
 						if ($pagenb == 1)
597 637
 						{
598 638
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
599
-						}
600
-						else
639
+						} else
601 640
 						{
602 641
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
603 642
 						}
604 643
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
605 644
 						// New page
606 645
 						$pdf->AddPage();
607
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
646
+						if (! empty($tplidx)) {
647
+						    $pdf->useTemplate($tplidx);
648
+						}
608 649
 						$pagenb++;
609
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
650
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
651
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
652
+						}
610 653
 					}
611 654
 				}
612 655
 
@@ -615,8 +658,7 @@  discard block
 block discarded – undo
615 658
 				{
616 659
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
617 660
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
618
-				}
619
-				else
661
+				} else
620 662
 				{
621 663
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
622 664
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
@@ -627,7 +669,9 @@  discard block
 block discarded – undo
627 669
 
628 670
 				// Pied de page
629 671
 				$this->_pagefoot($pdf,$object,$outputlangs);
630
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
672
+				if (method_exists($pdf,'AliasNbPages')) {
673
+				    $pdf->AliasNbPages();
674
+				}
631 675
 
632 676
 				$pdf->Close();
633 677
 
@@ -639,20 +683,19 @@  discard block
 block discarded – undo
639 683
 				global $action;
640 684
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
641 685
 
642
-				if (! empty($conf->global->MAIN_UMASK))
643
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
686
+				if (! empty($conf->global->MAIN_UMASK)) {
687
+								@chmod($file, octdec($conf->global->MAIN_UMASK));
688
+				}
644 689
 
645 690
 				$this->result = array('fullpath'=>$file);
646 691
 
647 692
 				return 1;	// No error
648
-			}
649
-			else
693
+			} else
650 694
 			{
651 695
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
652 696
 				return 0;
653 697
 			}
654
-		}
655
-		else
698
+		} else
656 699
 		{
657 700
 			$this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
658 701
 			return 0;
@@ -689,8 +732,11 @@  discard block
 block discarded – undo
689 732
 		{
690 733
 			$col2x-=20;
691 734
 		}*/
692
-		if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
693
-		else $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
735
+		if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) {
736
+		    $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
737
+		} else {
738
+		    $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
739
+		}
694 740
 
695 741
 		$useborder=0;
696 742
 		$index = 0;
@@ -711,10 +757,18 @@  discard block
 block discarded – undo
711 757
 		    $object->volume_units=$object->size_units * 3;
712 758
 		}
713 759
 
714
-		if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
715
-		if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
716
-		if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
717
-		if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
760
+		if ($totalWeight!='') {
761
+		    $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
762
+		}
763
+		if ($totalVolume!='') {
764
+		    $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
765
+		}
766
+		if ($object->trueWeight) {
767
+		    $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
768
+		}
769
+		if ($object->trueVolume) {
770
+		    $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
771
+		}
718 772
 
719 773
     	$pdf->SetFillColor(255,255,255);
720 774
     	$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -758,7 +812,9 @@  discard block
 block discarded – undo
758 812
 
759 813
 			    $index++;
760 814
 			}
761
-			if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++;
815
+			if (! $totalWeighttoshow && ! $totalVolumetoshow) {
816
+			    $index++;
817
+			}
762 818
 		}
763 819
 
764 820
 		$pdf->SetTextColor(0,0,0);
@@ -784,7 +840,9 @@  discard block
 block discarded – undo
784 840
 
785 841
 		// Force to disable hidetop and hidebottom
786 842
 		$hidebottom=0;
787
-		if ($hidetop) $hidetop=-1;
843
+		if ($hidetop) {
844
+		    $hidetop=-1;
845
+		}
788 846
 
789 847
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
790 848
 
@@ -898,16 +956,14 @@  discard block
 block discarded – undo
898 956
 			{
899 957
 			    $height=pdf_getHeightForLogo($logo);
900 958
 			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
901
-			}
902
-			else
959
+			} else
903 960
 			{
904 961
 				$pdf->SetTextColor(200,0,0);
905 962
 				$pdf->SetFont('','B', $default_font_size - 2);
906 963
 				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
907 964
 				$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
908 965
 			}
909
-		}
910
-		else
966
+		} else
911 967
 		{
912 968
 			$text=$this->emetteur->name;
913 969
 			$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -917,8 +973,7 @@  discard block
 block discarded – undo
917 973
 		if (! empty($conf->barcode->enabled))
918 974
 		{
919 975
 			$posx=105;
920
-		}
921
-		else
976
+		} else
922 977
 		{
923 978
 			$posx=$this->marge_gauche+3;
924 979
 		}
@@ -982,9 +1037,11 @@  discard block
 block discarded – undo
982 1037
 		$origin_id 	= $object->origin_id;
983 1038
 
984 1039
 	    // TODO move to external function
985
-		if (! empty($conf->$origin->enabled))     // commonly $origin='commande'
1040
+		if (! empty($conf->$origin->enabled)) {
1041
+		    // commonly $origin='commande'
986 1042
 		{
987 1043
 			$outputlangs->load('orders');
1044
+		}
988 1045
 
989 1046
 			$classname = ucfirst($origin);
990 1047
 			$linkedobject = new $classname($this->db);
@@ -995,7 +1052,9 @@  discard block
 block discarded – undo
995 1052
 
996 1053
 				$pdf->SetFont('','', $default_font_size - 2);
997 1054
 				$text=$linkedobject->ref;
998
-				if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')';
1055
+				if ($linkedobject->ref_client) {
1056
+				    $text.=' ('.$linkedobject->ref_client.')';
1057
+				}
999 1058
 				$Yoff = $Yoff+8;
1000 1059
 				$pdf->SetXY($this->page_largeur - $this->marge_droite - $w,$Yoff);
1001 1060
 				$pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R');
@@ -1011,7 +1070,9 @@  discard block
 block discarded – undo
1011 1070
 			$carac_emetteur='';
1012 1071
 		 	// Add internal contact of origin element if defined
1013 1072
 			$arrayidcontact=array();
1014
-			if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL');
1073
+			if (! empty($origin) && is_object($object->$origin)) {
1074
+			    $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL');
1075
+			}
1015 1076
 		 	if (count($arrayidcontact) > 0)
1016 1077
 		 	{
1017 1078
 		 		$object->fetch_user(reset($arrayidcontact));
@@ -1023,7 +1084,9 @@  discard block
 block discarded – undo
1023 1084
 			// Show sender
1024 1085
 			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1025 1086
 			$posx=$this->marge_gauche;
1026
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1087
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1088
+			    $posx=$this->page_largeur-$this->marge_droite-80;
1089
+			}
1027 1090
 
1028 1091
 			$hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1029 1092
 			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
@@ -1074,10 +1137,15 @@  discard block
 block discarded – undo
1074 1137
 
1075 1138
 			// Show recipient
1076 1139
 			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1077
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1140
+			if ($this->page_largeur < 210) {
1141
+			    $widthrecbox=84;
1142
+			}
1143
+			// To work with US executive format
1078 1144
 			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1079 1145
 			$posx=$this->page_largeur - $this->marge_droite - $widthrecbox;
1080
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1146
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1147
+			    $posx=$this->marge_gauche;
1148
+			}
1081 1149
 
1082 1150
 			// Show recipient frame
1083 1151
 			$pdf->SetTextColor(0,0,0);
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/expedition/doc/pdf_merou.modules.php 3 patches
Indentation   +590 added lines, -590 removed lines patch added patch discarded remove patch
@@ -42,197 +42,197 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public $db;
44 44
 
45
-	/**
45
+    /**
46 46
      * @var string model name
47 47
      */
48 48
     public $name;
49 49
 
50
-	/**
50
+    /**
51 51
      * @var string model description (short text)
52 52
      */
53 53
     public $description;
54 54
 
55
-	/**
55
+    /**
56 56
      * @var string document type
57 57
      */
58 58
     public $type;
59 59
 
60
-	/**
60
+    /**
61 61
      * @var array() Minimum version of PHP required by module.
62
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
62
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
63 63
      */
64
-	public $phpmin = array(5, 4);
64
+    public $phpmin = array(5, 4);
65 65
 
66
-	/**
66
+    /**
67 67
      * Dolibarr version of the loaded document
68 68
      * @public string
69 69
      */
70
-	public $version = 'dolibarr';
70
+    public $version = 'dolibarr';
71 71
 
72
-	/**
72
+    /**
73 73
      * @var int page_largeur
74 74
      */
75 75
     public $page_largeur;
76 76
 
77
-	/**
77
+    /**
78 78
      * @var int page_hauteur
79 79
      */
80 80
     public $page_hauteur;
81 81
 
82
-	/**
82
+    /**
83 83
      * @var array format
84 84
      */
85 85
     public $format;
86 86
 
87
-	/**
87
+    /**
88 88
      * @var int marge_gauche
89 89
      */
90
-	public $marge_gauche;
90
+    public $marge_gauche;
91 91
 
92
-	/**
92
+    /**
93 93
      * @var int marge_droite
94 94
      */
95
-	public $marge_droite;
95
+    public $marge_droite;
96 96
 
97
-	/**
97
+    /**
98 98
      * @var int marge_haute
99 99
      */
100
-	public $marge_haute;
100
+    public $marge_haute;
101 101
 
102
-	/**
102
+    /**
103 103
      * @var int marge_basse
104 104
      */
105
-	public $marge_basse;
106
-
107
-	/**
108
-	 * Issuer
109
-	 * @var Societe
110
-	 */
111
-	public $emetteur;
112
-
113
-
114
-	/**
115
-	 *	Constructor
116
-	 *
117
-	 *  @param		DoliDB		$db      Database handler
118
-	 */
119
-	function __construct($db=0)
120
-	{
121
-		global $conf,$langs,$mysoc;
122
-
123
-		$this->db = $db;
124
-		$this->name = "merou";
125
-		$this->description = $langs->trans("DocumentModelMerou");
126
-
127
-		$this->type = 'pdf';
128
-		$formatarray=pdf_getFormat();
129
-		$this->page_largeur = $formatarray['width'];
130
-		$this->page_hauteur = round($formatarray['height']/2);
131
-		$this->format = array($this->page_largeur,$this->page_hauteur);
132
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
133
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
134
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
135
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
136
-
137
-		$this->option_logo = 1;
138
-
139
-		// Get source company
140
-		$this->emetteur=$mysoc;
141
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
142
-	}
105
+    public $marge_basse;
106
+
107
+    /**
108
+     * Issuer
109
+     * @var Societe
110
+     */
111
+    public $emetteur;
112
+
113
+
114
+    /**
115
+     *	Constructor
116
+     *
117
+     *  @param		DoliDB		$db      Database handler
118
+     */
119
+    function __construct($db=0)
120
+    {
121
+        global $conf,$langs,$mysoc;
122
+
123
+        $this->db = $db;
124
+        $this->name = "merou";
125
+        $this->description = $langs->trans("DocumentModelMerou");
126
+
127
+        $this->type = 'pdf';
128
+        $formatarray=pdf_getFormat();
129
+        $this->page_largeur = $formatarray['width'];
130
+        $this->page_hauteur = round($formatarray['height']/2);
131
+        $this->format = array($this->page_largeur,$this->page_hauteur);
132
+        $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
133
+        $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
134
+        $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
135
+        $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
136
+
137
+        $this->option_logo = 1;
138
+
139
+        // Get source company
140
+        $this->emetteur=$mysoc;
141
+        if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
142
+    }
143 143
 
144 144
 
145 145
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
146
-	/**
147
-	 *	Function to build pdf onto disk
148
-	 *
149
-	 *	@param		Object		$object			Object expedition to generate (or id if old method)
150
-	 *	@param		Translate	$outputlangs		Lang output object
146
+    /**
147
+     *	Function to build pdf onto disk
148
+     *
149
+     *	@param		Object		$object			Object expedition to generate (or id if old method)
150
+     *	@param		Translate	$outputlangs		Lang output object
151 151
      *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
152 152
      *  @param		int			$hidedetails		Do not show line details
153 153
      *  @param		int			$hidedesc			Do not show desc
154 154
      *  @param		int			$hideref			Do not show ref
155 155
      *  @return     int         	    			1=OK, 0=KO
156
-	 */
157
-	function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
158
-	{
156
+     */
157
+    function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
158
+    {
159 159
         // phpcs:enable
160
-		global $user,$conf,$langs,$mysoc,$hookmanager;
160
+        global $user,$conf,$langs,$mysoc,$hookmanager;
161 161
 
162
-		$object->fetch_thirdparty();
162
+        $object->fetch_thirdparty();
163 163
 
164
-		if (! is_object($outputlangs)) $outputlangs=$langs;
165
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
166
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
164
+        if (! is_object($outputlangs)) $outputlangs=$langs;
165
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
166
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
167 167
 
168
-		// Load traductions files requiredby by page
169
-		$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
168
+        // Load traductions files requiredby by page
169
+        $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
170 170
 
171
-		if ($conf->expedition->dir_output)
172
-		{
173
-			$object->fetch_thirdparty();
171
+        if ($conf->expedition->dir_output)
172
+        {
173
+            $object->fetch_thirdparty();
174 174
 
175
-			$origin = $object->origin;
175
+            $origin = $object->origin;
176 176
 
177
-			//Creation de l expediteur
178
-			$this->expediteur = $mysoc;
177
+            //Creation de l expediteur
178
+            $this->expediteur = $mysoc;
179 179
 
180
-			//Creation du destinataire
181
-			$idcontact = $object->$origin->getIdContact('external','SHIPPING');
180
+            //Creation du destinataire
181
+            $idcontact = $object->$origin->getIdContact('external','SHIPPING');
182 182
             $this->destinataire = new Contact($this->db);
183
-			if (! empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]);
184
-
185
-			//Creation du livreur
186
-			$idcontact = $object->$origin->getIdContact('internal','LIVREUR');
187
-			$this->livreur = new User($this->db);
188
-			if (! empty($idcontact[0])) $this->livreur->fetch($idcontact[0]);
189
-
190
-			// Definition de $dir et $file
191
-			if ($object->specimen)
192
-			{
193
-				$dir = $conf->expedition->dir_output."/sending";
194
-				$file = $dir . "/SPECIMEN.pdf";
195
-			}
196
-			else
197
-			{
198
-				$expref = dol_sanitizeFileName($object->ref);
199
-				$dir = $conf->expedition->dir_output . "/sending/" . $expref;
200
-				$file = $dir . "/" . $expref . ".pdf";
201
-			}
202
-
203
-			if (! file_exists($dir))
204
-			{
205
-				if (dol_mkdir($dir) < 0)
206
-				{
207
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
208
-					return 0;
209
-				}
210
-			}
211
-
212
-			if (file_exists($dir))
213
-			{
214
-				// Add pdfgeneration hook
215
-				if (! is_object($hookmanager))
216
-				{
217
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
218
-					$hookmanager=new HookManager($this->db);
219
-				}
220
-				$hookmanager->initHooks(array('pdfgeneration'));
221
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
222
-				global $action;
223
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
224
-
225
-				$nblignes = count($object->lines);
226
-
227
-				$pdf=pdf_getInstance($this->format,'mm','l');
228
-				$default_font_size = pdf_getPDFFontSize($outputlangs);
229
-				$heightforinfotot = 0;	// Height reserved to output the info and total part
230
-		        $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
231
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
232
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
183
+            if (! empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]);
184
+
185
+            //Creation du livreur
186
+            $idcontact = $object->$origin->getIdContact('internal','LIVREUR');
187
+            $this->livreur = new User($this->db);
188
+            if (! empty($idcontact[0])) $this->livreur->fetch($idcontact[0]);
189
+
190
+            // Definition de $dir et $file
191
+            if ($object->specimen)
192
+            {
193
+                $dir = $conf->expedition->dir_output."/sending";
194
+                $file = $dir . "/SPECIMEN.pdf";
195
+            }
196
+            else
197
+            {
198
+                $expref = dol_sanitizeFileName($object->ref);
199
+                $dir = $conf->expedition->dir_output . "/sending/" . $expref;
200
+                $file = $dir . "/" . $expref . ".pdf";
201
+            }
202
+
203
+            if (! file_exists($dir))
204
+            {
205
+                if (dol_mkdir($dir) < 0)
206
+                {
207
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
208
+                    return 0;
209
+                }
210
+            }
211
+
212
+            if (file_exists($dir))
213
+            {
214
+                // Add pdfgeneration hook
215
+                if (! is_object($hookmanager))
216
+                {
217
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
218
+                    $hookmanager=new HookManager($this->db);
219
+                }
220
+                $hookmanager->initHooks(array('pdfgeneration'));
221
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
222
+                global $action;
223
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
224
+
225
+                $nblignes = count($object->lines);
226
+
227
+                $pdf=pdf_getInstance($this->format,'mm','l');
228
+                $default_font_size = pdf_getPDFFontSize($outputlangs);
229
+                $heightforinfotot = 0;	// Height reserved to output the info and total part
230
+                $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
231
+                $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
232
+                if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
233 233
                 $pdf->SetAutoPageBreak(1,0);
234 234
 
235
-			    if (class_exists('TCPDF'))
235
+                if (class_exists('TCPDF'))
236 236
                 {
237 237
                     $pdf->setPrintHeader(false);
238 238
                     $pdf->setPrintFooter(false);
@@ -245,483 +245,483 @@  discard block
 block discarded – undo
245 245
                     $tplidx = $pdf->importPage(1);
246 246
                 }
247 247
 
248
-				$pdf->Open();
249
-				$pagenb=0;
250
-				$pdf->SetDrawColor(128,128,128);
251
-
252
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
253
-
254
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
255
-				$pdf->SetSubject($outputlangs->transnoentities("Shipment"));
256
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
257
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
258
-				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
259
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
260
-
261
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
262
-
263
-				// New page
264
-				$pdf->AddPage();
265
-				$pagenb++;
266
-				$this->_pagehead($pdf, $object, 1, $outputlangs);
267
-				$pdf->SetFont('','', $default_font_size - 3);
268
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
269
-				$pdf->SetTextColor(0,0,0);
270
-
271
-				$tab_top = 52;
272
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
273
-				$tab_height = $this->page_hauteur - $tab_top - $heightforfooter;
274
-				$tab_height_newpage = $this->page_hauteur - $tab_top_newpage - $heightforfooter;
275
-
276
-				// Affiche notes
277
-				if (! empty($object->note_public))
278
-				{
279
-					$pdf->SetFont('','', $default_font_size - 1);
280
-					$pdf->writeHTMLCell(190, 3, $this->marge_gauche, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
281
-					$nexY = $pdf->GetY();
282
-					$height_note=$nexY-$tab_top;
283
-
284
-					// Rect prend une longueur en 3eme param
285
-					$pdf->SetDrawColor(192,192,192);
286
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
287
-
288
-					$tab_height = $tab_height - $height_note;
289
-					$tab_top = $nexY+6;
290
-				}
291
-				else
292
-				{
293
-					$height_note=0;
294
-				}
295
-
296
-
297
-				$pdf->SetFillColor(240,240,240);
298
-				$pdf->SetTextColor(0,0,0);
299
-				$pdf->SetXY(10, $tab_top + 5);
300
-
301
-				$iniY = $tab_top + 7;
302
-				$curY = $tab_top + 7;
303
-				$nexY = $tab_top + 7;
304
-
305
-				$num=count($object->lines);
306
-				// Loop on each lines
307
-				for ($i = 0; $i < $num; $i++)
308
-				{
309
-					$curY = $nexY;
310
-					$pdf->SetFont('','', $default_font_size - 3);
311
-					$pdf->SetTextColor(0,0,0);
312
-
313
-					$pdf->setTopMargin($tab_top_newpage);
314
-					$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
315
-					$pageposbefore=$pdf->getPage();
316
-
317
-					// Description de la ligne produit
318
-					$libelleproduitservice = pdf_writelinedesc($pdf,$object,$i,$outputlangs,90,3,50,$curY,0,1);
319
-
320
-					$nexY = $pdf->GetY();
321
-					$pageposafter=$pdf->getPage();
322
-					$pdf->setPage($pageposbefore);
323
-					$pdf->setTopMargin($this->marge_haute);
324
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
325
-
326
-					// We suppose that a too long description is moved completely on next page
327
-					if ($pageposafter > $pageposbefore) {
328
-						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
329
-					}
330
-
331
-					$pdf->SetFont('','', $default_font_size - 3);
332
-
333
-					// Check boxes
334
-					$pdf->SetDrawColor(120,120,120);
335
-					$pdf->Rect(10+3, $curY, 3, 3);
336
-					$pdf->Rect(20+3, $curY, 3, 3);
337
-
338
-					//Insertion de la reference du produit
339
-					$pdf->SetXY(30, $curY);
340
-					$pdf->SetFont('','B', $default_font_size - 3);
341
-					$pdf->MultiCell(24, 3, $outputlangs->convToOutputCharset($object->lines[$i]->ref), 0, 'L', 0);
342
-
343
-					$pdf->SetXY(140, $curY);
344
-					$pdf->MultiCell(30, 3, $object->lines[$i]->qty_asked, 0, 'C', 0);
345
-
346
-					$pdf->SetXY(170, $curY);
347
-					$pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped, 0, 'C', 0);
348
-
349
-					// Add line
350
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
351
-					{
352
-						$pdf->setPage($pageposafter);
353
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
354
-						//$pdf->SetDrawColor(190,190,200);
355
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
356
-						$pdf->SetLineStyle(array('dash'=>0));
357
-					}
358
-
359
-					$nexY+=2;    // Passe espace entre les lignes
360
-
361
-					// Detect if some page were added automatically and output _tableau for past pages
362
-					while ($pagenb < $pageposafter)
363
-					{
364
-						$pdf->setPage($pagenb);
365
-						if ($pagenb == 1)
366
-						{
367
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
368
-						}
369
-						else
370
-						{
371
-							$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
372
-						}
373
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
374
-						$pagenb++;
375
-						$pdf->setPage($pagenb);
376
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
377
-					}
378
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
379
-					{
380
-						if ($pagenb == 1)
381
-						{
382
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
383
-						}
384
-						else
385
-						{
386
-							$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
387
-						}
388
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
389
-						// New page
390
-						$pdf->AddPage();
391
-						$pagenb++;
392
-					}
393
-				}
394
-
395
-				// Show square
396
-				if ($pagenb == 1)
397
-				{
398
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
399
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
400
-				}
401
-				else
402
-				{
403
-					$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
404
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
405
-				}
406
-
407
-				// Pied de page
408
-				$this->_pagefoot($pdf, $object, $outputlangs);
409
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
410
-
411
-				$pdf->Close();
412
-
413
-				$pdf->Output($file,'F');
414
-
415
-				// Add pdfgeneration hook
416
-				if (! is_object($hookmanager))
417
-				{
418
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
419
-					$hookmanager=new HookManager($this->db);
420
-				}
421
-				$hookmanager->initHooks(array('pdfgeneration'));
422
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
423
-				global $action;
424
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
248
+                $pdf->Open();
249
+                $pagenb=0;
250
+                $pdf->SetDrawColor(128,128,128);
251
+
252
+                if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
253
+
254
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
255
+                $pdf->SetSubject($outputlangs->transnoentities("Shipment"));
256
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
257
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
258
+                $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
259
+                if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
260
+
261
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
262
+
263
+                // New page
264
+                $pdf->AddPage();
265
+                $pagenb++;
266
+                $this->_pagehead($pdf, $object, 1, $outputlangs);
267
+                $pdf->SetFont('','', $default_font_size - 3);
268
+                $pdf->MultiCell(0, 3, '');		// Set interline to 3
269
+                $pdf->SetTextColor(0,0,0);
270
+
271
+                $tab_top = 52;
272
+                $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
273
+                $tab_height = $this->page_hauteur - $tab_top - $heightforfooter;
274
+                $tab_height_newpage = $this->page_hauteur - $tab_top_newpage - $heightforfooter;
275
+
276
+                // Affiche notes
277
+                if (! empty($object->note_public))
278
+                {
279
+                    $pdf->SetFont('','', $default_font_size - 1);
280
+                    $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
281
+                    $nexY = $pdf->GetY();
282
+                    $height_note=$nexY-$tab_top;
283
+
284
+                    // Rect prend une longueur en 3eme param
285
+                    $pdf->SetDrawColor(192,192,192);
286
+                    $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
287
+
288
+                    $tab_height = $tab_height - $height_note;
289
+                    $tab_top = $nexY+6;
290
+                }
291
+                else
292
+                {
293
+                    $height_note=0;
294
+                }
295
+
296
+
297
+                $pdf->SetFillColor(240,240,240);
298
+                $pdf->SetTextColor(0,0,0);
299
+                $pdf->SetXY(10, $tab_top + 5);
300
+
301
+                $iniY = $tab_top + 7;
302
+                $curY = $tab_top + 7;
303
+                $nexY = $tab_top + 7;
304
+
305
+                $num=count($object->lines);
306
+                // Loop on each lines
307
+                for ($i = 0; $i < $num; $i++)
308
+                {
309
+                    $curY = $nexY;
310
+                    $pdf->SetFont('','', $default_font_size - 3);
311
+                    $pdf->SetTextColor(0,0,0);
312
+
313
+                    $pdf->setTopMargin($tab_top_newpage);
314
+                    $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
315
+                    $pageposbefore=$pdf->getPage();
316
+
317
+                    // Description de la ligne produit
318
+                    $libelleproduitservice = pdf_writelinedesc($pdf,$object,$i,$outputlangs,90,3,50,$curY,0,1);
319
+
320
+                    $nexY = $pdf->GetY();
321
+                    $pageposafter=$pdf->getPage();
322
+                    $pdf->setPage($pageposbefore);
323
+                    $pdf->setTopMargin($this->marge_haute);
324
+                    $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
325
+
326
+                    // We suppose that a too long description is moved completely on next page
327
+                    if ($pageposafter > $pageposbefore) {
328
+                        $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
329
+                    }
330
+
331
+                    $pdf->SetFont('','', $default_font_size - 3);
332
+
333
+                    // Check boxes
334
+                    $pdf->SetDrawColor(120,120,120);
335
+                    $pdf->Rect(10+3, $curY, 3, 3);
336
+                    $pdf->Rect(20+3, $curY, 3, 3);
337
+
338
+                    //Insertion de la reference du produit
339
+                    $pdf->SetXY(30, $curY);
340
+                    $pdf->SetFont('','B', $default_font_size - 3);
341
+                    $pdf->MultiCell(24, 3, $outputlangs->convToOutputCharset($object->lines[$i]->ref), 0, 'L', 0);
342
+
343
+                    $pdf->SetXY(140, $curY);
344
+                    $pdf->MultiCell(30, 3, $object->lines[$i]->qty_asked, 0, 'C', 0);
345
+
346
+                    $pdf->SetXY(170, $curY);
347
+                    $pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped, 0, 'C', 0);
348
+
349
+                    // Add line
350
+                    if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
351
+                    {
352
+                        $pdf->setPage($pageposafter);
353
+                        $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
354
+                        //$pdf->SetDrawColor(190,190,200);
355
+                        $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
356
+                        $pdf->SetLineStyle(array('dash'=>0));
357
+                    }
358
+
359
+                    $nexY+=2;    // Passe espace entre les lignes
360
+
361
+                    // Detect if some page were added automatically and output _tableau for past pages
362
+                    while ($pagenb < $pageposafter)
363
+                    {
364
+                        $pdf->setPage($pagenb);
365
+                        if ($pagenb == 1)
366
+                        {
367
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
368
+                        }
369
+                        else
370
+                        {
371
+                            $this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
372
+                        }
373
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
374
+                        $pagenb++;
375
+                        $pdf->setPage($pagenb);
376
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
377
+                    }
378
+                    if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
379
+                    {
380
+                        if ($pagenb == 1)
381
+                        {
382
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
383
+                        }
384
+                        else
385
+                        {
386
+                            $this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
387
+                        }
388
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
389
+                        // New page
390
+                        $pdf->AddPage();
391
+                        $pagenb++;
392
+                    }
393
+                }
394
+
395
+                // Show square
396
+                if ($pagenb == 1)
397
+                {
398
+                    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
399
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
400
+                }
401
+                else
402
+                {
403
+                    $this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
404
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
405
+                }
406
+
407
+                // Pied de page
408
+                $this->_pagefoot($pdf, $object, $outputlangs);
409
+                if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
410
+
411
+                $pdf->Close();
412
+
413
+                $pdf->Output($file,'F');
414
+
415
+                // Add pdfgeneration hook
416
+                if (! is_object($hookmanager))
417
+                {
418
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
419
+                    $hookmanager=new HookManager($this->db);
420
+                }
421
+                $hookmanager->initHooks(array('pdfgeneration'));
422
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
423
+                global $action;
424
+                $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
425 425
 
426 426
                 if (! empty($conf->global->MAIN_UMASK))
427 427
                     @chmod($file, octdec($conf->global->MAIN_UMASK));
428 428
 
429
-				$this->result = array('fullpath'=>$file);
430
-
431
-				return 1;
432
-			}
433
-			else
434
-			{
435
-				$this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir",$dir);
436
-				return 0;
437
-			}
438
-		}
439
-		else
440
-		{
441
-			$this->error=$outputlangs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
442
-			return 0;
443
-		}
444
-	}
445
-
446
-	/**
447
-	 *   Show table for lines
448
-	 *
449
-	 *   @param		PDF			$pdf     		Object PDF
450
-	 *   @param		string		$tab_top		Top position of table
451
-	 *   @param		string		$tab_height		Height of table (rectangle)
452
-	 *   @param		int			$nexY			Y
453
-	 *   @param		Translate	$outputlangs	Langs object
454
-	 *   @param		int			$hidetop		Hide top bar of array
455
-	 *   @param		int			$hidebottom		Hide bottom bar of array
456
-	 *   @return	void
457
-	 */
458
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
459
-	{
460
-		global $langs;
461
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
462
-
463
-		// Translations
464
-		$langs->loadLangs(array("main", "bills"));
465
-
466
-		if (empty($hidetop))
467
-		{
468
-			$pdf->SetFont('','B', $default_font_size - 2);
469
-			$pdf->SetXY(10,$tab_top);
470
-			$pdf->MultiCell(10,5,"LS",0,'C',1);
471
-			$pdf->line(20, $tab_top, 20, $tab_top + $tab_height);
472
-			$pdf->SetXY(20,$tab_top);
473
-			$pdf->MultiCell(10,5,"LR",0,'C',1);
474
-			$pdf->line(30, $tab_top, 30, $tab_top + $tab_height);
475
-			$pdf->SetXY(30,$tab_top);
476
-			$pdf->MultiCell(20,5,$outputlangs->transnoentities("Ref"),0,'C',1);
477
-			$pdf->SetXY(50,$tab_top);
478
-			$pdf->MultiCell(90,5,$outputlangs->transnoentities("Description"),0,'L',1);
479
-			$pdf->SetXY(140,$tab_top);
480
-			$pdf->MultiCell(30,5,$outputlangs->transnoentities("QtyOrdered"),0,'C',1);
481
-			$pdf->SetXY(170,$tab_top);
482
-			$pdf->MultiCell(30,5,$outputlangs->transnoentities("QtyToShip"),0,'C',1);
483
-		}
484
-		$pdf->Rect(10, $tab_top, 190, $tab_height);
485
-	}
486
-
487
-	/**
488
-	 *   	Show footer of page. Need this->emetteur object
429
+                $this->result = array('fullpath'=>$file);
430
+
431
+                return 1;
432
+            }
433
+            else
434
+            {
435
+                $this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir",$dir);
436
+                return 0;
437
+            }
438
+        }
439
+        else
440
+        {
441
+            $this->error=$outputlangs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
442
+            return 0;
443
+        }
444
+    }
445
+
446
+    /**
447
+     *   Show table for lines
448
+     *
449
+     *   @param		PDF			$pdf     		Object PDF
450
+     *   @param		string		$tab_top		Top position of table
451
+     *   @param		string		$tab_height		Height of table (rectangle)
452
+     *   @param		int			$nexY			Y
453
+     *   @param		Translate	$outputlangs	Langs object
454
+     *   @param		int			$hidetop		Hide top bar of array
455
+     *   @param		int			$hidebottom		Hide bottom bar of array
456
+     *   @return	void
457
+     */
458
+    function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
459
+    {
460
+        global $langs;
461
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
462
+
463
+        // Translations
464
+        $langs->loadLangs(array("main", "bills"));
465
+
466
+        if (empty($hidetop))
467
+        {
468
+            $pdf->SetFont('','B', $default_font_size - 2);
469
+            $pdf->SetXY(10,$tab_top);
470
+            $pdf->MultiCell(10,5,"LS",0,'C',1);
471
+            $pdf->line(20, $tab_top, 20, $tab_top + $tab_height);
472
+            $pdf->SetXY(20,$tab_top);
473
+            $pdf->MultiCell(10,5,"LR",0,'C',1);
474
+            $pdf->line(30, $tab_top, 30, $tab_top + $tab_height);
475
+            $pdf->SetXY(30,$tab_top);
476
+            $pdf->MultiCell(20,5,$outputlangs->transnoentities("Ref"),0,'C',1);
477
+            $pdf->SetXY(50,$tab_top);
478
+            $pdf->MultiCell(90,5,$outputlangs->transnoentities("Description"),0,'L',1);
479
+            $pdf->SetXY(140,$tab_top);
480
+            $pdf->MultiCell(30,5,$outputlangs->transnoentities("QtyOrdered"),0,'C',1);
481
+            $pdf->SetXY(170,$tab_top);
482
+            $pdf->MultiCell(30,5,$outputlangs->transnoentities("QtyToShip"),0,'C',1);
483
+        }
484
+        $pdf->Rect(10, $tab_top, 190, $tab_height);
485
+    }
486
+
487
+    /**
488
+     *   	Show footer of page. Need this->emetteur object
489 489
      *
490
-	 *   	@param	PDF			$pdf     			PDF
491
-	 * 		@param	Object		$object				Object to show
492
-	 *      @param	Translate	$outputlangs		Object lang for output
493
-	 *      @param	int			$hidefreetext		1=Hide free text
494
-	 *      @return	void
495
-	 */
496
-	function _pagefoot(&$pdf, $object, $outputlangs,$hidefreetext=0)
497
-	{
498
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
499
-		$pdf->SetFont('','', $default_font_size - 2);
500
-		$pdf->SetY(-23);
501
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("GoodStatusDeclaration"), 0, 'L');
502
-		$pdf->SetY(-13);
503
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ToAndDate"), 0, 'C');
504
-		$pdf->SetXY(120,-23);
505
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("NameAndSignature"), 0, 'C');
506
-
507
-		// Show page nb only on iso languages (so default Helvetica font)
490
+     *   	@param	PDF			$pdf     			PDF
491
+     * 		@param	Object		$object				Object to show
492
+     *      @param	Translate	$outputlangs		Object lang for output
493
+     *      @param	int			$hidefreetext		1=Hide free text
494
+     *      @return	void
495
+     */
496
+    function _pagefoot(&$pdf, $object, $outputlangs,$hidefreetext=0)
497
+    {
498
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
499
+        $pdf->SetFont('','', $default_font_size - 2);
500
+        $pdf->SetY(-23);
501
+        $pdf->MultiCell(100, 3, $outputlangs->transnoentities("GoodStatusDeclaration"), 0, 'L');
502
+        $pdf->SetY(-13);
503
+        $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ToAndDate"), 0, 'C');
504
+        $pdf->SetXY(120,-23);
505
+        $pdf->MultiCell(100, 3, $outputlangs->transnoentities("NameAndSignature"), 0, 'C');
506
+
507
+        // Show page nb only on iso languages (so default Helvetica font)
508 508
         //if (pdf_getPDFFont($outputlangs) == 'Helvetica')
509 509
         //{
510
-    	//    $pdf->SetXY(-10,-10);
510
+        //    $pdf->SetXY(-10,-10);
511 511
         //    $pdf->MultiCell(11, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0);
512 512
         //}
513
-	}
513
+    }
514 514
 
515 515
 
516
-	/**
517
-	 *  Show top header of page.
518
-	 *
519
-	 *  @param	PDF			$pdf     		Object PDF
520
-	 *  @param  Object		$object     	Object to show
521
-	 *  @param  int	    	$showaddress    0=no, 1=yes
522
-	 *  @param  Translate	$outputlangs	Object lang for output
523
-	 *  @return	void
524
-	 */
525
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
526
-	{
527
-		global $conf, $langs,$hookmanager;
516
+    /**
517
+     *  Show top header of page.
518
+     *
519
+     *  @param	PDF			$pdf     		Object PDF
520
+     *  @param  Object		$object     	Object to show
521
+     *  @param  int	    	$showaddress    0=no, 1=yes
522
+     *  @param  Translate	$outputlangs	Object lang for output
523
+     *  @return	void
524
+     */
525
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
526
+    {
527
+        global $conf, $langs,$hookmanager;
528 528
 
529
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
529
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
530 530
 
531
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
531
+        pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
532 532
 
533
-			//Affiche le filigrane brouillon - Print Draft Watermark
534
-		if($object->statut==0 && (! empty($conf->global->SENDING_DRAFT_WATERMARK)) )
535
-		{
533
+            //Affiche le filigrane brouillon - Print Draft Watermark
534
+        if($object->statut==0 && (! empty($conf->global->SENDING_DRAFT_WATERMARK)) )
535
+        {
536 536
             pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SENDING_DRAFT_WATERMARK);
537
-		}
537
+        }
538 538
 
539 539
         $posy=$this->marge_haute;
540 540
         $posx=$this->page_largeur-$this->marge_droite-100;
541 541
 
542
-		$Xoff = 90;
543
-		$Yoff = 0;
544
-
545
-		$tab4_top = 60;
546
-		$tab4_hl = 6;
547
-		$tab4_sl = 4;
548
-		$line = 2;
549
-
550
-		//*********************LOGO****************************
551
-		$pdf->SetXY(11,7);
552
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
553
-		if ($this->emetteur->logo)
554
-		{
555
-			if (is_readable($logo))
556
-			{
557
-			    $height=pdf_getHeightForLogo($logo);
558
-			    $pdf->Image($logo,10, 5, 0, $height);	// width=0 (auto)
559
-			}
560
-			else
561
-			{
562
-				$pdf->SetTextColor(200,0,0);
563
-				$pdf->SetFont('','B', $default_font_size - 2);
564
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
565
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
566
-			}
567
-		}
568
-		else
569
-		{
570
-			$text=$this->emetteur->name;
571
-			$pdf->MultiCell(70, 3, $outputlangs->convToOutputCharset($text), 0, 'L');
572
-		}
573
-
574
-		//*********************Entete****************************
575
-		//Nom du Document
576
-		$pdf->SetXY($Xoff,7);
577
-		$pdf->SetFont('','B', $default_font_size + 2);
578
-		$pdf->SetTextColor(0,0,0);
579
-		$pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L');	// Bordereau expedition
580
-		//Num Expedition
581
-		$Yoff = $Yoff+7;
582
-		$Xoff = 142;
583
-		//$pdf->Rect($Xoff, $Yoff, 85, 8);
584
-		$pdf->SetXY($Xoff,$Yoff);
585
-		$pdf->SetFont('','', $default_font_size - 2);
586
-		$pdf->SetTextColor(0,0,0);
587
-		$pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefSending").': '.$outputlangs->convToOutputCharset($object->ref), '', 'R');
588
-		//$this->Code39($Xoff+43, $Yoff+1, $object->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
589
-
590
-		$origin 	= $object->origin;
591
-		$origin_id 	= $object->origin_id;
592
-
593
-		// Add list of linked elements
594
-		$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size - 1, $hookmanager);
595
-
596
-		//$this->Code39($Xoff+43, $Yoff+1, $object->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
597
-		//Definition Emplacement du bloc Societe
598
-		$Xoff = 110;
599
-		$blSocX=90;
600
-		$blSocY=24;
601
-		$blSocW=50;
602
-		$blSocX2=$blSocW+$blSocX;
603
-
604
-		// Sender name
605
-		$pdf->SetTextColor(0,0,0);
606
-		$pdf->SetFont('','B', $default_font_size - 3);
607
-		$pdf->SetXY($blSocX,$blSocY+1);
608
-		$pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
609
-		$pdf->SetTextColor(0,0,0);
610
-
611
-		// Sender properties
612
-		$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
613
-
614
-		$pdf->SetFont('','', $default_font_size - 3);
615
-		$pdf->SetXY($blSocX,$blSocY+4);
616
-		$pdf->MultiCell(80, 2, $carac_emetteur, 0, 'L');
617
-
618
-
619
-		if ($object->thirdparty->code_client)
620
-		{
621
-			$Yoff+=3;
622
-			$posy=$Yoff;
623
-			$pdf->SetXY(100,$posy);
624
-			$pdf->SetTextColor(0,0,0);
625
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
626
-		}
627
-
628
-		// Date Expedition
629
-		$Yoff = $Yoff+7;
630
-		$pdf->SetXY($blSocX-80,$blSocY+17);
631
-
632
-		$pdf->SetFont('','B', $default_font_size - 3);
633
-		$pdf->SetTextColor(0,0,0);
634
-		$pdf->MultiCell(50, 8, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_delivery,'day',false,$outputlangs,true), '', 'L');
635
-
636
-		$pdf->SetXY($blSocX-80,$blSocY+20);
637
-		$pdf->SetFont('','B', $default_font_size - 3);
638
-		$pdf->SetTextColor(0,0,0);
639
-		$pdf->MultiCell(50, 8, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, '', 'L');
640
-
641
-		// Deliverer
642
-		$pdf->SetXY($blSocX-80,$blSocY+23);
643
-		$pdf->SetFont('','', $default_font_size - 3);
644
-		$pdf->SetTextColor(0,0,0);
645
-
646
-		if (! empty($object->tracking_number))
647
-		{
648
-			$object->getUrlTrackingStatus($object->tracking_number);
649
-			if (! empty($object->tracking_url))
650
-			{
651
-				if ($object->shipping_method_id > 0)
652
-				{
653
-					// Get code using getLabelFromKey
654
-					$code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code');
655
-
656
-					$label='';
657
-					$label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
658
-					//var_dump($object->tracking_url != $object->tracking_number);exit;
659
-					if ($object->tracking_url != $object->tracking_number)
660
-					{
661
-						$label.=" : ";
662
-						$label.=$object->tracking_url;
663
-					}
664
-					$pdf->SetFont('','B', $default_font_size - 3);
665
-					$pdf->writeHTMLCell(50, 8, '', '', $label, '', 'L');
666
-				}
667
-			}
668
-		}
669
-		else
670
-		{
671
-			$pdf->MultiCell(50, 8, $outputlangs->transnoentities("Deliverer")." ".$outputlangs->convToOutputCharset($this->livreur->getFullName($outputlangs)), '', 'L');
672
-		}
673
-
674
-
675
-		// Shipping company (My Company)
676
-		$Yoff = $blSocY;
677
-		$blExpX=$Xoff-20;
678
-		$blW=52;
679
-		$Ydef = $Yoff;
680
-		$pdf->Rect($blExpX, $Yoff, $blW, 26);
681
-
682
-		$object->fetch_thirdparty();
683
-
684
-		// If SHIPPING contact defined on order, we use it
685
-		$usecontact=false;
686
-		$arrayidcontact=$object->$origin->getIdContact('external','SHIPPING');
687
-		if (count($arrayidcontact) > 0)
688
-		{
689
-			$usecontact=true;
690
-			$result=$object->fetch_contact($arrayidcontact[0]);
691
-		}
692
-
693
-		// Recipient name
694
-		// On peut utiliser le nom de la societe du contact
695
-		if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
696
-			$thirdparty = $object->contact;
697
-		} else {
698
-			$thirdparty = $object->thirdparty;
699
-		}
700
-
701
-		$carac_client_name=pdfBuildThirdpartyName($thirdparty, $outputlangs);
702
-
703
-		$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,((!empty($object->contact))?$object->contact:null),$usecontact,'targetwithdetails',$object);
704
-
705
-		$blDestX=$blExpX+55;
706
-		$blW=54;
707
-		$Yoff = $Ydef +1;
708
-
709
-		// Show Recipient frame
710
-		$pdf->SetFont('','B', $default_font_size - 3);
711
-		$pdf->SetXY($blDestX,$Yoff-4);
712
-		$pdf->MultiCell($blW,3, $outputlangs->transnoentities("Recipient"), 0, 'L');
713
-		$pdf->Rect($blDestX, $Yoff-1, $blW, 26);
714
-
715
-		// Show recipient name
716
-		$pdf->SetFont('','B', $default_font_size - 3);
717
-		$pdf->SetXY($blDestX,$Yoff);
718
-		$pdf->MultiCell($blW,3, $carac_client_name, 0, 'L');
719
-
720
-		$posy = $pdf->getY();
721
-
722
-		// Show recipient information
723
-		$pdf->SetFont('','', $default_font_size - 3);
724
-		$pdf->SetXY($blDestX,$posy);
725
-		$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
726
-	}
542
+        $Xoff = 90;
543
+        $Yoff = 0;
544
+
545
+        $tab4_top = 60;
546
+        $tab4_hl = 6;
547
+        $tab4_sl = 4;
548
+        $line = 2;
549
+
550
+        //*********************LOGO****************************
551
+        $pdf->SetXY(11,7);
552
+        $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
553
+        if ($this->emetteur->logo)
554
+        {
555
+            if (is_readable($logo))
556
+            {
557
+                $height=pdf_getHeightForLogo($logo);
558
+                $pdf->Image($logo,10, 5, 0, $height);	// width=0 (auto)
559
+            }
560
+            else
561
+            {
562
+                $pdf->SetTextColor(200,0,0);
563
+                $pdf->SetFont('','B', $default_font_size - 2);
564
+                $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
565
+                $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
566
+            }
567
+        }
568
+        else
569
+        {
570
+            $text=$this->emetteur->name;
571
+            $pdf->MultiCell(70, 3, $outputlangs->convToOutputCharset($text), 0, 'L');
572
+        }
573
+
574
+        //*********************Entete****************************
575
+        //Nom du Document
576
+        $pdf->SetXY($Xoff,7);
577
+        $pdf->SetFont('','B', $default_font_size + 2);
578
+        $pdf->SetTextColor(0,0,0);
579
+        $pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L');	// Bordereau expedition
580
+        //Num Expedition
581
+        $Yoff = $Yoff+7;
582
+        $Xoff = 142;
583
+        //$pdf->Rect($Xoff, $Yoff, 85, 8);
584
+        $pdf->SetXY($Xoff,$Yoff);
585
+        $pdf->SetFont('','', $default_font_size - 2);
586
+        $pdf->SetTextColor(0,0,0);
587
+        $pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefSending").': '.$outputlangs->convToOutputCharset($object->ref), '', 'R');
588
+        //$this->Code39($Xoff+43, $Yoff+1, $object->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
589
+
590
+        $origin 	= $object->origin;
591
+        $origin_id 	= $object->origin_id;
592
+
593
+        // Add list of linked elements
594
+        $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size - 1, $hookmanager);
595
+
596
+        //$this->Code39($Xoff+43, $Yoff+1, $object->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
597
+        //Definition Emplacement du bloc Societe
598
+        $Xoff = 110;
599
+        $blSocX=90;
600
+        $blSocY=24;
601
+        $blSocW=50;
602
+        $blSocX2=$blSocW+$blSocX;
603
+
604
+        // Sender name
605
+        $pdf->SetTextColor(0,0,0);
606
+        $pdf->SetFont('','B', $default_font_size - 3);
607
+        $pdf->SetXY($blSocX,$blSocY+1);
608
+        $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
609
+        $pdf->SetTextColor(0,0,0);
610
+
611
+        // Sender properties
612
+        $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
613
+
614
+        $pdf->SetFont('','', $default_font_size - 3);
615
+        $pdf->SetXY($blSocX,$blSocY+4);
616
+        $pdf->MultiCell(80, 2, $carac_emetteur, 0, 'L');
617
+
618
+
619
+        if ($object->thirdparty->code_client)
620
+        {
621
+            $Yoff+=3;
622
+            $posy=$Yoff;
623
+            $pdf->SetXY(100,$posy);
624
+            $pdf->SetTextColor(0,0,0);
625
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
626
+        }
627
+
628
+        // Date Expedition
629
+        $Yoff = $Yoff+7;
630
+        $pdf->SetXY($blSocX-80,$blSocY+17);
631
+
632
+        $pdf->SetFont('','B', $default_font_size - 3);
633
+        $pdf->SetTextColor(0,0,0);
634
+        $pdf->MultiCell(50, 8, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_delivery,'day',false,$outputlangs,true), '', 'L');
635
+
636
+        $pdf->SetXY($blSocX-80,$blSocY+20);
637
+        $pdf->SetFont('','B', $default_font_size - 3);
638
+        $pdf->SetTextColor(0,0,0);
639
+        $pdf->MultiCell(50, 8, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, '', 'L');
640
+
641
+        // Deliverer
642
+        $pdf->SetXY($blSocX-80,$blSocY+23);
643
+        $pdf->SetFont('','', $default_font_size - 3);
644
+        $pdf->SetTextColor(0,0,0);
645
+
646
+        if (! empty($object->tracking_number))
647
+        {
648
+            $object->getUrlTrackingStatus($object->tracking_number);
649
+            if (! empty($object->tracking_url))
650
+            {
651
+                if ($object->shipping_method_id > 0)
652
+                {
653
+                    // Get code using getLabelFromKey
654
+                    $code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code');
655
+
656
+                    $label='';
657
+                    $label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
658
+                    //var_dump($object->tracking_url != $object->tracking_number);exit;
659
+                    if ($object->tracking_url != $object->tracking_number)
660
+                    {
661
+                        $label.=" : ";
662
+                        $label.=$object->tracking_url;
663
+                    }
664
+                    $pdf->SetFont('','B', $default_font_size - 3);
665
+                    $pdf->writeHTMLCell(50, 8, '', '', $label, '', 'L');
666
+                }
667
+            }
668
+        }
669
+        else
670
+        {
671
+            $pdf->MultiCell(50, 8, $outputlangs->transnoentities("Deliverer")." ".$outputlangs->convToOutputCharset($this->livreur->getFullName($outputlangs)), '', 'L');
672
+        }
673
+
674
+
675
+        // Shipping company (My Company)
676
+        $Yoff = $blSocY;
677
+        $blExpX=$Xoff-20;
678
+        $blW=52;
679
+        $Ydef = $Yoff;
680
+        $pdf->Rect($blExpX, $Yoff, $blW, 26);
681
+
682
+        $object->fetch_thirdparty();
683
+
684
+        // If SHIPPING contact defined on order, we use it
685
+        $usecontact=false;
686
+        $arrayidcontact=$object->$origin->getIdContact('external','SHIPPING');
687
+        if (count($arrayidcontact) > 0)
688
+        {
689
+            $usecontact=true;
690
+            $result=$object->fetch_contact($arrayidcontact[0]);
691
+        }
692
+
693
+        // Recipient name
694
+        // On peut utiliser le nom de la societe du contact
695
+        if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
696
+            $thirdparty = $object->contact;
697
+        } else {
698
+            $thirdparty = $object->thirdparty;
699
+        }
700
+
701
+        $carac_client_name=pdfBuildThirdpartyName($thirdparty, $outputlangs);
702
+
703
+        $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,((!empty($object->contact))?$object->contact:null),$usecontact,'targetwithdetails',$object);
704
+
705
+        $blDestX=$blExpX+55;
706
+        $blW=54;
707
+        $Yoff = $Ydef +1;
708
+
709
+        // Show Recipient frame
710
+        $pdf->SetFont('','B', $default_font_size - 3);
711
+        $pdf->SetXY($blDestX,$Yoff-4);
712
+        $pdf->MultiCell($blW,3, $outputlangs->transnoentities("Recipient"), 0, 'L');
713
+        $pdf->Rect($blDestX, $Yoff-1, $blW, 26);
714
+
715
+        // Show recipient name
716
+        $pdf->SetFont('','B', $default_font_size - 3);
717
+        $pdf->SetXY($blDestX,$Yoff);
718
+        $pdf->MultiCell($blW,3, $carac_client_name, 0, 'L');
719
+
720
+        $posy = $pdf->getY();
721
+
722
+        // Show recipient information
723
+        $pdf->SetFont('','', $default_font_size - 3);
724
+        $pdf->SetXY($blDestX,$posy);
725
+        $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
726
+    }
727 727
 }
Please login to merge, or discard this patch.
Spacing   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -116,29 +116,29 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 *  @param		DoliDB		$db      Database handler
118 118
 	 */
119
-	function __construct($db=0)
119
+	function __construct($db = 0)
120 120
 	{
121
-		global $conf,$langs,$mysoc;
121
+		global $conf, $langs, $mysoc;
122 122
 
123 123
 		$this->db = $db;
124 124
 		$this->name = "merou";
125 125
 		$this->description = $langs->trans("DocumentModelMerou");
126 126
 
127 127
 		$this->type = 'pdf';
128
-		$formatarray=pdf_getFormat();
128
+		$formatarray = pdf_getFormat();
129 129
 		$this->page_largeur = $formatarray['width'];
130
-		$this->page_hauteur = round($formatarray['height']/2);
131
-		$this->format = array($this->page_largeur,$this->page_hauteur);
132
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
133
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
134
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
135
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
130
+		$this->page_hauteur = round($formatarray['height'] / 2);
131
+		$this->format = array($this->page_largeur, $this->page_hauteur);
132
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
133
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
134
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
135
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
136 136
 
137 137
 		$this->option_logo = 1;
138 138
 
139 139
 		// Get source company
140
-		$this->emetteur=$mysoc;
141
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
140
+		$this->emetteur = $mysoc;
141
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
142 142
 	}
143 143
 
144 144
 
@@ -154,16 +154,16 @@  discard block
 block discarded – undo
154 154
      *  @param		int			$hideref			Do not show ref
155 155
      *  @return     int         	    			1=OK, 0=KO
156 156
 	 */
157
-	function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
157
+	function write_file(&$object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
158 158
 	{
159 159
         // phpcs:enable
160
-		global $user,$conf,$langs,$mysoc,$hookmanager;
160
+		global $user, $conf, $langs, $mysoc, $hookmanager;
161 161
 
162 162
 		$object->fetch_thirdparty();
163 163
 
164
-		if (! is_object($outputlangs)) $outputlangs=$langs;
164
+		if (!is_object($outputlangs)) $outputlangs = $langs;
165 165
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
166
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
166
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
167 167
 
168 168
 		// Load traductions files requiredby by page
169 169
 		$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
@@ -178,33 +178,33 @@  discard block
 block discarded – undo
178 178
 			$this->expediteur = $mysoc;
179 179
 
180 180
 			//Creation du destinataire
181
-			$idcontact = $object->$origin->getIdContact('external','SHIPPING');
181
+			$idcontact = $object->$origin->getIdContact('external', 'SHIPPING');
182 182
             $this->destinataire = new Contact($this->db);
183
-			if (! empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]);
183
+			if (!empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]);
184 184
 
185 185
 			//Creation du livreur
186
-			$idcontact = $object->$origin->getIdContact('internal','LIVREUR');
186
+			$idcontact = $object->$origin->getIdContact('internal', 'LIVREUR');
187 187
 			$this->livreur = new User($this->db);
188
-			if (! empty($idcontact[0])) $this->livreur->fetch($idcontact[0]);
188
+			if (!empty($idcontact[0])) $this->livreur->fetch($idcontact[0]);
189 189
 
190 190
 			// Definition de $dir et $file
191 191
 			if ($object->specimen)
192 192
 			{
193 193
 				$dir = $conf->expedition->dir_output."/sending";
194
-				$file = $dir . "/SPECIMEN.pdf";
194
+				$file = $dir."/SPECIMEN.pdf";
195 195
 			}
196 196
 			else
197 197
 			{
198 198
 				$expref = dol_sanitizeFileName($object->ref);
199
-				$dir = $conf->expedition->dir_output . "/sending/" . $expref;
200
-				$file = $dir . "/" . $expref . ".pdf";
199
+				$dir = $conf->expedition->dir_output."/sending/".$expref;
200
+				$file = $dir."/".$expref.".pdf";
201 201
 			}
202 202
 
203
-			if (! file_exists($dir))
203
+			if (!file_exists($dir))
204 204
 			{
205 205
 				if (dol_mkdir($dir) < 0)
206 206
 				{
207
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
207
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
208 208
 					return 0;
209 209
 				}
210 210
 			}
@@ -212,25 +212,25 @@  discard block
 block discarded – undo
212 212
 			if (file_exists($dir))
213 213
 			{
214 214
 				// Add pdfgeneration hook
215
-				if (! is_object($hookmanager))
215
+				if (!is_object($hookmanager))
216 216
 				{
217 217
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
218
-					$hookmanager=new HookManager($this->db);
218
+					$hookmanager = new HookManager($this->db);
219 219
 				}
220 220
 				$hookmanager->initHooks(array('pdfgeneration'));
221
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
221
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
222 222
 				global $action;
223
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
223
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
224 224
 
225 225
 				$nblignes = count($object->lines);
226 226
 
227
-				$pdf=pdf_getInstance($this->format,'mm','l');
227
+				$pdf = pdf_getInstance($this->format, 'mm', 'l');
228 228
 				$default_font_size = pdf_getPDFFontSize($outputlangs);
229
-				$heightforinfotot = 0;	// Height reserved to output the info and total part
230
-		        $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
231
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
232
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
233
-                $pdf->SetAutoPageBreak(1,0);
229
+				$heightforinfotot = 0; // Height reserved to output the info and total part
230
+		        $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
231
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
232
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
233
+                $pdf->SetAutoPageBreak(1, 0);
234 234
 
235 235
 			    if (class_exists('TCPDF'))
236 236
                 {
@@ -239,105 +239,105 @@  discard block
 block discarded – undo
239 239
                 }
240 240
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
241 241
                 // Set path to the background PDF File
242
-                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
242
+                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
243 243
                 {
244 244
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
245 245
                     $tplidx = $pdf->importPage(1);
246 246
                 }
247 247
 
248 248
 				$pdf->Open();
249
-				$pagenb=0;
250
-				$pdf->SetDrawColor(128,128,128);
249
+				$pagenb = 0;
250
+				$pdf->SetDrawColor(128, 128, 128);
251 251
 
252
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
252
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
253 253
 
254 254
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
255 255
 				$pdf->SetSubject($outputlangs->transnoentities("Shipment"));
256 256
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
257 257
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
258 258
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
259
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
259
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
260 260
 
261
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
261
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
262 262
 
263 263
 				// New page
264 264
 				$pdf->AddPage();
265 265
 				$pagenb++;
266 266
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
267
-				$pdf->SetFont('','', $default_font_size - 3);
268
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
269
-				$pdf->SetTextColor(0,0,0);
267
+				$pdf->SetFont('', '', $default_font_size - 3);
268
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
269
+				$pdf->SetTextColor(0, 0, 0);
270 270
 
271 271
 				$tab_top = 52;
272
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
272
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
273 273
 				$tab_height = $this->page_hauteur - $tab_top - $heightforfooter;
274 274
 				$tab_height_newpage = $this->page_hauteur - $tab_top_newpage - $heightforfooter;
275 275
 
276 276
 				// Affiche notes
277
-				if (! empty($object->note_public))
277
+				if (!empty($object->note_public))
278 278
 				{
279
-					$pdf->SetFont('','', $default_font_size - 1);
279
+					$pdf->SetFont('', '', $default_font_size - 1);
280 280
 					$pdf->writeHTMLCell(190, 3, $this->marge_gauche, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
281 281
 					$nexY = $pdf->GetY();
282
-					$height_note=$nexY-$tab_top;
282
+					$height_note = $nexY - $tab_top;
283 283
 
284 284
 					// Rect prend une longueur en 3eme param
285
-					$pdf->SetDrawColor(192,192,192);
286
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
285
+					$pdf->SetDrawColor(192, 192, 192);
286
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
287 287
 
288 288
 					$tab_height = $tab_height - $height_note;
289
-					$tab_top = $nexY+6;
289
+					$tab_top = $nexY + 6;
290 290
 				}
291 291
 				else
292 292
 				{
293
-					$height_note=0;
293
+					$height_note = 0;
294 294
 				}
295 295
 
296 296
 
297
-				$pdf->SetFillColor(240,240,240);
298
-				$pdf->SetTextColor(0,0,0);
297
+				$pdf->SetFillColor(240, 240, 240);
298
+				$pdf->SetTextColor(0, 0, 0);
299 299
 				$pdf->SetXY(10, $tab_top + 5);
300 300
 
301 301
 				$iniY = $tab_top + 7;
302 302
 				$curY = $tab_top + 7;
303 303
 				$nexY = $tab_top + 7;
304 304
 
305
-				$num=count($object->lines);
305
+				$num = count($object->lines);
306 306
 				// Loop on each lines
307 307
 				for ($i = 0; $i < $num; $i++)
308 308
 				{
309 309
 					$curY = $nexY;
310
-					$pdf->SetFont('','', $default_font_size - 3);
311
-					$pdf->SetTextColor(0,0,0);
310
+					$pdf->SetFont('', '', $default_font_size - 3);
311
+					$pdf->SetTextColor(0, 0, 0);
312 312
 
313 313
 					$pdf->setTopMargin($tab_top_newpage);
314
-					$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
315
-					$pageposbefore=$pdf->getPage();
314
+					$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
315
+					$pageposbefore = $pdf->getPage();
316 316
 
317 317
 					// Description de la ligne produit
318
-					$libelleproduitservice = pdf_writelinedesc($pdf,$object,$i,$outputlangs,90,3,50,$curY,0,1);
318
+					$libelleproduitservice = pdf_writelinedesc($pdf, $object, $i, $outputlangs, 90, 3, 50, $curY, 0, 1);
319 319
 
320 320
 					$nexY = $pdf->GetY();
321
-					$pageposafter=$pdf->getPage();
321
+					$pageposafter = $pdf->getPage();
322 322
 					$pdf->setPage($pageposbefore);
323 323
 					$pdf->setTopMargin($this->marge_haute);
324
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
324
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
325 325
 
326 326
 					// We suppose that a too long description is moved completely on next page
327 327
 					if ($pageposafter > $pageposbefore) {
328 328
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
329 329
 					}
330 330
 
331
-					$pdf->SetFont('','', $default_font_size - 3);
331
+					$pdf->SetFont('', '', $default_font_size - 3);
332 332
 
333 333
 					// Check boxes
334
-					$pdf->SetDrawColor(120,120,120);
335
-					$pdf->Rect(10+3, $curY, 3, 3);
336
-					$pdf->Rect(20+3, $curY, 3, 3);
334
+					$pdf->SetDrawColor(120, 120, 120);
335
+					$pdf->Rect(10 + 3, $curY, 3, 3);
336
+					$pdf->Rect(20 + 3, $curY, 3, 3);
337 337
 
338 338
 					//Insertion de la reference du produit
339 339
 					$pdf->SetXY(30, $curY);
340
-					$pdf->SetFont('','B', $default_font_size - 3);
340
+					$pdf->SetFont('', 'B', $default_font_size - 3);
341 341
 					$pdf->MultiCell(24, 3, $outputlangs->convToOutputCharset($object->lines[$i]->ref), 0, 'L', 0);
342 342
 
343 343
 					$pdf->SetXY(140, $curY);
@@ -347,16 +347,16 @@  discard block
 block discarded – undo
347 347
 					$pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped, 0, 'C', 0);
348 348
 
349 349
 					// Add line
350
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
350
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
351 351
 					{
352 352
 						$pdf->setPage($pageposafter);
353
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
353
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
354 354
 						//$pdf->SetDrawColor(190,190,200);
355
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
355
+						$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
356 356
 						$pdf->SetLineStyle(array('dash'=>0));
357 357
 					}
358 358
 
359
-					$nexY+=2;    // Passe espace entre les lignes
359
+					$nexY += 2; // Passe espace entre les lignes
360 360
 
361 361
 					// Detect if some page were added automatically and output _tableau for past pages
362 362
 					while ($pagenb < $pageposafter)
@@ -370,12 +370,12 @@  discard block
 block discarded – undo
370 370
 						{
371 371
 							$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
372 372
 						}
373
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
373
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
374 374
 						$pagenb++;
375 375
 						$pdf->setPage($pagenb);
376
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
376
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
377 377
 					}
378
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
378
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
379 379
 					{
380 380
 						if ($pagenb == 1)
381 381
 						{
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 						{
386 386
 							$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
387 387
 						}
388
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
388
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
389 389
 						// New page
390 390
 						$pdf->AddPage();
391 391
 						$pagenb++;
@@ -396,34 +396,34 @@  discard block
 block discarded – undo
396 396
 				if ($pagenb == 1)
397 397
 				{
398 398
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
399
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
399
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
400 400
 				}
401 401
 				else
402 402
 				{
403 403
 					$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
404
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
404
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
405 405
 				}
406 406
 
407 407
 				// Pied de page
408 408
 				$this->_pagefoot($pdf, $object, $outputlangs);
409
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
409
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
410 410
 
411 411
 				$pdf->Close();
412 412
 
413
-				$pdf->Output($file,'F');
413
+				$pdf->Output($file, 'F');
414 414
 
415 415
 				// Add pdfgeneration hook
416
-				if (! is_object($hookmanager))
416
+				if (!is_object($hookmanager))
417 417
 				{
418 418
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
419
-					$hookmanager=new HookManager($this->db);
419
+					$hookmanager = new HookManager($this->db);
420 420
 				}
421 421
 				$hookmanager->initHooks(array('pdfgeneration'));
422
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
422
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
423 423
 				global $action;
424
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
424
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
425 425
 
426
-                if (! empty($conf->global->MAIN_UMASK))
426
+                if (!empty($conf->global->MAIN_UMASK))
427 427
                     @chmod($file, octdec($conf->global->MAIN_UMASK));
428 428
 
429 429
 				$this->result = array('fullpath'=>$file);
@@ -432,13 +432,13 @@  discard block
 block discarded – undo
432 432
 			}
433 433
 			else
434 434
 			{
435
-				$this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir",$dir);
435
+				$this->error = $outputlangs->transnoentities("ErrorCanNotCreateDir", $dir);
436 436
 				return 0;
437 437
 			}
438 438
 		}
439 439
 		else
440 440
 		{
441
-			$this->error=$outputlangs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
441
+			$this->error = $outputlangs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
442 442
 			return 0;
443 443
 		}
444 444
 	}
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 	 *   @param		int			$hidebottom		Hide bottom bar of array
456 456
 	 *   @return	void
457 457
 	 */
458
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
458
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
459 459
 	{
460 460
 		global $langs;
461 461
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -465,21 +465,21 @@  discard block
 block discarded – undo
465 465
 
466 466
 		if (empty($hidetop))
467 467
 		{
468
-			$pdf->SetFont('','B', $default_font_size - 2);
469
-			$pdf->SetXY(10,$tab_top);
470
-			$pdf->MultiCell(10,5,"LS",0,'C',1);
468
+			$pdf->SetFont('', 'B', $default_font_size - 2);
469
+			$pdf->SetXY(10, $tab_top);
470
+			$pdf->MultiCell(10, 5, "LS", 0, 'C', 1);
471 471
 			$pdf->line(20, $tab_top, 20, $tab_top + $tab_height);
472
-			$pdf->SetXY(20,$tab_top);
473
-			$pdf->MultiCell(10,5,"LR",0,'C',1);
472
+			$pdf->SetXY(20, $tab_top);
473
+			$pdf->MultiCell(10, 5, "LR", 0, 'C', 1);
474 474
 			$pdf->line(30, $tab_top, 30, $tab_top + $tab_height);
475
-			$pdf->SetXY(30,$tab_top);
476
-			$pdf->MultiCell(20,5,$outputlangs->transnoentities("Ref"),0,'C',1);
477
-			$pdf->SetXY(50,$tab_top);
478
-			$pdf->MultiCell(90,5,$outputlangs->transnoentities("Description"),0,'L',1);
479
-			$pdf->SetXY(140,$tab_top);
480
-			$pdf->MultiCell(30,5,$outputlangs->transnoentities("QtyOrdered"),0,'C',1);
481
-			$pdf->SetXY(170,$tab_top);
482
-			$pdf->MultiCell(30,5,$outputlangs->transnoentities("QtyToShip"),0,'C',1);
475
+			$pdf->SetXY(30, $tab_top);
476
+			$pdf->MultiCell(20, 5, $outputlangs->transnoentities("Ref"), 0, 'C', 1);
477
+			$pdf->SetXY(50, $tab_top);
478
+			$pdf->MultiCell(90, 5, $outputlangs->transnoentities("Description"), 0, 'L', 1);
479
+			$pdf->SetXY(140, $tab_top);
480
+			$pdf->MultiCell(30, 5, $outputlangs->transnoentities("QtyOrdered"), 0, 'C', 1);
481
+			$pdf->SetXY(170, $tab_top);
482
+			$pdf->MultiCell(30, 5, $outputlangs->transnoentities("QtyToShip"), 0, 'C', 1);
483 483
 		}
484 484
 		$pdf->Rect(10, $tab_top, 190, $tab_height);
485 485
 	}
@@ -493,15 +493,15 @@  discard block
 block discarded – undo
493 493
 	 *      @param	int			$hidefreetext		1=Hide free text
494 494
 	 *      @return	void
495 495
 	 */
496
-	function _pagefoot(&$pdf, $object, $outputlangs,$hidefreetext=0)
496
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
497 497
 	{
498 498
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
499
-		$pdf->SetFont('','', $default_font_size - 2);
499
+		$pdf->SetFont('', '', $default_font_size - 2);
500 500
 		$pdf->SetY(-23);
501 501
 		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("GoodStatusDeclaration"), 0, 'L');
502 502
 		$pdf->SetY(-13);
503 503
 		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ToAndDate"), 0, 'C');
504
-		$pdf->SetXY(120,-23);
504
+		$pdf->SetXY(120, -23);
505 505
 		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("NameAndSignature"), 0, 'C');
506 506
 
507 507
 		// Show page nb only on iso languages (so default Helvetica font)
@@ -524,20 +524,20 @@  discard block
 block discarded – undo
524 524
 	 */
525 525
 	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
526 526
 	{
527
-		global $conf, $langs,$hookmanager;
527
+		global $conf, $langs, $hookmanager;
528 528
 
529 529
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
530 530
 
531
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
531
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
532 532
 
533 533
 			//Affiche le filigrane brouillon - Print Draft Watermark
534
-		if($object->statut==0 && (! empty($conf->global->SENDING_DRAFT_WATERMARK)) )
534
+		if ($object->statut == 0 && (!empty($conf->global->SENDING_DRAFT_WATERMARK)))
535 535
 		{
536
-            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SENDING_DRAFT_WATERMARK);
536
+            pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SENDING_DRAFT_WATERMARK);
537 537
 		}
538 538
 
539
-        $posy=$this->marge_haute;
540
-        $posx=$this->page_largeur-$this->marge_droite-100;
539
+        $posy = $this->marge_haute;
540
+        $posx = $this->page_largeur - $this->marge_droite - 100;
541 541
 
542 542
 		$Xoff = 90;
543 543
 		$Yoff = 0;
@@ -548,47 +548,47 @@  discard block
 block discarded – undo
548 548
 		$line = 2;
549 549
 
550 550
 		//*********************LOGO****************************
551
-		$pdf->SetXY(11,7);
552
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
551
+		$pdf->SetXY(11, 7);
552
+		$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
553 553
 		if ($this->emetteur->logo)
554 554
 		{
555 555
 			if (is_readable($logo))
556 556
 			{
557
-			    $height=pdf_getHeightForLogo($logo);
558
-			    $pdf->Image($logo,10, 5, 0, $height);	// width=0 (auto)
557
+			    $height = pdf_getHeightForLogo($logo);
558
+			    $pdf->Image($logo, 10, 5, 0, $height); // width=0 (auto)
559 559
 			}
560 560
 			else
561 561
 			{
562
-				$pdf->SetTextColor(200,0,0);
563
-				$pdf->SetFont('','B', $default_font_size - 2);
564
-				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
562
+				$pdf->SetTextColor(200, 0, 0);
563
+				$pdf->SetFont('', 'B', $default_font_size - 2);
564
+				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
565 565
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
566 566
 			}
567 567
 		}
568 568
 		else
569 569
 		{
570
-			$text=$this->emetteur->name;
570
+			$text = $this->emetteur->name;
571 571
 			$pdf->MultiCell(70, 3, $outputlangs->convToOutputCharset($text), 0, 'L');
572 572
 		}
573 573
 
574 574
 		//*********************Entete****************************
575 575
 		//Nom du Document
576
-		$pdf->SetXY($Xoff,7);
577
-		$pdf->SetFont('','B', $default_font_size + 2);
578
-		$pdf->SetTextColor(0,0,0);
579
-		$pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L');	// Bordereau expedition
576
+		$pdf->SetXY($Xoff, 7);
577
+		$pdf->SetFont('', 'B', $default_font_size + 2);
578
+		$pdf->SetTextColor(0, 0, 0);
579
+		$pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L'); // Bordereau expedition
580 580
 		//Num Expedition
581
-		$Yoff = $Yoff+7;
581
+		$Yoff = $Yoff + 7;
582 582
 		$Xoff = 142;
583 583
 		//$pdf->Rect($Xoff, $Yoff, 85, 8);
584
-		$pdf->SetXY($Xoff,$Yoff);
585
-		$pdf->SetFont('','', $default_font_size - 2);
586
-		$pdf->SetTextColor(0,0,0);
584
+		$pdf->SetXY($Xoff, $Yoff);
585
+		$pdf->SetFont('', '', $default_font_size - 2);
586
+		$pdf->SetTextColor(0, 0, 0);
587 587
 		$pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefSending").': '.$outputlangs->convToOutputCharset($object->ref), '', 'R');
588 588
 		//$this->Code39($Xoff+43, $Yoff+1, $object->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
589 589
 
590
-		$origin 	= $object->origin;
591
-		$origin_id 	= $object->origin_id;
590
+		$origin = $object->origin;
591
+		$origin_id = $object->origin_id;
592 592
 
593 593
 		// Add list of linked elements
594 594
 		$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size - 1, $hookmanager);
@@ -596,72 +596,72 @@  discard block
 block discarded – undo
596 596
 		//$this->Code39($Xoff+43, $Yoff+1, $object->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
597 597
 		//Definition Emplacement du bloc Societe
598 598
 		$Xoff = 110;
599
-		$blSocX=90;
600
-		$blSocY=24;
601
-		$blSocW=50;
602
-		$blSocX2=$blSocW+$blSocX;
599
+		$blSocX = 90;
600
+		$blSocY = 24;
601
+		$blSocW = 50;
602
+		$blSocX2 = $blSocW + $blSocX;
603 603
 
604 604
 		// Sender name
605
-		$pdf->SetTextColor(0,0,0);
606
-		$pdf->SetFont('','B', $default_font_size - 3);
607
-		$pdf->SetXY($blSocX,$blSocY+1);
605
+		$pdf->SetTextColor(0, 0, 0);
606
+		$pdf->SetFont('', 'B', $default_font_size - 3);
607
+		$pdf->SetXY($blSocX, $blSocY + 1);
608 608
 		$pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
609
-		$pdf->SetTextColor(0,0,0);
609
+		$pdf->SetTextColor(0, 0, 0);
610 610
 
611 611
 		// Sender properties
612 612
 		$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
613 613
 
614
-		$pdf->SetFont('','', $default_font_size - 3);
615
-		$pdf->SetXY($blSocX,$blSocY+4);
614
+		$pdf->SetFont('', '', $default_font_size - 3);
615
+		$pdf->SetXY($blSocX, $blSocY + 4);
616 616
 		$pdf->MultiCell(80, 2, $carac_emetteur, 0, 'L');
617 617
 
618 618
 
619 619
 		if ($object->thirdparty->code_client)
620 620
 		{
621
-			$Yoff+=3;
622
-			$posy=$Yoff;
623
-			$pdf->SetXY(100,$posy);
624
-			$pdf->SetTextColor(0,0,0);
625
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
621
+			$Yoff += 3;
622
+			$posy = $Yoff;
623
+			$pdf->SetXY(100, $posy);
624
+			$pdf->SetTextColor(0, 0, 0);
625
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
626 626
 		}
627 627
 
628 628
 		// Date Expedition
629
-		$Yoff = $Yoff+7;
630
-		$pdf->SetXY($blSocX-80,$blSocY+17);
629
+		$Yoff = $Yoff + 7;
630
+		$pdf->SetXY($blSocX - 80, $blSocY + 17);
631 631
 
632
-		$pdf->SetFont('','B', $default_font_size - 3);
633
-		$pdf->SetTextColor(0,0,0);
634
-		$pdf->MultiCell(50, 8, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_delivery,'day',false,$outputlangs,true), '', 'L');
632
+		$pdf->SetFont('', 'B', $default_font_size - 3);
633
+		$pdf->SetTextColor(0, 0, 0);
634
+		$pdf->MultiCell(50, 8, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, 'day', false, $outputlangs, true), '', 'L');
635 635
 
636
-		$pdf->SetXY($blSocX-80,$blSocY+20);
637
-		$pdf->SetFont('','B', $default_font_size - 3);
638
-		$pdf->SetTextColor(0,0,0);
639
-		$pdf->MultiCell(50, 8, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, '', 'L');
636
+		$pdf->SetXY($blSocX - 80, $blSocY + 20);
637
+		$pdf->SetFont('', 'B', $default_font_size - 3);
638
+		$pdf->SetTextColor(0, 0, 0);
639
+		$pdf->MultiCell(50, 8, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, '', 'L');
640 640
 
641 641
 		// Deliverer
642
-		$pdf->SetXY($blSocX-80,$blSocY+23);
643
-		$pdf->SetFont('','', $default_font_size - 3);
644
-		$pdf->SetTextColor(0,0,0);
642
+		$pdf->SetXY($blSocX - 80, $blSocY + 23);
643
+		$pdf->SetFont('', '', $default_font_size - 3);
644
+		$pdf->SetTextColor(0, 0, 0);
645 645
 
646
-		if (! empty($object->tracking_number))
646
+		if (!empty($object->tracking_number))
647 647
 		{
648 648
 			$object->getUrlTrackingStatus($object->tracking_number);
649
-			if (! empty($object->tracking_url))
649
+			if (!empty($object->tracking_url))
650 650
 			{
651 651
 				if ($object->shipping_method_id > 0)
652 652
 				{
653 653
 					// Get code using getLabelFromKey
654
-					$code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code');
654
+					$code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
655 655
 
656
-					$label='';
657
-					$label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
656
+					$label = '';
657
+					$label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
658 658
 					//var_dump($object->tracking_url != $object->tracking_number);exit;
659 659
 					if ($object->tracking_url != $object->tracking_number)
660 660
 					{
661
-						$label.=" : ";
662
-						$label.=$object->tracking_url;
661
+						$label .= " : ";
662
+						$label .= $object->tracking_url;
663 663
 					}
664
-					$pdf->SetFont('','B', $default_font_size - 3);
664
+					$pdf->SetFont('', 'B', $default_font_size - 3);
665 665
 					$pdf->writeHTMLCell(50, 8, '', '', $label, '', 'L');
666 666
 				}
667 667
 			}
@@ -674,20 +674,20 @@  discard block
 block discarded – undo
674 674
 
675 675
 		// Shipping company (My Company)
676 676
 		$Yoff = $blSocY;
677
-		$blExpX=$Xoff-20;
678
-		$blW=52;
677
+		$blExpX = $Xoff - 20;
678
+		$blW = 52;
679 679
 		$Ydef = $Yoff;
680 680
 		$pdf->Rect($blExpX, $Yoff, $blW, 26);
681 681
 
682 682
 		$object->fetch_thirdparty();
683 683
 
684 684
 		// If SHIPPING contact defined on order, we use it
685
-		$usecontact=false;
686
-		$arrayidcontact=$object->$origin->getIdContact('external','SHIPPING');
685
+		$usecontact = false;
686
+		$arrayidcontact = $object->$origin->getIdContact('external', 'SHIPPING');
687 687
 		if (count($arrayidcontact) > 0)
688 688
 		{
689
-			$usecontact=true;
690
-			$result=$object->fetch_contact($arrayidcontact[0]);
689
+			$usecontact = true;
690
+			$result = $object->fetch_contact($arrayidcontact[0]);
691 691
 		}
692 692
 
693 693
 		// Recipient name
@@ -698,30 +698,30 @@  discard block
 block discarded – undo
698 698
 			$thirdparty = $object->thirdparty;
699 699
 		}
700 700
 
701
-		$carac_client_name=pdfBuildThirdpartyName($thirdparty, $outputlangs);
701
+		$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
702 702
 
703
-		$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,((!empty($object->contact))?$object->contact:null),$usecontact,'targetwithdetails',$object);
703
+		$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ((!empty($object->contact)) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
704 704
 
705
-		$blDestX=$blExpX+55;
706
-		$blW=54;
707
-		$Yoff = $Ydef +1;
705
+		$blDestX = $blExpX + 55;
706
+		$blW = 54;
707
+		$Yoff = $Ydef + 1;
708 708
 
709 709
 		// Show Recipient frame
710
-		$pdf->SetFont('','B', $default_font_size - 3);
711
-		$pdf->SetXY($blDestX,$Yoff-4);
712
-		$pdf->MultiCell($blW,3, $outputlangs->transnoentities("Recipient"), 0, 'L');
713
-		$pdf->Rect($blDestX, $Yoff-1, $blW, 26);
710
+		$pdf->SetFont('', 'B', $default_font_size - 3);
711
+		$pdf->SetXY($blDestX, $Yoff - 4);
712
+		$pdf->MultiCell($blW, 3, $outputlangs->transnoentities("Recipient"), 0, 'L');
713
+		$pdf->Rect($blDestX, $Yoff - 1, $blW, 26);
714 714
 
715 715
 		// Show recipient name
716
-		$pdf->SetFont('','B', $default_font_size - 3);
717
-		$pdf->SetXY($blDestX,$Yoff);
718
-		$pdf->MultiCell($blW,3, $carac_client_name, 0, 'L');
716
+		$pdf->SetFont('', 'B', $default_font_size - 3);
717
+		$pdf->SetXY($blDestX, $Yoff);
718
+		$pdf->MultiCell($blW, 3, $carac_client_name, 0, 'L');
719 719
 
720 720
 		$posy = $pdf->getY();
721 721
 
722 722
 		// Show recipient information
723
-		$pdf->SetFont('','', $default_font_size - 3);
724
-		$pdf->SetXY($blDestX,$posy);
723
+		$pdf->SetFont('', '', $default_font_size - 3);
724
+		$pdf->SetXY($blDestX, $posy);
725 725
 		$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
726 726
 	}
727 727
 }
Please login to merge, or discard this patch.
Braces   +41 added lines, -31 removed lines patch added patch discarded remove patch
@@ -138,7 +138,10 @@  discard block
 block discarded – undo
138 138
 
139 139
 		// Get source company
140 140
 		$this->emetteur=$mysoc;
141
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
141
+		if (! $this->emetteur->country_code) {
142
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
143
+		}
144
+		// By default if not defined
142 145
 	}
143 146
 
144 147
 
@@ -161,9 +164,13 @@  discard block
 block discarded – undo
161 164
 
162 165
 		$object->fetch_thirdparty();
163 166
 
164
-		if (! is_object($outputlangs)) $outputlangs=$langs;
167
+		if (! is_object($outputlangs)) {
168
+		    $outputlangs=$langs;
169
+		}
165 170
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
166
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
171
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
172
+		    $outputlangs->charset_output='ISO-8859-1';
173
+		}
167 174
 
168 175
 		// Load traductions files requiredby by page
169 176
 		$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
@@ -180,20 +187,23 @@  discard block
 block discarded – undo
180 187
 			//Creation du destinataire
181 188
 			$idcontact = $object->$origin->getIdContact('external','SHIPPING');
182 189
             $this->destinataire = new Contact($this->db);
183
-			if (! empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]);
190
+			if (! empty($idcontact[0])) {
191
+			    $this->destinataire->fetch($idcontact[0]);
192
+			}
184 193
 
185 194
 			//Creation du livreur
186 195
 			$idcontact = $object->$origin->getIdContact('internal','LIVREUR');
187 196
 			$this->livreur = new User($this->db);
188
-			if (! empty($idcontact[0])) $this->livreur->fetch($idcontact[0]);
197
+			if (! empty($idcontact[0])) {
198
+			    $this->livreur->fetch($idcontact[0]);
199
+			}
189 200
 
190 201
 			// Definition de $dir et $file
191 202
 			if ($object->specimen)
192 203
 			{
193 204
 				$dir = $conf->expedition->dir_output."/sending";
194 205
 				$file = $dir . "/SPECIMEN.pdf";
195
-			}
196
-			else
206
+			} else
197 207
 			{
198 208
 				$expref = dol_sanitizeFileName($object->ref);
199 209
 				$dir = $conf->expedition->dir_output . "/sending/" . $expref;
@@ -229,7 +239,9 @@  discard block
 block discarded – undo
229 239
 				$heightforinfotot = 0;	// Height reserved to output the info and total part
230 240
 		        $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
231 241
 	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
232
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
242
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) {
243
+	                $heightforfooter+= 6;
244
+	            }
233 245
                 $pdf->SetAutoPageBreak(1,0);
234 246
 
235 247
 			    if (class_exists('TCPDF'))
@@ -249,14 +261,18 @@  discard block
 block discarded – undo
249 261
 				$pagenb=0;
250 262
 				$pdf->SetDrawColor(128,128,128);
251 263
 
252
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
264
+				if (method_exists($pdf,'AliasNbPages')) {
265
+				    $pdf->AliasNbPages();
266
+				}
253 267
 
254 268
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
255 269
 				$pdf->SetSubject($outputlangs->transnoentities("Shipment"));
256 270
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
257 271
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
258 272
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
259
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
273
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
274
+				    $pdf->SetCompression(false);
275
+				}
260 276
 
261 277
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
262 278
 
@@ -287,8 +303,7 @@  discard block
 block discarded – undo
287 303
 
288 304
 					$tab_height = $tab_height - $height_note;
289 305
 					$tab_top = $nexY+6;
290
-				}
291
-				else
306
+				} else
292 307
 				{
293 308
 					$height_note=0;
294 309
 				}
@@ -365,8 +380,7 @@  discard block
 block discarded – undo
365 380
 						if ($pagenb == 1)
366 381
 						{
367 382
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
368
-						}
369
-						else
383
+						} else
370 384
 						{
371 385
 							$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
372 386
 						}
@@ -380,8 +394,7 @@  discard block
 block discarded – undo
380 394
 						if ($pagenb == 1)
381 395
 						{
382 396
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
383
-						}
384
-						else
397
+						} else
385 398
 						{
386 399
 							$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
387 400
 						}
@@ -397,8 +410,7 @@  discard block
 block discarded – undo
397 410
 				{
398 411
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
399 412
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
400
-				}
401
-				else
413
+				} else
402 414
 				{
403 415
 					$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
404 416
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
@@ -406,7 +418,9 @@  discard block
 block discarded – undo
406 418
 
407 419
 				// Pied de page
408 420
 				$this->_pagefoot($pdf, $object, $outputlangs);
409
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
421
+				if (method_exists($pdf,'AliasNbPages')) {
422
+				    $pdf->AliasNbPages();
423
+				}
410 424
 
411 425
 				$pdf->Close();
412 426
 
@@ -423,20 +437,19 @@  discard block
 block discarded – undo
423 437
 				global $action;
424 438
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
425 439
 
426
-                if (! empty($conf->global->MAIN_UMASK))
427
-                    @chmod($file, octdec($conf->global->MAIN_UMASK));
440
+                if (! empty($conf->global->MAIN_UMASK)) {
441
+                                    @chmod($file, octdec($conf->global->MAIN_UMASK));
442
+                }
428 443
 
429 444
 				$this->result = array('fullpath'=>$file);
430 445
 
431 446
 				return 1;
432
-			}
433
-			else
447
+			} else
434 448
 			{
435 449
 				$this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir",$dir);
436 450
 				return 0;
437 451
 			}
438
-		}
439
-		else
452
+		} else
440 453
 		{
441 454
 			$this->error=$outputlangs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
442 455
 			return 0;
@@ -556,16 +569,14 @@  discard block
 block discarded – undo
556 569
 			{
557 570
 			    $height=pdf_getHeightForLogo($logo);
558 571
 			    $pdf->Image($logo,10, 5, 0, $height);	// width=0 (auto)
559
-			}
560
-			else
572
+			} else
561 573
 			{
562 574
 				$pdf->SetTextColor(200,0,0);
563 575
 				$pdf->SetFont('','B', $default_font_size - 2);
564 576
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
565 577
 				$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
566 578
 			}
567
-		}
568
-		else
579
+		} else
569 580
 		{
570 581
 			$text=$this->emetteur->name;
571 582
 			$pdf->MultiCell(70, 3, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -665,8 +676,7 @@  discard block
 block discarded – undo
665 676
 					$pdf->writeHTMLCell(50, 8, '', '', $label, '', 'L');
666 677
 				}
667 678
 			}
668
-		}
669
-		else
679
+		} else
670 680
 		{
671 681
 			$pdf->MultiCell(50, 8, $outputlangs->transnoentities("Deliverer")." ".$outputlangs->convToOutputCharset($this->livreur->getFullName($outputlangs)), '', 'L');
672 682
 		}
Please login to merge, or discard this patch.
htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php 3 patches
Indentation   +520 added lines, -520 removed lines patch added patch discarded remove patch
@@ -40,550 +40,550 @@
 block discarded – undo
40 40
  */
41 41
 class doc_generic_shipment_odt extends ModelePdfExpedition
42 42
 {
43
-	/**
44
-	 * Issuer
45
-	 * @var Societe
46
-	 */
47
-	public $emetteur;
48
-
49
-	/**
50
-   * @var array() Minimum version of PHP required by module.
51
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
52
-   */
53
-	public $phpmin = array(5, 4);
54
-
55
-	/**
43
+    /**
44
+     * Issuer
45
+     * @var Societe
46
+     */
47
+    public $emetteur;
48
+
49
+    /**
50
+     * @var array() Minimum version of PHP required by module.
51
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
52
+     */
53
+    public $phpmin = array(5, 4);
54
+
55
+    /**
56 56
      * Dolibarr version of the loaded document
57 57
      * @public string
58 58
      */
59
-	public $version = 'dolibarr';
59
+    public $version = 'dolibarr';
60 60
 
61 61
 
62
-	/**
63
-	 *	Constructor
64
-	 *
65
-	 *  @param		DoliDB		$db      Database handler
66
-	 */
67
-	function __construct($db)
68
-	{
69
-		global $conf, $langs, $mysoc;
62
+    /**
63
+     *	Constructor
64
+     *
65
+     *  @param		DoliDB		$db      Database handler
66
+     */
67
+    function __construct($db)
68
+    {
69
+        global $conf, $langs, $mysoc;
70 70
 
71
-		// Load translation files required by the page
71
+        // Load translation files required by the page
72 72
         $langs->loadLangs(array("main","companies"));
73 73
 
74
-		$this->db = $db;
75
-		$this->name = "ODT templates";
76
-		$this->description = $langs->trans("DocumentModelOdt");
77
-		$this->scandir = 'EXPEDITION_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
78
-
79
-		// Dimension page pour format A4
80
-		$this->type = 'odt';
81
-		$this->page_largeur = 0;
82
-		$this->page_hauteur = 0;
83
-		$this->format = array($this->page_largeur,$this->page_hauteur);
84
-		$this->marge_gauche=0;
85
-		$this->marge_droite=0;
86
-		$this->marge_haute=0;
87
-		$this->marge_basse=0;
88
-
89
-		$this->option_logo = 1;                    // Affiche logo
90
-		$this->option_tva = 0;                     // Gere option tva EXPEDITION_TVAOPTION
91
-		$this->option_modereg = 0;                 // Affiche mode reglement
92
-		$this->option_condreg = 0;                 // Affiche conditions reglement
93
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
94
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
95
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
96
-		$this->option_credit_note = 0;             // Support credit notes
97
-		$this->option_freetext = 1;				   // Support add of a personalised text
98
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
99
-
100
-		// Recupere emetteur
101
-		$this->emetteur=$mysoc;
102
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
103
-	}
104
-
105
-
106
-	/**
107
-	 *	Return description of a module
108
-	 *
109
-	 *	@param	Translate	$langs      Lang object to use for output
110
-	 *	@return string       			Description
111
-	 */
112
-	function info($langs)
113
-	{
114
-		global $conf,$langs;
115
-
116
-		// Load translation files required by the page
74
+        $this->db = $db;
75
+        $this->name = "ODT templates";
76
+        $this->description = $langs->trans("DocumentModelOdt");
77
+        $this->scandir = 'EXPEDITION_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
78
+
79
+        // Dimension page pour format A4
80
+        $this->type = 'odt';
81
+        $this->page_largeur = 0;
82
+        $this->page_hauteur = 0;
83
+        $this->format = array($this->page_largeur,$this->page_hauteur);
84
+        $this->marge_gauche=0;
85
+        $this->marge_droite=0;
86
+        $this->marge_haute=0;
87
+        $this->marge_basse=0;
88
+
89
+        $this->option_logo = 1;                    // Affiche logo
90
+        $this->option_tva = 0;                     // Gere option tva EXPEDITION_TVAOPTION
91
+        $this->option_modereg = 0;                 // Affiche mode reglement
92
+        $this->option_condreg = 0;                 // Affiche conditions reglement
93
+        $this->option_codeproduitservice = 0;      // Affiche code produit-service
94
+        $this->option_multilang = 1;               // Dispo en plusieurs langues
95
+        $this->option_escompte = 0;                // Affiche si il y a eu escompte
96
+        $this->option_credit_note = 0;             // Support credit notes
97
+        $this->option_freetext = 1;				   // Support add of a personalised text
98
+        $this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
99
+
100
+        // Recupere emetteur
101
+        $this->emetteur=$mysoc;
102
+        if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
103
+    }
104
+
105
+
106
+    /**
107
+     *	Return description of a module
108
+     *
109
+     *	@param	Translate	$langs      Lang object to use for output
110
+     *	@return string       			Description
111
+     */
112
+    function info($langs)
113
+    {
114
+        global $conf,$langs;
115
+
116
+        // Load translation files required by the page
117 117
         $langs->loadLangs(array("errors","companies"));
118 118
 
119
-		$form = new Form($this->db);
120
-
121
-		$texte = $this->description.".<br>\n";
122
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
123
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
124
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
125
-		$texte.= '<input type="hidden" name="param1" value="EXPEDITION_ADDON_PDF_ODT_PATH">';
126
-		$texte.= '<table class="nobordernopadding" width="100%">';
127
-
128
-		// List of directories area
129
-		$texte.= '<tr><td>';
130
-		$texttitle=$langs->trans("ListOfDirectories");
131
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->EXPEDITION_ADDON_PDF_ODT_PATH)));
132
-		$listoffiles=array();
133
-		foreach($listofdir as $key=>$tmpdir)
134
-		{
135
-			$tmpdir=trim($tmpdir);
136
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
137
-			if (! $tmpdir) {
138
-				unset($listofdir[$key]); continue;
139
-			}
140
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
141
-			else
142
-			{
143
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
144
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
145
-			}
146
-		}
147
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
148
-		// Add list of substitution keys
149
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
150
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
151
-
152
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
153
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
154
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
155
-		$texte.=$conf->global->EXPEDITION_ADDON_PDF_ODT_PATH;
156
-		$texte.= '</textarea>';
157
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
158
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
159
-		$texte.= '<br></div></div>';
160
-
161
-		// Scan directories
162
-		$nbofiles=count($listoffiles);
163
-		if (! empty($conf->global->EXPEDITION_ADDON_PDF_ODT_PATH))
164
-		{
165
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
166
-			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
167
-			$texte.=count($listoffiles);
168
-			//$texte.=$nbofiles?'</a>':'';
169
-			$texte.='</b>';
170
-		}
171
-		if ($nbofiles)
172
-		{
173
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
174
-   			foreach($listoffiles as $file)
175
-   			{
119
+        $form = new Form($this->db);
120
+
121
+        $texte = $this->description.".<br>\n";
122
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
123
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
124
+        $texte.= '<input type="hidden" name="action" value="setModuleOptions">';
125
+        $texte.= '<input type="hidden" name="param1" value="EXPEDITION_ADDON_PDF_ODT_PATH">';
126
+        $texte.= '<table class="nobordernopadding" width="100%">';
127
+
128
+        // List of directories area
129
+        $texte.= '<tr><td>';
130
+        $texttitle=$langs->trans("ListOfDirectories");
131
+        $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->EXPEDITION_ADDON_PDF_ODT_PATH)));
132
+        $listoffiles=array();
133
+        foreach($listofdir as $key=>$tmpdir)
134
+        {
135
+            $tmpdir=trim($tmpdir);
136
+            $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
137
+            if (! $tmpdir) {
138
+                unset($listofdir[$key]); continue;
139
+            }
140
+            if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
141
+            else
142
+            {
143
+                $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
144
+                if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
145
+            }
146
+        }
147
+        $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
148
+        // Add list of substitution keys
149
+        $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
150
+        $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
151
+
152
+        $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
153
+        $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
154
+        $texte.= '<textarea class="flat" cols="60" name="value1">';
155
+        $texte.=$conf->global->EXPEDITION_ADDON_PDF_ODT_PATH;
156
+        $texte.= '</textarea>';
157
+        $texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
158
+        $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
159
+        $texte.= '<br></div></div>';
160
+
161
+        // Scan directories
162
+        $nbofiles=count($listoffiles);
163
+        if (! empty($conf->global->EXPEDITION_ADDON_PDF_ODT_PATH))
164
+        {
165
+            $texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
166
+            //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
167
+            $texte.=count($listoffiles);
168
+            //$texte.=$nbofiles?'</a>':'';
169
+            $texte.='</b>';
170
+        }
171
+        if ($nbofiles)
172
+        {
173
+                $texte.='<div id="div_'.get_class($this).'" class="hidden">';
174
+                foreach($listoffiles as $file)
175
+                {
176 176
                 $texte.=$file['name'].'<br>';
177
-   			}
178
-   			$texte.='<div id="div_'.get_class($this).'">';
179
-		}
177
+                }
178
+                $texte.='<div id="div_'.get_class($this).'">';
179
+        }
180 180
 
181
-		$texte.= '</td>';
181
+        $texte.= '</td>';
182 182
 
183
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
184
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
185
-		$texte.= '</td>';
186
-		$texte.= '</tr>';
183
+        $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
184
+        $texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
185
+        $texte.= '</td>';
186
+        $texte.= '</tr>';
187 187
 
188
-		$texte.= '</table>';
189
-		$texte.= '</form>';
188
+        $texte.= '</table>';
189
+        $texte.= '</form>';
190 190
 
191
-		return $texte;
192
-	}
191
+        return $texte;
192
+    }
193 193
 
194 194
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
195
-	/**
196
-	 *	Function to build a document on disk using the generic odt module.
197
-	 *
198
-	 *	@param		Expedition	$object				Object source to build document
199
-	 *	@param		Translate	$outputlangs		Lang output object
200
-	 * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
201
-	 *  @param		int			$hidedetails		Do not show line details
202
-	 *  @param		int			$hidedesc			Do not show desc
203
-	 *  @param		int			$hideref			Do not show ref
204
-	 *	@return		int         					1 if OK, <=0 if KO
205
-	 */
206
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
207
-	{
195
+    /**
196
+     *	Function to build a document on disk using the generic odt module.
197
+     *
198
+     *	@param		Expedition	$object				Object source to build document
199
+     *	@param		Translate	$outputlangs		Lang output object
200
+     * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
201
+     *  @param		int			$hidedetails		Do not show line details
202
+     *  @param		int			$hidedesc			Do not show desc
203
+     *  @param		int			$hideref			Do not show ref
204
+     *	@return		int         					1 if OK, <=0 if KO
205
+     */
206
+    function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
207
+    {
208 208
         // phpcs:enable
209
-		global $user,$langs,$conf,$mysoc,$hookmanager;
210
-
211
-		if (empty($srctemplatepath))
212
-		{
213
-			dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
214
-			return -1;
215
-		}
216
-
217
-		// Add odtgeneration hook
218
-		if (! is_object($hookmanager))
219
-		{
220
-			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
221
-			$hookmanager=new HookManager($this->db);
222
-		}
223
-		$hookmanager->initHooks(array('odtgeneration'));
224
-		global $action;
225
-
226
-		if (! is_object($outputlangs)) $outputlangs=$langs;
227
-		$sav_charset_output=$outputlangs->charset_output;
228
-		$outputlangs->charset_output='UTF-8';
229
-
230
-		// Load traductions files requiredby by page
231
-		$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
232
-
233
-		if ($conf->expedition->dir_output."/sending")
234
-		{
235
-			// If $object is id instead of object
236
-			if (! is_object($object))
237
-			{
238
-				$id = $object;
239
-				$object = new Expedition($this->db);
240
-				$result=$object->fetch($id);
241
-				if ($result < 0)
242
-				{
243
-					dol_print_error($this->db,$object->error);
244
-					return -1;
245
-				}
246
-			}
247
-
248
-			$dir = $conf->expedition->dir_output."/sending";
249
-			$objectref = dol_sanitizeFileName($object->ref);
250
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
251
-			$file = $dir . "/" . $objectref . ".odt";
252
-
253
-			if (! file_exists($dir))
254
-			{
255
-				if (dol_mkdir($dir) < 0)
256
-				{
257
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
258
-					return -1;
259
-				}
260
-			}
261
-
262
-			if (file_exists($dir))
263
-			{
264
-				//print "srctemplatepath=".$srctemplatepath;	// Src filename
265
-				$newfile=basename($srctemplatepath);
266
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
267
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
268
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
269
-				$newfiletmp=$objectref.'_'.$newfiletmp;
270
-				//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
271
-				// Get extension (ods or odt)
272
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
273
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
274
-				{
275
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
276
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
277
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
278
-				}
279
-				else
280
-				{
281
-					$filename=$newfiletmp.'.'.$newfileformat;
282
-				}
283
-				$file=$dir.'/'.$filename;
284
-				//print "newdir=".$dir;
285
-				//print "newfile=".$newfile;
286
-				//print "file=".$file;
287
-				//print "conf->societe->dir_temp=".$conf->societe->dir_temp;
288
-
289
-				dol_mkdir($conf->expedition->dir_temp);
290
-
291
-
292
-				// If SHIPMENT contact defined on invoice, we use it
293
-				$usecontact=false;
294
-				$arrayidcontact=$object->getIdContact('external','SHIPPING');
295
-				if (count($arrayidcontact) > 0)
296
-				{
297
-					$usecontact=true;
298
-					$result=$object->fetch_contact($arrayidcontact[0]);
299
-				}
300
-
301
-				// Recipient name
302
-				$contactobject = null;
303
-				if (! empty($usecontact)) {
304
-					// On peut utiliser le nom de la societe du contact
305
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))
306
-						$socobject = $object->contact;
307
-					else {
308
-						$socobject = $object->thirdparty;
309
-						// if we have a SHIIPPING contact and we dont use it as recipient we store the contact object for later use
310
-						$contactobject = $object->contact;
311
-					}
312
-				} else {
313
-					$socobject = $object->thirdparty;
314
-				}
315
-
316
-				// Make substitution
317
-				$substitutionarray=array(
318
-					'__FROM_NAME__' => $this->emetteur->name,
319
-					'__FROM_EMAIL__' => $this->emetteur->email,
320
-					'__TOTAL_TTC__' => $object->total_ttc,
321
-					'__TOTAL_HT__' => $object->total_ht,
322
-					'__TOTAL_VAT__' => $object->total_vat
323
-				);
324
-				complete_substitutions_array($substitutionarray, $langs, $object);
325
-				// Call the ODTSubstitution hook
326
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
327
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
328
-
329
-				// Line of free text
330
-				$newfreetext='';
331
-				$paramfreetext='EXPEDITION_FREE_TEXT';
332
-				if (! empty($conf->global->$paramfreetext))
333
-				{
334
-					$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
335
-				}
336
-
337
-				// Open and load template
338
-				require_once ODTPHP_PATH.'odf.php';
339
-				try {
340
-					$odfHandler = new odf(
341
-						$srctemplatepath,
342
-						array(
343
-						'PATH_TO_TMP'	  => $conf->expedition->dir_temp,
344
-						'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
345
-						'DELIMITER_LEFT'  => '{',
346
-						'DELIMITER_RIGHT' => '}'
347
-						)
348
-					);
349
-				}
350
-				catch(Exception $e)
351
-				{
352
-					$this->error=$e->getMessage();
353
-					dol_syslog($e->getMessage(), LOG_INFO);
354
-					return -1;
355
-				}
356
-				// After construction $odfHandler->contentXml contains content and
357
-				// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
358
-				// [!-- BEGIN lines --]*[!-- END lines --]
359
-				//print html_entity_decode($odfHandler->__toString());
360
-				//print exit;
361
-
362
-
363
-				// Make substitutions into odt of freetext
364
-				try {
365
-					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
366
-				}
367
-				catch(OdfException $e)
368
-				{
369
-					dol_syslog($e->getMessage(), LOG_INFO);
370
-				}
371
-
372
-				// Make substitutions into odt of user info
373
-				$tmparray=$this->get_substitutionarray_user($user,$outputlangs);
374
-				//var_dump($tmparray); exit;
375
-				foreach($tmparray as $key=>$value)
376
-				{
377
-					try {
378
-						if (preg_match('/logo$/',$key)) // Image
379
-						{
380
-							//var_dump($value);exit;
381
-							if (file_exists($value)) $odfHandler->setImage($key, $value);
382
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
383
-						}
384
-						else    // Text
385
-						{
386
-							$odfHandler->setVars($key, $value, true, 'UTF-8');
387
-						}
388
-					}
389
-					catch (OdfException $e)
390
-					{
209
+        global $user,$langs,$conf,$mysoc,$hookmanager;
210
+
211
+        if (empty($srctemplatepath))
212
+        {
213
+            dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
214
+            return -1;
215
+        }
216
+
217
+        // Add odtgeneration hook
218
+        if (! is_object($hookmanager))
219
+        {
220
+            include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
221
+            $hookmanager=new HookManager($this->db);
222
+        }
223
+        $hookmanager->initHooks(array('odtgeneration'));
224
+        global $action;
225
+
226
+        if (! is_object($outputlangs)) $outputlangs=$langs;
227
+        $sav_charset_output=$outputlangs->charset_output;
228
+        $outputlangs->charset_output='UTF-8';
229
+
230
+        // Load traductions files requiredby by page
231
+        $outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
232
+
233
+        if ($conf->expedition->dir_output."/sending")
234
+        {
235
+            // If $object is id instead of object
236
+            if (! is_object($object))
237
+            {
238
+                $id = $object;
239
+                $object = new Expedition($this->db);
240
+                $result=$object->fetch($id);
241
+                if ($result < 0)
242
+                {
243
+                    dol_print_error($this->db,$object->error);
244
+                    return -1;
245
+                }
246
+            }
247
+
248
+            $dir = $conf->expedition->dir_output."/sending";
249
+            $objectref = dol_sanitizeFileName($object->ref);
250
+            if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
251
+            $file = $dir . "/" . $objectref . ".odt";
252
+
253
+            if (! file_exists($dir))
254
+            {
255
+                if (dol_mkdir($dir) < 0)
256
+                {
257
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
258
+                    return -1;
259
+                }
260
+            }
261
+
262
+            if (file_exists($dir))
263
+            {
264
+                //print "srctemplatepath=".$srctemplatepath;	// Src filename
265
+                $newfile=basename($srctemplatepath);
266
+                $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
267
+                $newfiletmp=preg_replace('/template_/i','',$newfiletmp);
268
+                $newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
269
+                $newfiletmp=$objectref.'_'.$newfiletmp;
270
+                //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
271
+                // Get extension (ods or odt)
272
+                $newfileformat=substr($newfile, strrpos($newfile, '.')+1);
273
+                if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
274
+                {
275
+                    $format=$conf->global->MAIN_DOC_USE_TIMING;
276
+                    if ($format == '1') $format='%Y%m%d%H%M%S';
277
+                    $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
278
+                }
279
+                else
280
+                {
281
+                    $filename=$newfiletmp.'.'.$newfileformat;
282
+                }
283
+                $file=$dir.'/'.$filename;
284
+                //print "newdir=".$dir;
285
+                //print "newfile=".$newfile;
286
+                //print "file=".$file;
287
+                //print "conf->societe->dir_temp=".$conf->societe->dir_temp;
288
+
289
+                dol_mkdir($conf->expedition->dir_temp);
290
+
291
+
292
+                // If SHIPMENT contact defined on invoice, we use it
293
+                $usecontact=false;
294
+                $arrayidcontact=$object->getIdContact('external','SHIPPING');
295
+                if (count($arrayidcontact) > 0)
296
+                {
297
+                    $usecontact=true;
298
+                    $result=$object->fetch_contact($arrayidcontact[0]);
299
+                }
300
+
301
+                // Recipient name
302
+                $contactobject = null;
303
+                if (! empty($usecontact)) {
304
+                    // On peut utiliser le nom de la societe du contact
305
+                    if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))
306
+                        $socobject = $object->contact;
307
+                    else {
308
+                        $socobject = $object->thirdparty;
309
+                        // if we have a SHIIPPING contact and we dont use it as recipient we store the contact object for later use
310
+                        $contactobject = $object->contact;
311
+                    }
312
+                } else {
313
+                    $socobject = $object->thirdparty;
314
+                }
315
+
316
+                // Make substitution
317
+                $substitutionarray=array(
318
+                    '__FROM_NAME__' => $this->emetteur->name,
319
+                    '__FROM_EMAIL__' => $this->emetteur->email,
320
+                    '__TOTAL_TTC__' => $object->total_ttc,
321
+                    '__TOTAL_HT__' => $object->total_ht,
322
+                    '__TOTAL_VAT__' => $object->total_vat
323
+                );
324
+                complete_substitutions_array($substitutionarray, $langs, $object);
325
+                // Call the ODTSubstitution hook
326
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
327
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
328
+
329
+                // Line of free text
330
+                $newfreetext='';
331
+                $paramfreetext='EXPEDITION_FREE_TEXT';
332
+                if (! empty($conf->global->$paramfreetext))
333
+                {
334
+                    $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
335
+                }
336
+
337
+                // Open and load template
338
+                require_once ODTPHP_PATH.'odf.php';
339
+                try {
340
+                    $odfHandler = new odf(
341
+                        $srctemplatepath,
342
+                        array(
343
+                        'PATH_TO_TMP'	  => $conf->expedition->dir_temp,
344
+                        'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
345
+                        'DELIMITER_LEFT'  => '{',
346
+                        'DELIMITER_RIGHT' => '}'
347
+                        )
348
+                    );
349
+                }
350
+                catch(Exception $e)
351
+                {
352
+                    $this->error=$e->getMessage();
353
+                    dol_syslog($e->getMessage(), LOG_INFO);
354
+                    return -1;
355
+                }
356
+                // After construction $odfHandler->contentXml contains content and
357
+                // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
358
+                // [!-- BEGIN lines --]*[!-- END lines --]
359
+                //print html_entity_decode($odfHandler->__toString());
360
+                //print exit;
361
+
362
+
363
+                // Make substitutions into odt of freetext
364
+                try {
365
+                    $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
366
+                }
367
+                catch(OdfException $e)
368
+                {
369
+                    dol_syslog($e->getMessage(), LOG_INFO);
370
+                }
371
+
372
+                // Make substitutions into odt of user info
373
+                $tmparray=$this->get_substitutionarray_user($user,$outputlangs);
374
+                //var_dump($tmparray); exit;
375
+                foreach($tmparray as $key=>$value)
376
+                {
377
+                    try {
378
+                        if (preg_match('/logo$/',$key)) // Image
379
+                        {
380
+                            //var_dump($value);exit;
381
+                            if (file_exists($value)) $odfHandler->setImage($key, $value);
382
+                            else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
383
+                        }
384
+                        else    // Text
385
+                        {
386
+                            $odfHandler->setVars($key, $value, true, 'UTF-8');
387
+                        }
388
+                    }
389
+                    catch (OdfException $e)
390
+                    {
391 391
                         dol_syslog($e->getMessage(), LOG_INFO);
392
-					}
393
-				}
394
-				// Make substitutions into odt of mysoc
395
-				$tmparray=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
396
-				//var_dump($tmparray); exit;
397
-				foreach($tmparray as $key=>$value)
398
-				{
399
-					try {
400
-						if (preg_match('/logo$/',$key))	// Image
401
-						{
402
-							//var_dump($value);exit;
403
-							if (file_exists($value)) $odfHandler->setImage($key, $value);
404
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
405
-						}
406
-						else	// Text
407
-						{
408
-							$odfHandler->setVars($key, $value, true, 'UTF-8');
409
-						}
410
-					}
411
-					catch (OdfException $e)
412
-					{
392
+                    }
393
+                }
394
+                // Make substitutions into odt of mysoc
395
+                $tmparray=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
396
+                //var_dump($tmparray); exit;
397
+                foreach($tmparray as $key=>$value)
398
+                {
399
+                    try {
400
+                        if (preg_match('/logo$/',$key))	// Image
401
+                        {
402
+                            //var_dump($value);exit;
403
+                            if (file_exists($value)) $odfHandler->setImage($key, $value);
404
+                            else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
405
+                        }
406
+                        else	// Text
407
+                        {
408
+                            $odfHandler->setVars($key, $value, true, 'UTF-8');
409
+                        }
410
+                    }
411
+                    catch (OdfException $e)
412
+                    {
413 413
                         dol_syslog($e->getMessage(), LOG_INFO);
414
-					}
415
-				}
416
-				// Make substitutions into odt of thirdparty
417
-				$tmparray=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
418
-				foreach($tmparray as $key=>$value)
419
-				{
420
-					try {
421
-						if (preg_match('/logo$/',$key))	// Image
422
-						{
423
-							if (file_exists($value)) $odfHandler->setImage($key, $value);
424
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
425
-						}
426
-						else	// Text
427
-						{
428
-							$odfHandler->setVars($key, $value, true, 'UTF-8');
429
-						}
430
-					}
431
-					catch (OdfException $e)
432
-					{
414
+                    }
415
+                }
416
+                // Make substitutions into odt of thirdparty
417
+                $tmparray=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
418
+                foreach($tmparray as $key=>$value)
419
+                {
420
+                    try {
421
+                        if (preg_match('/logo$/',$key))	// Image
422
+                        {
423
+                            if (file_exists($value)) $odfHandler->setImage($key, $value);
424
+                            else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
425
+                        }
426
+                        else	// Text
427
+                        {
428
+                            $odfHandler->setVars($key, $value, true, 'UTF-8');
429
+                        }
430
+                    }
431
+                    catch (OdfException $e)
432
+                    {
433 433
                         dol_syslog($e->getMessage(), LOG_INFO);
434
-					}
435
-				}
436
-
437
-				if ($usecontact && is_object($contactobject)) {
438
-					$tmparray=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
439
-					foreach($tmparray as $key=>$value)
440
-					{
441
-						try {
442
-							if (preg_match('/logo$/',$key))	// Image
443
-							{
444
-								if (file_exists($value)) $odfHandler->setImage($key, $value);
445
-								else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
446
-							}
447
-							else	// Text
448
-							{
449
-								$odfHandler->setVars($key, $value, true, 'UTF-8');
450
-							}
451
-						}
452
-						catch(OdfException $e)
453
-						{
434
+                    }
435
+                }
436
+
437
+                if ($usecontact && is_object($contactobject)) {
438
+                    $tmparray=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
439
+                    foreach($tmparray as $key=>$value)
440
+                    {
441
+                        try {
442
+                            if (preg_match('/logo$/',$key))	// Image
443
+                            {
444
+                                if (file_exists($value)) $odfHandler->setImage($key, $value);
445
+                                else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
446
+                            }
447
+                            else	// Text
448
+                            {
449
+                                $odfHandler->setVars($key, $value, true, 'UTF-8');
450
+                            }
451
+                        }
452
+                        catch(OdfException $e)
453
+                        {
454 454
                             dol_syslog($e->getMessage(), LOG_INFO);
455
-						}
456
-					}
457
-				}
458
-
459
-				// Replace tags of object + external modules
460
-				$tmparray=$this->get_substitutionarray_shipment($object,$outputlangs);
461
-				complete_substitutions_array($tmparray, $outputlangs, $object);
462
-				// Call the ODTSubstitution hook
463
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
464
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
465
-				foreach($tmparray as $key=>$value)
466
-				{
467
-					try {
468
-						if (preg_match('/logo$/',$key)) // Image
469
-						{
470
-							if (file_exists($value)) $odfHandler->setImage($key, $value);
471
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
472
-						}
473
-						else    // Text
474
-						{
475
-							$odfHandler->setVars($key, $value, true, 'UTF-8');
476
-						}
477
-					}
478
-					catch(OdfException $e)
479
-					{
455
+                        }
456
+                    }
457
+                }
458
+
459
+                // Replace tags of object + external modules
460
+                $tmparray=$this->get_substitutionarray_shipment($object,$outputlangs);
461
+                complete_substitutions_array($tmparray, $outputlangs, $object);
462
+                // Call the ODTSubstitution hook
463
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
464
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
465
+                foreach($tmparray as $key=>$value)
466
+                {
467
+                    try {
468
+                        if (preg_match('/logo$/',$key)) // Image
469
+                        {
470
+                            if (file_exists($value)) $odfHandler->setImage($key, $value);
471
+                            else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
472
+                        }
473
+                        else    // Text
474
+                        {
475
+                            $odfHandler->setVars($key, $value, true, 'UTF-8');
476
+                        }
477
+                    }
478
+                    catch(OdfException $e)
479
+                    {
480
+                        dol_syslog($e->getMessage(), LOG_INFO);
481
+                    }
482
+                }
483
+                // Replace tags of lines
484
+                try
485
+                {
486
+                    $foundtagforlines = 1;
487
+                    try {
488
+                        $listlines = $odfHandler->setSegment('lines');
489
+                    }
490
+                    catch(OdfException $e)
491
+                    {
492
+                        // We may arrive here if tags for lines not present into template
493
+                        $foundtagforlines = 0;
480 494
                         dol_syslog($e->getMessage(), LOG_INFO);
481
-					}
482
-				}
483
-				// Replace tags of lines
484
-				try
485
-				{
486
-					$foundtagforlines = 1;
487
-					try {
488
-						$listlines = $odfHandler->setSegment('lines');
489
-					}
490
-					catch(OdfException $e)
491
-					{
492
-						// We may arrive here if tags for lines not present into template
493
-						$foundtagforlines = 0;
494
-						dol_syslog($e->getMessage(), LOG_INFO);
495
-					}
496
-					if ($foundtagforlines)
497
-					{
498
-						foreach ($object->lines as $line)
499
-						{
500
-							$tmparray=$this->get_substitutionarray_shipment_lines($line,$outputlangs);
501
-							complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
502
-							// Call the ODTSubstitutionLine hook
503
-							$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
504
-							$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
505
-							foreach($tmparray as $key => $val)
506
-							{
507
-								try
508
-								{
509
-									$listlines->setVars($key, $val, true, 'UTF-8');
510
-								}
511
-								catch(OdfException $e)
512
-								{
513
-									dol_syslog($e->getMessage(), LOG_INFO);
514
-								}
515
-								catch(SegmentException $e)
516
-								{
517
-									dol_syslog($e->getMessage(), LOG_INFO);
518
-								}
519
-							}
520
-							$listlines->merge();
521
-						}
522
-						$odfHandler->mergeSegment($listlines);
523
-					}
524
-				}
525
-				catch (OdfException $e)
526
-				{
527
-					$this->error=$e->getMessage();
528
-					dol_syslog($this->error, LOG_WARNING);
529
-					return -1;
530
-				}
531
-
532
-				// Replace labels translated
533
-				$tmparray=$outputlangs->get_translations_for_substitutions();
534
-				foreach($tmparray as $key=>$value)
535
-				{
536
-					try {
537
-						$odfHandler->setVars($key, $value, true, 'UTF-8');
538
-					}
539
-					catch (OdfException $e)
540
-					{
495
+                    }
496
+                    if ($foundtagforlines)
497
+                    {
498
+                        foreach ($object->lines as $line)
499
+                        {
500
+                            $tmparray=$this->get_substitutionarray_shipment_lines($line,$outputlangs);
501
+                            complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
502
+                            // Call the ODTSubstitutionLine hook
503
+                            $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
504
+                            $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
505
+                            foreach($tmparray as $key => $val)
506
+                            {
507
+                                try
508
+                                {
509
+                                    $listlines->setVars($key, $val, true, 'UTF-8');
510
+                                }
511
+                                catch(OdfException $e)
512
+                                {
513
+                                    dol_syslog($e->getMessage(), LOG_INFO);
514
+                                }
515
+                                catch(SegmentException $e)
516
+                                {
517
+                                    dol_syslog($e->getMessage(), LOG_INFO);
518
+                                }
519
+                            }
520
+                            $listlines->merge();
521
+                        }
522
+                        $odfHandler->mergeSegment($listlines);
523
+                    }
524
+                }
525
+                catch (OdfException $e)
526
+                {
527
+                    $this->error=$e->getMessage();
528
+                    dol_syslog($this->error, LOG_WARNING);
529
+                    return -1;
530
+                }
531
+
532
+                // Replace labels translated
533
+                $tmparray=$outputlangs->get_translations_for_substitutions();
534
+                foreach($tmparray as $key=>$value)
535
+                {
536
+                    try {
537
+                        $odfHandler->setVars($key, $value, true, 'UTF-8');
538
+                    }
539
+                    catch (OdfException $e)
540
+                    {
541 541
                         dol_syslog($e->getMessage(), LOG_INFO);
542
-					}
543
-				}
544
-
545
-				// Call the beforeODTSave hook
546
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
547
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
548
-
549
-				// Write new file
550
-				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
551
-					try {
552
-						$odfHandler->exportAsAttachedPDF($file);
553
-					} catch (Exception $e) {
554
-						$this->error=$e->getMessage();
542
+                    }
543
+                }
544
+
545
+                // Call the beforeODTSave hook
546
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
547
+                $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
548
+
549
+                // Write new file
550
+                if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
551
+                    try {
552
+                        $odfHandler->exportAsAttachedPDF($file);
553
+                    } catch (Exception $e) {
554
+                        $this->error=$e->getMessage();
555 555
                         dol_syslog($e->getMessage(), LOG_INFO);
556
-						return -1;
557
-					}
558
-				}
559
-				else {
560
-					try {
561
-					$odfHandler->saveToDisk($file);
562
-					} catch (Exception $e) {
563
-						$this->error=$e->getMessage();
556
+                        return -1;
557
+                    }
558
+                }
559
+                else {
560
+                    try {
561
+                    $odfHandler->saveToDisk($file);
562
+                    } catch (Exception $e) {
563
+                        $this->error=$e->getMessage();
564 564
                         dol_syslog($e->getMessage(), LOG_INFO);
565
-						return -1;
566
-					}
567
-				}
568
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
569
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
570
-
571
-				if (! empty($conf->global->MAIN_UMASK))
572
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
573
-
574
-				$odfHandler=null;	// Destroy object
575
-
576
-				$this->result = array('fullpath'=>$file);
577
-
578
-				return 1;   // Success
579
-			}
580
-			else
581
-			{
582
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
583
-				return -1;
584
-			}
585
-		}
586
-
587
-		return -1;
588
-	}
565
+                        return -1;
566
+                    }
567
+                }
568
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
569
+                $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
570
+
571
+                if (! empty($conf->global->MAIN_UMASK))
572
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
573
+
574
+                $odfHandler=null;	// Destroy object
575
+
576
+                $this->result = array('fullpath'=>$file);
577
+
578
+                return 1;   // Success
579
+            }
580
+            else
581
+            {
582
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
583
+                return -1;
584
+            }
585
+        }
586
+
587
+        return -1;
588
+    }
589 589
 }
Please login to merge, or discard this patch.
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -69,37 +69,37 @@  discard block
 block discarded – undo
69 69
 		global $conf, $langs, $mysoc;
70 70
 
71 71
 		// Load translation files required by the page
72
-        $langs->loadLangs(array("main","companies"));
72
+        $langs->loadLangs(array("main", "companies"));
73 73
 
74 74
 		$this->db = $db;
75 75
 		$this->name = "ODT templates";
76 76
 		$this->description = $langs->trans("DocumentModelOdt");
77
-		$this->scandir = 'EXPEDITION_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
77
+		$this->scandir = 'EXPEDITION_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
78 78
 
79 79
 		// Dimension page pour format A4
80 80
 		$this->type = 'odt';
81 81
 		$this->page_largeur = 0;
82 82
 		$this->page_hauteur = 0;
83
-		$this->format = array($this->page_largeur,$this->page_hauteur);
84
-		$this->marge_gauche=0;
85
-		$this->marge_droite=0;
86
-		$this->marge_haute=0;
87
-		$this->marge_basse=0;
88
-
89
-		$this->option_logo = 1;                    // Affiche logo
90
-		$this->option_tva = 0;                     // Gere option tva EXPEDITION_TVAOPTION
91
-		$this->option_modereg = 0;                 // Affiche mode reglement
92
-		$this->option_condreg = 0;                 // Affiche conditions reglement
93
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
94
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
95
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
96
-		$this->option_credit_note = 0;             // Support credit notes
97
-		$this->option_freetext = 1;				   // Support add of a personalised text
98
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
83
+		$this->format = array($this->page_largeur, $this->page_hauteur);
84
+		$this->marge_gauche = 0;
85
+		$this->marge_droite = 0;
86
+		$this->marge_haute = 0;
87
+		$this->marge_basse = 0;
88
+
89
+		$this->option_logo = 1; // Affiche logo
90
+		$this->option_tva = 0; // Gere option tva EXPEDITION_TVAOPTION
91
+		$this->option_modereg = 0; // Affiche mode reglement
92
+		$this->option_condreg = 0; // Affiche conditions reglement
93
+		$this->option_codeproduitservice = 0; // Affiche code produit-service
94
+		$this->option_multilang = 1; // Dispo en plusieurs langues
95
+		$this->option_escompte = 0; // Affiche si il y a eu escompte
96
+		$this->option_credit_note = 0; // Support credit notes
97
+		$this->option_freetext = 1; // Support add of a personalised text
98
+		$this->option_draft_watermark = 0; // Support add of a watermark on drafts
99 99
 
100 100
 		// Recupere emetteur
101
-		$this->emetteur=$mysoc;
102
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
101
+		$this->emetteur = $mysoc;
102
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
103 103
 	}
104 104
 
105 105
 
@@ -111,82 +111,82 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	function info($langs)
113 113
 	{
114
-		global $conf,$langs;
114
+		global $conf, $langs;
115 115
 
116 116
 		// Load translation files required by the page
117
-        $langs->loadLangs(array("errors","companies"));
117
+        $langs->loadLangs(array("errors", "companies"));
118 118
 
119 119
 		$form = new Form($this->db);
120 120
 
121 121
 		$texte = $this->description.".<br>\n";
122
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
123
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
124
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
125
-		$texte.= '<input type="hidden" name="param1" value="EXPEDITION_ADDON_PDF_ODT_PATH">';
126
-		$texte.= '<table class="nobordernopadding" width="100%">';
122
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
123
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
124
+		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
125
+		$texte .= '<input type="hidden" name="param1" value="EXPEDITION_ADDON_PDF_ODT_PATH">';
126
+		$texte .= '<table class="nobordernopadding" width="100%">';
127 127
 
128 128
 		// List of directories area
129
-		$texte.= '<tr><td>';
130
-		$texttitle=$langs->trans("ListOfDirectories");
131
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->EXPEDITION_ADDON_PDF_ODT_PATH)));
132
-		$listoffiles=array();
133
-		foreach($listofdir as $key=>$tmpdir)
129
+		$texte .= '<tr><td>';
130
+		$texttitle = $langs->trans("ListOfDirectories");
131
+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->EXPEDITION_ADDON_PDF_ODT_PATH)));
132
+		$listoffiles = array();
133
+		foreach ($listofdir as $key=>$tmpdir)
134 134
 		{
135
-			$tmpdir=trim($tmpdir);
136
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
137
-			if (! $tmpdir) {
135
+			$tmpdir = trim($tmpdir);
136
+			$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
137
+			if (!$tmpdir) {
138 138
 				unset($listofdir[$key]); continue;
139 139
 			}
140
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
140
+			if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
141 141
 			else
142 142
 			{
143
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
144
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
143
+				$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
144
+				if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
145 145
 			}
146 146
 		}
147
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
147
+		$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
148 148
 		// Add list of substitution keys
149
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
150
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
151
-
152
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
153
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
154
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
155
-		$texte.=$conf->global->EXPEDITION_ADDON_PDF_ODT_PATH;
156
-		$texte.= '</textarea>';
157
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
158
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
159
-		$texte.= '<br></div></div>';
149
+		$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
150
+		$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
151
+
152
+		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
153
+		$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
154
+		$texte .= '<textarea class="flat" cols="60" name="value1">';
155
+		$texte .= $conf->global->EXPEDITION_ADDON_PDF_ODT_PATH;
156
+		$texte .= '</textarea>';
157
+		$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
158
+		$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
159
+		$texte .= '<br></div></div>';
160 160
 
161 161
 		// Scan directories
162
-		$nbofiles=count($listoffiles);
163
-		if (! empty($conf->global->EXPEDITION_ADDON_PDF_ODT_PATH))
162
+		$nbofiles = count($listoffiles);
163
+		if (!empty($conf->global->EXPEDITION_ADDON_PDF_ODT_PATH))
164 164
 		{
165
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
165
+			$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
166 166
 			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
167
-			$texte.=count($listoffiles);
167
+			$texte .= count($listoffiles);
168 168
 			//$texte.=$nbofiles?'</a>':'';
169
-			$texte.='</b>';
169
+			$texte .= '</b>';
170 170
 		}
171 171
 		if ($nbofiles)
172 172
 		{
173
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
174
-   			foreach($listoffiles as $file)
173
+   			$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
174
+   			foreach ($listoffiles as $file)
175 175
    			{
176
-                $texte.=$file['name'].'<br>';
176
+                $texte .= $file['name'].'<br>';
177 177
    			}
178
-   			$texte.='<div id="div_'.get_class($this).'">';
178
+   			$texte .= '<div id="div_'.get_class($this).'">';
179 179
 		}
180 180
 
181
-		$texte.= '</td>';
181
+		$texte .= '</td>';
182 182
 
183
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
184
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
185
-		$texte.= '</td>';
186
-		$texte.= '</tr>';
183
+		$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
184
+		$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
185
+		$texte .= '</td>';
186
+		$texte .= '</tr>';
187 187
 
188
-		$texte.= '</table>';
189
-		$texte.= '</form>';
188
+		$texte .= '</table>';
189
+		$texte .= '</form>';
190 190
 
191 191
 		return $texte;
192 192
 	}
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
 	 *  @param		int			$hideref			Do not show ref
204 204
 	 *	@return		int         					1 if OK, <=0 if KO
205 205
 	 */
206
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
206
+	function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
207 207
 	{
208 208
         // phpcs:enable
209
-		global $user,$langs,$conf,$mysoc,$hookmanager;
209
+		global $user, $langs, $conf, $mysoc, $hookmanager;
210 210
 
211 211
 		if (empty($srctemplatepath))
212 212
 		{
@@ -215,17 +215,17 @@  discard block
 block discarded – undo
215 215
 		}
216 216
 
217 217
 		// Add odtgeneration hook
218
-		if (! is_object($hookmanager))
218
+		if (!is_object($hookmanager))
219 219
 		{
220 220
 			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
221
-			$hookmanager=new HookManager($this->db);
221
+			$hookmanager = new HookManager($this->db);
222 222
 		}
223 223
 		$hookmanager->initHooks(array('odtgeneration'));
224 224
 		global $action;
225 225
 
226
-		if (! is_object($outputlangs)) $outputlangs=$langs;
227
-		$sav_charset_output=$outputlangs->charset_output;
228
-		$outputlangs->charset_output='UTF-8';
226
+		if (!is_object($outputlangs)) $outputlangs = $langs;
227
+		$sav_charset_output = $outputlangs->charset_output;
228
+		$outputlangs->charset_output = 'UTF-8';
229 229
 
230 230
 		// Load traductions files requiredby by page
231 231
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
@@ -233,28 +233,28 @@  discard block
 block discarded – undo
233 233
 		if ($conf->expedition->dir_output."/sending")
234 234
 		{
235 235
 			// If $object is id instead of object
236
-			if (! is_object($object))
236
+			if (!is_object($object))
237 237
 			{
238 238
 				$id = $object;
239 239
 				$object = new Expedition($this->db);
240
-				$result=$object->fetch($id);
240
+				$result = $object->fetch($id);
241 241
 				if ($result < 0)
242 242
 				{
243
-					dol_print_error($this->db,$object->error);
243
+					dol_print_error($this->db, $object->error);
244 244
 					return -1;
245 245
 				}
246 246
 			}
247 247
 
248 248
 			$dir = $conf->expedition->dir_output."/sending";
249 249
 			$objectref = dol_sanitizeFileName($object->ref);
250
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
251
-			$file = $dir . "/" . $objectref . ".odt";
250
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
251
+			$file = $dir."/".$objectref.".odt";
252 252
 
253
-			if (! file_exists($dir))
253
+			if (!file_exists($dir))
254 254
 			{
255 255
 				if (dol_mkdir($dir) < 0)
256 256
 				{
257
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
257
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
258 258
 					return -1;
259 259
 				}
260 260
 			}
@@ -262,25 +262,25 @@  discard block
 block discarded – undo
262 262
 			if (file_exists($dir))
263 263
 			{
264 264
 				//print "srctemplatepath=".$srctemplatepath;	// Src filename
265
-				$newfile=basename($srctemplatepath);
266
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
267
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
268
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
269
-				$newfiletmp=$objectref.'_'.$newfiletmp;
265
+				$newfile = basename($srctemplatepath);
266
+				$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
267
+				$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
268
+				$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
269
+				$newfiletmp = $objectref.'_'.$newfiletmp;
270 270
 				//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
271 271
 				// Get extension (ods or odt)
272
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
273
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
272
+				$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
273
+				if (!empty($conf->global->MAIN_DOC_USE_TIMING))
274 274
 				{
275
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
276
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
277
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
275
+				    $format = $conf->global->MAIN_DOC_USE_TIMING;
276
+				    if ($format == '1') $format = '%Y%m%d%H%M%S';
277
+					$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
278 278
 				}
279 279
 				else
280 280
 				{
281
-					$filename=$newfiletmp.'.'.$newfileformat;
281
+					$filename = $newfiletmp.'.'.$newfileformat;
282 282
 				}
283
-				$file=$dir.'/'.$filename;
283
+				$file = $dir.'/'.$filename;
284 284
 				//print "newdir=".$dir;
285 285
 				//print "newfile=".$newfile;
286 286
 				//print "file=".$file;
@@ -290,19 +290,19 @@  discard block
 block discarded – undo
290 290
 
291 291
 
292 292
 				// If SHIPMENT contact defined on invoice, we use it
293
-				$usecontact=false;
294
-				$arrayidcontact=$object->getIdContact('external','SHIPPING');
293
+				$usecontact = false;
294
+				$arrayidcontact = $object->getIdContact('external', 'SHIPPING');
295 295
 				if (count($arrayidcontact) > 0)
296 296
 				{
297
-					$usecontact=true;
298
-					$result=$object->fetch_contact($arrayidcontact[0]);
297
+					$usecontact = true;
298
+					$result = $object->fetch_contact($arrayidcontact[0]);
299 299
 				}
300 300
 
301 301
 				// Recipient name
302 302
 				$contactobject = null;
303
-				if (! empty($usecontact)) {
303
+				if (!empty($usecontact)) {
304 304
 					// On peut utiliser le nom de la societe du contact
305
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))
305
+					if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))
306 306
 						$socobject = $object->contact;
307 307
 					else {
308 308
 						$socobject = $object->thirdparty;
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 				}
315 315
 
316 316
 				// Make substitution
317
-				$substitutionarray=array(
317
+				$substitutionarray = array(
318 318
 					'__FROM_NAME__' => $this->emetteur->name,
319 319
 					'__FROM_EMAIL__' => $this->emetteur->email,
320 320
 					'__TOTAL_TTC__' => $object->total_ttc,
@@ -323,15 +323,15 @@  discard block
 block discarded – undo
323 323
 				);
324 324
 				complete_substitutions_array($substitutionarray, $langs, $object);
325 325
 				// Call the ODTSubstitution hook
326
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
327
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
326
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray);
327
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
328 328
 
329 329
 				// Line of free text
330
-				$newfreetext='';
331
-				$paramfreetext='EXPEDITION_FREE_TEXT';
332
-				if (! empty($conf->global->$paramfreetext))
330
+				$newfreetext = '';
331
+				$paramfreetext = 'EXPEDITION_FREE_TEXT';
332
+				if (!empty($conf->global->$paramfreetext))
333 333
 				{
334
-					$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
334
+					$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
335 335
 				}
336 336
 
337 337
 				// Open and load template
@@ -341,15 +341,15 @@  discard block
 block discarded – undo
341 341
 						$srctemplatepath,
342 342
 						array(
343 343
 						'PATH_TO_TMP'	  => $conf->expedition->dir_temp,
344
-						'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
344
+						'ZIP_PROXY'		  => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
345 345
 						'DELIMITER_LEFT'  => '{',
346 346
 						'DELIMITER_RIGHT' => '}'
347 347
 						)
348 348
 					);
349 349
 				}
350
-				catch(Exception $e)
350
+				catch (Exception $e)
351 351
 				{
352
-					$this->error=$e->getMessage();
352
+					$this->error = $e->getMessage();
353 353
 					dol_syslog($e->getMessage(), LOG_INFO);
354 354
 					return -1;
355 355
 				}
@@ -364,18 +364,18 @@  discard block
 block discarded – undo
364 364
 				try {
365 365
 					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
366 366
 				}
367
-				catch(OdfException $e)
367
+				catch (OdfException $e)
368 368
 				{
369 369
 					dol_syslog($e->getMessage(), LOG_INFO);
370 370
 				}
371 371
 
372 372
 				// Make substitutions into odt of user info
373
-				$tmparray=$this->get_substitutionarray_user($user,$outputlangs);
373
+				$tmparray = $this->get_substitutionarray_user($user, $outputlangs);
374 374
 				//var_dump($tmparray); exit;
375
-				foreach($tmparray as $key=>$value)
375
+				foreach ($tmparray as $key=>$value)
376 376
 				{
377 377
 					try {
378
-						if (preg_match('/logo$/',$key)) // Image
378
+						if (preg_match('/logo$/', $key)) // Image
379 379
 						{
380 380
 							//var_dump($value);exit;
381 381
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
@@ -392,12 +392,12 @@  discard block
 block discarded – undo
392 392
 					}
393 393
 				}
394 394
 				// Make substitutions into odt of mysoc
395
-				$tmparray=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
395
+				$tmparray = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
396 396
 				//var_dump($tmparray); exit;
397
-				foreach($tmparray as $key=>$value)
397
+				foreach ($tmparray as $key=>$value)
398 398
 				{
399 399
 					try {
400
-						if (preg_match('/logo$/',$key))	// Image
400
+						if (preg_match('/logo$/', $key))	// Image
401 401
 						{
402 402
 							//var_dump($value);exit;
403 403
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
@@ -414,11 +414,11 @@  discard block
 block discarded – undo
414 414
 					}
415 415
 				}
416 416
 				// Make substitutions into odt of thirdparty
417
-				$tmparray=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
418
-				foreach($tmparray as $key=>$value)
417
+				$tmparray = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
418
+				foreach ($tmparray as $key=>$value)
419 419
 				{
420 420
 					try {
421
-						if (preg_match('/logo$/',$key))	// Image
421
+						if (preg_match('/logo$/', $key))	// Image
422 422
 						{
423 423
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
424 424
 							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
@@ -435,11 +435,11 @@  discard block
 block discarded – undo
435 435
 				}
436 436
 
437 437
 				if ($usecontact && is_object($contactobject)) {
438
-					$tmparray=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
439
-					foreach($tmparray as $key=>$value)
438
+					$tmparray = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
439
+					foreach ($tmparray as $key=>$value)
440 440
 					{
441 441
 						try {
442
-							if (preg_match('/logo$/',$key))	// Image
442
+							if (preg_match('/logo$/', $key))	// Image
443 443
 							{
444 444
 								if (file_exists($value)) $odfHandler->setImage($key, $value);
445 445
 								else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 								$odfHandler->setVars($key, $value, true, 'UTF-8');
450 450
 							}
451 451
 						}
452
-						catch(OdfException $e)
452
+						catch (OdfException $e)
453 453
 						{
454 454
                             dol_syslog($e->getMessage(), LOG_INFO);
455 455
 						}
@@ -457,15 +457,15 @@  discard block
 block discarded – undo
457 457
 				}
458 458
 
459 459
 				// Replace tags of object + external modules
460
-				$tmparray=$this->get_substitutionarray_shipment($object,$outputlangs);
460
+				$tmparray = $this->get_substitutionarray_shipment($object, $outputlangs);
461 461
 				complete_substitutions_array($tmparray, $outputlangs, $object);
462 462
 				// Call the ODTSubstitution hook
463
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
464
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
465
-				foreach($tmparray as $key=>$value)
463
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
464
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
465
+				foreach ($tmparray as $key=>$value)
466 466
 				{
467 467
 					try {
468
-						if (preg_match('/logo$/',$key)) // Image
468
+						if (preg_match('/logo$/', $key)) // Image
469 469
 						{
470 470
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
471 471
 							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
476 476
 						}
477 477
 					}
478
-					catch(OdfException $e)
478
+					catch (OdfException $e)
479 479
 					{
480 480
                         dol_syslog($e->getMessage(), LOG_INFO);
481 481
 					}
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 					try {
488 488
 						$listlines = $odfHandler->setSegment('lines');
489 489
 					}
490
-					catch(OdfException $e)
490
+					catch (OdfException $e)
491 491
 					{
492 492
 						// We may arrive here if tags for lines not present into template
493 493
 						$foundtagforlines = 0;
@@ -497,22 +497,22 @@  discard block
 block discarded – undo
497 497
 					{
498 498
 						foreach ($object->lines as $line)
499 499
 						{
500
-							$tmparray=$this->get_substitutionarray_shipment_lines($line,$outputlangs);
500
+							$tmparray = $this->get_substitutionarray_shipment_lines($line, $outputlangs);
501 501
 							complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
502 502
 							// Call the ODTSubstitutionLine hook
503
-							$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
504
-							$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
505
-							foreach($tmparray as $key => $val)
503
+							$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line);
504
+							$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
505
+							foreach ($tmparray as $key => $val)
506 506
 							{
507 507
 								try
508 508
 								{
509 509
 									$listlines->setVars($key, $val, true, 'UTF-8');
510 510
 								}
511
-								catch(OdfException $e)
511
+								catch (OdfException $e)
512 512
 								{
513 513
 									dol_syslog($e->getMessage(), LOG_INFO);
514 514
 								}
515
-								catch(SegmentException $e)
515
+								catch (SegmentException $e)
516 516
 								{
517 517
 									dol_syslog($e->getMessage(), LOG_INFO);
518 518
 								}
@@ -524,14 +524,14 @@  discard block
 block discarded – undo
524 524
 				}
525 525
 				catch (OdfException $e)
526 526
 				{
527
-					$this->error=$e->getMessage();
527
+					$this->error = $e->getMessage();
528 528
 					dol_syslog($this->error, LOG_WARNING);
529 529
 					return -1;
530 530
 				}
531 531
 
532 532
 				// Replace labels translated
533
-				$tmparray=$outputlangs->get_translations_for_substitutions();
534
-				foreach($tmparray as $key=>$value)
533
+				$tmparray = $outputlangs->get_translations_for_substitutions();
534
+				foreach ($tmparray as $key=>$value)
535 535
 				{
536 536
 					try {
537 537
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
@@ -543,15 +543,15 @@  discard block
 block discarded – undo
543 543
 				}
544 544
 
545 545
 				// Call the beforeODTSave hook
546
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
547
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
546
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
547
+				$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
548 548
 
549 549
 				// Write new file
550 550
 				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
551 551
 					try {
552 552
 						$odfHandler->exportAsAttachedPDF($file);
553 553
 					} catch (Exception $e) {
554
-						$this->error=$e->getMessage();
554
+						$this->error = $e->getMessage();
555 555
                         dol_syslog($e->getMessage(), LOG_INFO);
556 556
 						return -1;
557 557
 					}
@@ -560,26 +560,26 @@  discard block
 block discarded – undo
560 560
 					try {
561 561
 					$odfHandler->saveToDisk($file);
562 562
 					} catch (Exception $e) {
563
-						$this->error=$e->getMessage();
563
+						$this->error = $e->getMessage();
564 564
                         dol_syslog($e->getMessage(), LOG_INFO);
565 565
 						return -1;
566 566
 					}
567 567
 				}
568
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
569
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
568
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
569
+				$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
570 570
 
571
-				if (! empty($conf->global->MAIN_UMASK))
571
+				if (!empty($conf->global->MAIN_UMASK))
572 572
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
573 573
 
574
-				$odfHandler=null;	// Destroy object
574
+				$odfHandler = null; // Destroy object
575 575
 
576 576
 				$this->result = array('fullpath'=>$file);
577 577
 
578
-				return 1;   // Success
578
+				return 1; // Success
579 579
 			}
580 580
 			else
581 581
 			{
582
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
582
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
583 583
 				return -1;
584 584
 			}
585 585
 		}
Please login to merge, or discard this patch.
Braces   +70 added lines, -62 removed lines patch added patch discarded remove patch
@@ -99,7 +99,10 @@  discard block
 block discarded – undo
99 99
 
100 100
 		// Recupere emetteur
101 101
 		$this->emetteur=$mysoc;
102
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
102
+		if (! $this->emetteur->country_code) {
103
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
104
+		}
105
+		// By default if not defined
103 106
 	}
104 107
 
105 108
 
@@ -137,11 +140,14 @@  discard block
 block discarded – undo
137 140
 			if (! $tmpdir) {
138 141
 				unset($listofdir[$key]); continue;
139 142
 			}
140
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
141
-			else
143
+			if (! is_dir($tmpdir)) {
144
+			    $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
145
+			} else
142 146
 			{
143 147
 				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
144
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
148
+				if (count($tmpfiles)) {
149
+				    $listoffiles=array_merge($listoffiles,$tmpfiles);
150
+				}
145 151
 			}
146 152
 		}
147 153
 		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
@@ -223,7 +229,9 @@  discard block
 block discarded – undo
223 229
 		$hookmanager->initHooks(array('odtgeneration'));
224 230
 		global $action;
225 231
 
226
-		if (! is_object($outputlangs)) $outputlangs=$langs;
232
+		if (! is_object($outputlangs)) {
233
+		    $outputlangs=$langs;
234
+		}
227 235
 		$sav_charset_output=$outputlangs->charset_output;
228 236
 		$outputlangs->charset_output='UTF-8';
229 237
 
@@ -247,7 +255,9 @@  discard block
 block discarded – undo
247 255
 
248 256
 			$dir = $conf->expedition->dir_output."/sending";
249 257
 			$objectref = dol_sanitizeFileName($object->ref);
250
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
258
+			if (! preg_match('/specimen/i',$objectref)) {
259
+			    $dir.= "/" . $objectref;
260
+			}
251 261
 			$file = $dir . "/" . $objectref . ".odt";
252 262
 
253 263
 			if (! file_exists($dir))
@@ -273,10 +283,11 @@  discard block
 block discarded – undo
273 283
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
274 284
 				{
275 285
 				    $format=$conf->global->MAIN_DOC_USE_TIMING;
276
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
286
+				    if ($format == '1') {
287
+				        $format='%Y%m%d%H%M%S';
288
+				    }
277 289
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
278
-				}
279
-				else
290
+				} else
280 291
 				{
281 292
 					$filename=$newfiletmp.'.'.$newfileformat;
282 293
 				}
@@ -302,9 +313,9 @@  discard block
 block discarded – undo
302 313
 				$contactobject = null;
303 314
 				if (! empty($usecontact)) {
304 315
 					// On peut utiliser le nom de la societe du contact
305
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))
306
-						$socobject = $object->contact;
307
-					else {
316
+					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
317
+											$socobject = $object->contact;
318
+					} else {
308 319
 						$socobject = $object->thirdparty;
309 320
 						// if we have a SHIIPPING contact and we dont use it as recipient we store the contact object for later use
310 321
 						$contactobject = $object->contact;
@@ -346,8 +357,7 @@  discard block
 block discarded – undo
346 357
 						'DELIMITER_RIGHT' => '}'
347 358
 						)
348 359
 					);
349
-				}
350
-				catch(Exception $e)
360
+				} catch(Exception $e)
351 361
 				{
352 362
 					$this->error=$e->getMessage();
353 363
 					dol_syslog($e->getMessage(), LOG_INFO);
@@ -363,8 +373,7 @@  discard block
 block discarded – undo
363 373
 				// Make substitutions into odt of freetext
364 374
 				try {
365 375
 					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
366
-				}
367
-				catch(OdfException $e)
376
+				} catch(OdfException $e)
368 377
 				{
369 378
 					dol_syslog($e->getMessage(), LOG_INFO);
370 379
 				}
@@ -375,18 +384,19 @@  discard block
 block discarded – undo
375 384
 				foreach($tmparray as $key=>$value)
376 385
 				{
377 386
 					try {
378
-						if (preg_match('/logo$/',$key)) // Image
387
+						if (preg_match('/logo$/',$key)) {
388
+						    // Image
379 389
 						{
380 390
 							//var_dump($value);exit;
381 391
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
382
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
383
-						}
384
-						else    // Text
392
+						} else {
393
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
394
+							}
395
+						} else    // Text
385 396
 						{
386 397
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
387 398
 						}
388
-					}
389
-					catch (OdfException $e)
399
+					} catch (OdfException $e)
390 400
 					{
391 401
                         dol_syslog($e->getMessage(), LOG_INFO);
392 402
 					}
@@ -397,18 +407,19 @@  discard block
 block discarded – undo
397 407
 				foreach($tmparray as $key=>$value)
398 408
 				{
399 409
 					try {
400
-						if (preg_match('/logo$/',$key))	// Image
410
+						if (preg_match('/logo$/',$key)) {
411
+						    // Image
401 412
 						{
402 413
 							//var_dump($value);exit;
403 414
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
404
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
405
-						}
406
-						else	// Text
415
+						} else {
416
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
417
+							}
418
+						} else	// Text
407 419
 						{
408 420
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
409 421
 						}
410
-					}
411
-					catch (OdfException $e)
422
+					} catch (OdfException $e)
412 423
 					{
413 424
                         dol_syslog($e->getMessage(), LOG_INFO);
414 425
 					}
@@ -418,17 +429,18 @@  discard block
 block discarded – undo
418 429
 				foreach($tmparray as $key=>$value)
419 430
 				{
420 431
 					try {
421
-						if (preg_match('/logo$/',$key))	// Image
432
+						if (preg_match('/logo$/',$key)) {
433
+						    // Image
422 434
 						{
423 435
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
424
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
425
-						}
426
-						else	// Text
436
+						} else {
437
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
438
+							}
439
+						} else	// Text
427 440
 						{
428 441
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
429 442
 						}
430
-					}
431
-					catch (OdfException $e)
443
+					} catch (OdfException $e)
432 444
 					{
433 445
                         dol_syslog($e->getMessage(), LOG_INFO);
434 446
 					}
@@ -439,17 +451,18 @@  discard block
 block discarded – undo
439 451
 					foreach($tmparray as $key=>$value)
440 452
 					{
441 453
 						try {
442
-							if (preg_match('/logo$/',$key))	// Image
454
+							if (preg_match('/logo$/',$key)) {
455
+							    // Image
443 456
 							{
444 457
 								if (file_exists($value)) $odfHandler->setImage($key, $value);
445
-								else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
446
-							}
447
-							else	// Text
458
+							} else {
459
+								    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
460
+								}
461
+							} else	// Text
448 462
 							{
449 463
 								$odfHandler->setVars($key, $value, true, 'UTF-8');
450 464
 							}
451
-						}
452
-						catch(OdfException $e)
465
+						} catch(OdfException $e)
453 466
 						{
454 467
                             dol_syslog($e->getMessage(), LOG_INFO);
455 468
 						}
@@ -465,17 +478,18 @@  discard block
 block discarded – undo
465 478
 				foreach($tmparray as $key=>$value)
466 479
 				{
467 480
 					try {
468
-						if (preg_match('/logo$/',$key)) // Image
481
+						if (preg_match('/logo$/',$key)) {
482
+						    // Image
469 483
 						{
470 484
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
471
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
472
-						}
473
-						else    // Text
485
+						} else {
486
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
487
+							}
488
+						} else    // Text
474 489
 						{
475 490
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
476 491
 						}
477
-					}
478
-					catch(OdfException $e)
492
+					} catch(OdfException $e)
479 493
 					{
480 494
                         dol_syslog($e->getMessage(), LOG_INFO);
481 495
 					}
@@ -486,8 +500,7 @@  discard block
 block discarded – undo
486 500
 					$foundtagforlines = 1;
487 501
 					try {
488 502
 						$listlines = $odfHandler->setSegment('lines');
489
-					}
490
-					catch(OdfException $e)
503
+					} catch(OdfException $e)
491 504
 					{
492 505
 						// We may arrive here if tags for lines not present into template
493 506
 						$foundtagforlines = 0;
@@ -507,12 +520,10 @@  discard block
 block discarded – undo
507 520
 								try
508 521
 								{
509 522
 									$listlines->setVars($key, $val, true, 'UTF-8');
510
-								}
511
-								catch(OdfException $e)
523
+								} catch(OdfException $e)
512 524
 								{
513 525
 									dol_syslog($e->getMessage(), LOG_INFO);
514
-								}
515
-								catch(SegmentException $e)
526
+								} catch(SegmentException $e)
516 527
 								{
517 528
 									dol_syslog($e->getMessage(), LOG_INFO);
518 529
 								}
@@ -521,8 +532,7 @@  discard block
 block discarded – undo
521 532
 						}
522 533
 						$odfHandler->mergeSegment($listlines);
523 534
 					}
524
-				}
525
-				catch (OdfException $e)
535
+				} catch (OdfException $e)
526 536
 				{
527 537
 					$this->error=$e->getMessage();
528 538
 					dol_syslog($this->error, LOG_WARNING);
@@ -535,8 +545,7 @@  discard block
 block discarded – undo
535 545
 				{
536 546
 					try {
537 547
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
538
-					}
539
-					catch (OdfException $e)
548
+					} catch (OdfException $e)
540 549
 					{
541 550
                         dol_syslog($e->getMessage(), LOG_INFO);
542 551
 					}
@@ -555,8 +564,7 @@  discard block
 block discarded – undo
555 564
                         dol_syslog($e->getMessage(), LOG_INFO);
556 565
 						return -1;
557 566
 					}
558
-				}
559
-				else {
567
+				} else {
560 568
 					try {
561 569
 					$odfHandler->saveToDisk($file);
562 570
 					} catch (Exception $e) {
@@ -568,16 +576,16 @@  discard block
 block discarded – undo
568 576
 				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
569 577
 				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
570 578
 
571
-				if (! empty($conf->global->MAIN_UMASK))
572
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
579
+				if (! empty($conf->global->MAIN_UMASK)) {
580
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
581
+				}
573 582
 
574 583
 				$odfHandler=null;	// Destroy object
575 584
 
576 585
 				$this->result = array('fullpath'=>$file);
577 586
 
578 587
 				return 1;   // Success
579
-			}
580
-			else
588
+			} else
581 589
 			{
582 590
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
583 591
 				return -1;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/expedition/mod_expedition_ribera.php 2 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -29,125 +29,125 @@
 block discarded – undo
29 29
  */
30 30
 class mod_expedition_ribera extends ModelNumRefExpedition
31 31
 {
32
-	/**
32
+    /**
33 33
      * Dolibarr version of the loaded document
34 34
      * @public string
35 35
      */
36
-	public $version = 'dolibarr';
37
-
38
-	/**
39
-	 * @var string Error message
40
-	 */
41
-	public $error = '';
42
-
43
-	/**
44
-	 * @var string Nom du modele
45
-	 * @deprecated
46
-	 * @see name
47
-	 */
48
-	public $nom='Ribera';
49
-
50
-	/**
51
-	 * @var string model name
52
-	 */
53
-	public $name='Ribera';
54
-
55
-	/**
56
-	 *	Return default description of numbering model
57
-	 *
58
-	 *	@return     string      text description
59
-	 */
60
-	function info()
36
+    public $version = 'dolibarr';
37
+
38
+    /**
39
+     * @var string Error message
40
+     */
41
+    public $error = '';
42
+
43
+    /**
44
+     * @var string Nom du modele
45
+     * @deprecated
46
+     * @see name
47
+     */
48
+    public $nom='Ribera';
49
+
50
+    /**
51
+     * @var string model name
52
+     */
53
+    public $name='Ribera';
54
+
55
+    /**
56
+     *	Return default description of numbering model
57
+     *
58
+     *	@return     string      text description
59
+     */
60
+    function info()
61 61
     {
62
-    	global $conf, $langs;
62
+        global $conf, $langs;
63 63
 
64
-		$langs->load("bills");
64
+        $langs->load("bills");
65 65
 
66
-		$form = new Form($this->db);
66
+        $form = new Form($this->db);
67 67
 
68
-		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
69
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
70
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
71
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
72
-		$texte.= '<input type="hidden" name="maskconstexpedition" value="EXPEDITION_RIBERA_MASK">';
73
-		$texte.= '<table class="nobordernopadding" width="100%">';
68
+        $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
69
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
70
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
71
+        $texte.= '<input type="hidden" name="action" value="updateMask">';
72
+        $texte.= '<input type="hidden" name="maskconstexpedition" value="EXPEDITION_RIBERA_MASK">';
73
+        $texte.= '<table class="nobordernopadding" width="100%">';
74 74
 
75
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Shipment"),$langs->transnoentities("Shipment"));
76
-		$tooltip.=$langs->trans("GenericMaskCodes2");
77
-		$tooltip.=$langs->trans("GenericMaskCodes3");
78
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Shipment"),$langs->transnoentities("Shipment"));
79
-		$tooltip.=$langs->trans("GenericMaskCodes5");
75
+        $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Shipment"),$langs->transnoentities("Shipment"));
76
+        $tooltip.=$langs->trans("GenericMaskCodes2");
77
+        $tooltip.=$langs->trans("GenericMaskCodes3");
78
+        $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Shipment"),$langs->transnoentities("Shipment"));
79
+        $tooltip.=$langs->trans("GenericMaskCodes5");
80 80
 
81
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
82
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskexpedition" value="'.$conf->global->EXPEDITION_RIBERA_MASK.'">',$tooltip,1,1).'</td>';
83
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
84
-		$texte.= '</tr>';
85
-		$texte.= '</table>';
86
-		$texte.= '</form>';
81
+        $texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
82
+        $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskexpedition" value="'.$conf->global->EXPEDITION_RIBERA_MASK.'">',$tooltip,1,1).'</td>';
83
+        $texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
84
+        $texte.= '</tr>';
85
+        $texte.= '</table>';
86
+        $texte.= '</form>';
87 87
 
88
-		return $texte;
88
+        return $texte;
89 89
     }
90 90
 
91
-	/**
92
-	 *	Return numbering example
93
-	 *
94
-	 *	@return     string      Example
95
-	 */
91
+    /**
92
+     *	Return numbering example
93
+     *
94
+     *	@return     string      Example
95
+     */
96 96
     function getExample()
97 97
     {
98
-     	global $conf,$langs,$mysoc;
99
-
100
-    	$old_code_client=$mysoc->code_client;
101
-    	$old_code_type=$mysoc->typent_code;
102
-    	$mysoc->code_client='CCCCCCCCCC';
103
-    	$mysoc->typent_code='TTTTTTTTTT';
104
-     	$numExample = $this->getNextValue($mysoc,'');
105
-		$mysoc->code_client=$old_code_client;
106
-		$mysoc->typent_code=$old_code_type;
107
-
108
-		if (! $numExample)
109
-		{
110
-			$numExample = $langs->trans('NotConfigured');
111
-		}
112
-		return $numExample;
98
+            global $conf,$langs,$mysoc;
99
+
100
+        $old_code_client=$mysoc->code_client;
101
+        $old_code_type=$mysoc->typent_code;
102
+        $mysoc->code_client='CCCCCCCCCC';
103
+        $mysoc->typent_code='TTTTTTTTTT';
104
+            $numExample = $this->getNextValue($mysoc,'');
105
+        $mysoc->code_client=$old_code_client;
106
+        $mysoc->typent_code=$old_code_type;
107
+
108
+        if (! $numExample)
109
+        {
110
+            $numExample = $langs->trans('NotConfigured');
111
+        }
112
+        return $numExample;
113 113
     }
114 114
 
115
-	/**
116
-	 *	Return next value
117
-	 *
118
-	 *	@param	Societe		$objsoc     Third party object
119
-	 *	@param	Object		$shipment	Shipment object
120
-	 *	@return string      			Value if OK, 0 if KO
121
-	 */
115
+    /**
116
+     *	Return next value
117
+     *
118
+     *	@param	Societe		$objsoc     Third party object
119
+     *	@param	Object		$shipment	Shipment object
120
+     *	@return string      			Value if OK, 0 if KO
121
+     */
122 122
     function getNextValue($objsoc,$shipment)
123 123
     {
124
-		global $db,$conf;
124
+        global $db,$conf;
125 125
 
126
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
126
+        require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
127 127
 
128
-		$mask=$conf->global->EXPEDITION_RIBERA_MASK;
128
+        $mask=$conf->global->EXPEDITION_RIBERA_MASK;
129 129
 
130
-		if (! $mask)
131
-		{
132
-			$this->error='NotConfigured';
133
-			return 0;
134
-		}
130
+        if (! $mask)
131
+        {
132
+            $this->error='NotConfigured';
133
+            return 0;
134
+        }
135 135
 
136
-		$date = $shipment->date_expedition;
136
+        $date = $shipment->date_expedition;
137 137
 
138
-		$numFinal=get_next_value($db,$mask,'expedition','ref','',$objsoc,$date);
138
+        $numFinal=get_next_value($db,$mask,'expedition','ref','',$objsoc,$date);
139 139
 
140
-		return  $numFinal;
141
-	}
140
+        return  $numFinal;
141
+    }
142 142
 
143 143
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
144
-	/**
145
-	 *  Return next free value
146
-	 *
147
-	 *	@param	Societe		$objsoc     Third party object
148
-	 *	@param	Object		$objforref	Shipment object
149
-	 *	@return string      			Next free value
150
-	 */
144
+    /**
145
+     *  Return next free value
146
+     *
147
+     *	@param	Societe		$objsoc     Third party object
148
+     *	@param	Object		$objforref	Shipment object
149
+     *	@return string      			Next free value
150
+     */
151 151
     function expedition_get_num($objsoc,$objforref)
152 152
     {
153 153
         // phpcs:enable
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *  \brief      File of class to manage expedition numbering rules Ribera
23 23
  */
24 24
 
25
-require_once DOL_DOCUMENT_ROOT .'/core/modules/expedition/modules_expedition.php';
25
+require_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php';
26 26
 
27 27
 /**
28 28
  *	Class to manage expedition numbering rules Ribera
@@ -45,12 +45,12 @@  discard block
 block discarded – undo
45 45
 	 * @deprecated
46 46
 	 * @see name
47 47
 	 */
48
-	public $nom='Ribera';
48
+	public $nom = 'Ribera';
49 49
 
50 50
 	/**
51 51
 	 * @var string model name
52 52
 	 */
53
-	public $name='Ribera';
53
+	public $name = 'Ribera';
54 54
 
55 55
 	/**
56 56
 	 *	Return default description of numbering model
@@ -66,24 +66,24 @@  discard block
 block discarded – undo
66 66
 		$form = new Form($this->db);
67 67
 
68 68
 		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
69
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
70
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
71
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
72
-		$texte.= '<input type="hidden" name="maskconstexpedition" value="EXPEDITION_RIBERA_MASK">';
73
-		$texte.= '<table class="nobordernopadding" width="100%">';
74
-
75
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Shipment"),$langs->transnoentities("Shipment"));
76
-		$tooltip.=$langs->trans("GenericMaskCodes2");
77
-		$tooltip.=$langs->trans("GenericMaskCodes3");
78
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Shipment"),$langs->transnoentities("Shipment"));
79
-		$tooltip.=$langs->trans("GenericMaskCodes5");
80
-
81
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
82
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskexpedition" value="'.$conf->global->EXPEDITION_RIBERA_MASK.'">',$tooltip,1,1).'</td>';
83
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
84
-		$texte.= '</tr>';
85
-		$texte.= '</table>';
86
-		$texte.= '</form>';
69
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
70
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
71
+		$texte .= '<input type="hidden" name="action" value="updateMask">';
72
+		$texte .= '<input type="hidden" name="maskconstexpedition" value="EXPEDITION_RIBERA_MASK">';
73
+		$texte .= '<table class="nobordernopadding" width="100%">';
74
+
75
+		$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Shipment"), $langs->transnoentities("Shipment"));
76
+		$tooltip .= $langs->trans("GenericMaskCodes2");
77
+		$tooltip .= $langs->trans("GenericMaskCodes3");
78
+		$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Shipment"), $langs->transnoentities("Shipment"));
79
+		$tooltip .= $langs->trans("GenericMaskCodes5");
80
+
81
+		$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
82
+		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskexpedition" value="'.$conf->global->EXPEDITION_RIBERA_MASK.'">', $tooltip, 1, 1).'</td>';
83
+		$texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
84
+		$texte .= '</tr>';
85
+		$texte .= '</table>';
86
+		$texte .= '</form>';
87 87
 
88 88
 		return $texte;
89 89
     }
@@ -95,17 +95,17 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
     function getExample()
97 97
     {
98
-     	global $conf,$langs,$mysoc;
98
+     	global $conf, $langs, $mysoc;
99 99
 
100
-    	$old_code_client=$mysoc->code_client;
101
-    	$old_code_type=$mysoc->typent_code;
102
-    	$mysoc->code_client='CCCCCCCCCC';
103
-    	$mysoc->typent_code='TTTTTTTTTT';
104
-     	$numExample = $this->getNextValue($mysoc,'');
105
-		$mysoc->code_client=$old_code_client;
106
-		$mysoc->typent_code=$old_code_type;
100
+    	$old_code_client = $mysoc->code_client;
101
+    	$old_code_type = $mysoc->typent_code;
102
+    	$mysoc->code_client = 'CCCCCCCCCC';
103
+    	$mysoc->typent_code = 'TTTTTTTTTT';
104
+     	$numExample = $this->getNextValue($mysoc, '');
105
+		$mysoc->code_client = $old_code_client;
106
+		$mysoc->typent_code = $old_code_type;
107 107
 
108
-		if (! $numExample)
108
+		if (!$numExample)
109 109
 		{
110 110
 			$numExample = $langs->trans('NotConfigured');
111 111
 		}
@@ -119,23 +119,23 @@  discard block
 block discarded – undo
119 119
 	 *	@param	Object		$shipment	Shipment object
120 120
 	 *	@return string      			Value if OK, 0 if KO
121 121
 	 */
122
-    function getNextValue($objsoc,$shipment)
122
+    function getNextValue($objsoc, $shipment)
123 123
     {
124
-		global $db,$conf;
124
+		global $db, $conf;
125 125
 
126
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
126
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
127 127
 
128
-		$mask=$conf->global->EXPEDITION_RIBERA_MASK;
128
+		$mask = $conf->global->EXPEDITION_RIBERA_MASK;
129 129
 
130
-		if (! $mask)
130
+		if (!$mask)
131 131
 		{
132
-			$this->error='NotConfigured';
132
+			$this->error = 'NotConfigured';
133 133
 			return 0;
134 134
 		}
135 135
 
136 136
 		$date = $shipment->date_expedition;
137 137
 
138
-		$numFinal=get_next_value($db,$mask,'expedition','ref','',$objsoc,$date);
138
+		$numFinal = get_next_value($db, $mask, 'expedition', 'ref', '', $objsoc, $date);
139 139
 
140 140
 		return  $numFinal;
141 141
 	}
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
 	 *	@param	Object		$objforref	Shipment object
149 149
 	 *	@return string      			Next free value
150 150
 	 */
151
-    function expedition_get_num($objsoc,$objforref)
151
+    function expedition_get_num($objsoc, $objforref)
152 152
     {
153 153
         // phpcs:enable
154
-        return $this->getNextValue($objsoc,$objforref);
154
+        return $this->getNextValue($objsoc, $objforref);
155 155
     }
156 156
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/expedition/mod_expedition_safor.php 3 patches
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -28,139 +28,139 @@
 block discarded – undo
28 28
  */
29 29
 class mod_expedition_safor extends ModelNumRefExpedition
30 30
 {
31
-	/**
31
+    /**
32 32
      * Dolibarr version of the loaded document
33 33
      * @public string
34 34
      */
35
-	public $version = 'dolibarr';
35
+    public $version = 'dolibarr';
36 36
 
37
-	public $prefix='SH';
37
+    public $prefix='SH';
38 38
 
39
-	/**
40
-	 * @var string Error code (or message)
41
-	 */
42
-	public $error='';
39
+    /**
40
+     * @var string Error code (or message)
41
+     */
42
+    public $error='';
43 43
 
44
-	/**
45
-	 * @var string Nom du modele
46
-	 * @deprecated
47
-	 * @see name
48
-	 */
49
-	public $nom='Safor';
44
+    /**
45
+     * @var string Nom du modele
46
+     * @deprecated
47
+     * @see name
48
+     */
49
+    public $nom='Safor';
50 50
 
51
-	/**
52
-	 * @var string model name
53
-	 */
54
-	public $name='Safor';
51
+    /**
52
+     * @var string model name
53
+     */
54
+    public $name='Safor';
55 55
 
56 56
 
57
-	/**
58
-	 *	Return default description of numbering model
59
-	 *
60
-	 *	@return     string      text description
61
-	 */
57
+    /**
58
+     *	Return default description of numbering model
59
+     *
60
+     *	@return     string      text description
61
+     */
62 62
     function info()
63 63
     {
64
-    	global $langs;
65
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
64
+        global $langs;
65
+            return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
66 66
     }
67 67
 
68 68
 
69
-	/**
70
-	 *	Return numbering example
71
-	 *
72
-	 *	@return     string      Example
73
-	 */
74
-	function getExample()
75
-	{
76
-		return $this->prefix."0501-0001";
77
-	}
78
-
79
-
80
-	/**
81
-	 *	Test if existing numbers make problems with numbering
82
-	 *
83
-	 *	@return     boolean     false if conflit, true if ok
84
-	 */
85
-	function canBeActivated()
86
-	{
87
-		global $conf,$langs,$db;
88
-
89
-		$coyymm=''; $max='';
90
-
91
-		$posindice=8;
92
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
93
-		$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
94
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
95
-		$sql.= " AND entity = ".$conf->entity;
96
-
97
-		$resql=$db->query($sql);
98
-		if ($resql)
99
-		{
100
-			$row = $db->fetch_row($resql);
101
-			if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; }
102
-		}
103
-		if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
104
-		{
105
-			$langs->load("errors");
106
-			$this->error=$langs->trans('ErrorNumRefModel', $max);
107
-			return false;
108
-		}
109
-
110
-		return true;
111
-	}
112
-
113
-	/**
114
-	 *	Return next value
115
-	 *
116
-	 *	@param	Societe		$objsoc     Third party object
117
-	 *	@param	Object		$shipment	Shipment object
118
-	 *	@return string      			Value if OK, 0 if KO
119
-	 */
120
-	function getNextValue($objsoc,$shipment)
121
-	{
122
-		global $db,$conf;
123
-
124
-		$posindice=8;
125
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
126
-		$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
127
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
128
-		$sql.= " AND entity = ".$conf->entity;
129
-
130
-		$resql=$db->query($sql);
131
-		if ($resql)
132
-		{
133
-			$obj = $db->fetch_object($resql);
134
-			if ($obj) $max = intval($obj->max);
135
-			else $max=0;
136
-		}
137
-		else
138
-		{
139
-			dol_syslog("mod_expedition_safor::getNextValue", LOG_DEBUG);
140
-			return -1;
141
-		}
142
-
143
-		$date=time();
144
-		$yymm = strftime("%y%m",$date);
145
-
146
-		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
147
-		else $num = sprintf("%04s",$max+1);
148
-
149
-		dol_syslog("mod_expedition_safor::getNextValue return ".$this->prefix.$yymm."-".$num);
150
-		return $this->prefix.$yymm."-".$num;
151
-	}
69
+    /**
70
+     *	Return numbering example
71
+     *
72
+     *	@return     string      Example
73
+     */
74
+    function getExample()
75
+    {
76
+        return $this->prefix."0501-0001";
77
+    }
78
+
79
+
80
+    /**
81
+     *	Test if existing numbers make problems with numbering
82
+     *
83
+     *	@return     boolean     false if conflit, true if ok
84
+     */
85
+    function canBeActivated()
86
+    {
87
+        global $conf,$langs,$db;
88
+
89
+        $coyymm=''; $max='';
90
+
91
+        $posindice=8;
92
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
93
+        $sql.= " FROM ".MAIN_DB_PREFIX."expedition";
94
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
95
+        $sql.= " AND entity = ".$conf->entity;
96
+
97
+        $resql=$db->query($sql);
98
+        if ($resql)
99
+        {
100
+            $row = $db->fetch_row($resql);
101
+            if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; }
102
+        }
103
+        if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
104
+        {
105
+            $langs->load("errors");
106
+            $this->error=$langs->trans('ErrorNumRefModel', $max);
107
+            return false;
108
+        }
109
+
110
+        return true;
111
+    }
112
+
113
+    /**
114
+     *	Return next value
115
+     *
116
+     *	@param	Societe		$objsoc     Third party object
117
+     *	@param	Object		$shipment	Shipment object
118
+     *	@return string      			Value if OK, 0 if KO
119
+     */
120
+    function getNextValue($objsoc,$shipment)
121
+    {
122
+        global $db,$conf;
123
+
124
+        $posindice=8;
125
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
126
+        $sql.= " FROM ".MAIN_DB_PREFIX."expedition";
127
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
128
+        $sql.= " AND entity = ".$conf->entity;
129
+
130
+        $resql=$db->query($sql);
131
+        if ($resql)
132
+        {
133
+            $obj = $db->fetch_object($resql);
134
+            if ($obj) $max = intval($obj->max);
135
+            else $max=0;
136
+        }
137
+        else
138
+        {
139
+            dol_syslog("mod_expedition_safor::getNextValue", LOG_DEBUG);
140
+            return -1;
141
+        }
142
+
143
+        $date=time();
144
+        $yymm = strftime("%y%m",$date);
145
+
146
+        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
147
+        else $num = sprintf("%04s",$max+1);
148
+
149
+        dol_syslog("mod_expedition_safor::getNextValue return ".$this->prefix.$yymm."-".$num);
150
+        return $this->prefix.$yymm."-".$num;
151
+    }
152 152
 
153 153
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
154
-	/**
155
-	 *  Return next free value
156
-	 *
157
-	 *	@param	Societe		$objsoc     Third party object
158
-	 *	@param	Object		$objforref	Shipment object
159
-	 *	@return string      			Next free value
160
-	 */
161
-	function expedition_get_num($objsoc,$objforref)
162
-	{
154
+    /**
155
+     *  Return next free value
156
+     *
157
+     *	@param	Societe		$objsoc     Third party object
158
+     *	@param	Object		$objforref	Shipment object
159
+     *	@return string      			Next free value
160
+     */
161
+    function expedition_get_num($objsoc,$objforref)
162
+    {
163 163
         // phpcs:enable
164
-		return $this->getNextValue($objsoc,$objforref);
165
-	}
164
+        return $this->getNextValue($objsoc,$objforref);
165
+    }
166 166
 }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  *  \ingroup    expedition
22 22
  *  \brief      File of class to manage shipments numbering rules Safor
23 23
  */
24
-require_once DOL_DOCUMENT_ROOT .'/core/modules/expedition/modules_expedition.php';
24
+require_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php';
25 25
 
26 26
 /**
27 27
  *	Class to manage expedition numbering rules Safor
@@ -34,24 +34,24 @@  discard block
 block discarded – undo
34 34
      */
35 35
 	public $version = 'dolibarr';
36 36
 
37
-	public $prefix='SH';
37
+	public $prefix = 'SH';
38 38
 
39 39
 	/**
40 40
 	 * @var string Error code (or message)
41 41
 	 */
42
-	public $error='';
42
+	public $error = '';
43 43
 
44 44
 	/**
45 45
 	 * @var string Nom du modele
46 46
 	 * @deprecated
47 47
 	 * @see name
48 48
 	 */
49
-	public $nom='Safor';
49
+	public $nom = 'Safor';
50 50
 
51 51
 	/**
52 52
 	 * @var string model name
53 53
 	 */
54
-	public $name='Safor';
54
+	public $name = 'Safor';
55 55
 
56 56
 
57 57
 	/**
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     function info()
63 63
     {
64 64
     	global $langs;
65
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
65
+      	return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
66 66
     }
67 67
 
68 68
 
@@ -84,26 +84,26 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	function canBeActivated()
86 86
 	{
87
-		global $conf,$langs,$db;
87
+		global $conf, $langs, $db;
88 88
 
89
-		$coyymm=''; $max='';
89
+		$coyymm = ''; $max = '';
90 90
 
91
-		$posindice=8;
91
+		$posindice = 8;
92 92
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
93
-		$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
94
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
95
-		$sql.= " AND entity = ".$conf->entity;
93
+		$sql .= " FROM ".MAIN_DB_PREFIX."expedition";
94
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
95
+		$sql .= " AND entity = ".$conf->entity;
96 96
 
97
-		$resql=$db->query($sql);
97
+		$resql = $db->query($sql);
98 98
 		if ($resql)
99 99
 		{
100 100
 			$row = $db->fetch_row($resql);
101
-			if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; }
101
+			if ($row) { $coyymm = substr($row[0], 0, 6); $max = $row[0]; }
102 102
 		}
103
-		if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
103
+		if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
104 104
 		{
105 105
 			$langs->load("errors");
106
-			$this->error=$langs->trans('ErrorNumRefModel', $max);
106
+			$this->error = $langs->trans('ErrorNumRefModel', $max);
107 107
 			return false;
108 108
 		}
109 109
 
@@ -117,22 +117,22 @@  discard block
 block discarded – undo
117 117
 	 *	@param	Object		$shipment	Shipment object
118 118
 	 *	@return string      			Value if OK, 0 if KO
119 119
 	 */
120
-	function getNextValue($objsoc,$shipment)
120
+	function getNextValue($objsoc, $shipment)
121 121
 	{
122
-		global $db,$conf;
122
+		global $db, $conf;
123 123
 
124
-		$posindice=8;
124
+		$posindice = 8;
125 125
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
126
-		$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
127
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
128
-		$sql.= " AND entity = ".$conf->entity;
126
+		$sql .= " FROM ".MAIN_DB_PREFIX."expedition";
127
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
128
+		$sql .= " AND entity = ".$conf->entity;
129 129
 
130
-		$resql=$db->query($sql);
130
+		$resql = $db->query($sql);
131 131
 		if ($resql)
132 132
 		{
133 133
 			$obj = $db->fetch_object($resql);
134 134
 			if ($obj) $max = intval($obj->max);
135
-			else $max=0;
135
+			else $max = 0;
136 136
 		}
137 137
 		else
138 138
 		{
@@ -140,11 +140,11 @@  discard block
 block discarded – undo
140 140
 			return -1;
141 141
 		}
142 142
 
143
-		$date=time();
144
-		$yymm = strftime("%y%m",$date);
143
+		$date = time();
144
+		$yymm = strftime("%y%m", $date);
145 145
 
146
-		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
147
-		else $num = sprintf("%04s",$max+1);
146
+		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
147
+		else $num = sprintf("%04s", $max + 1);
148 148
 
149 149
 		dol_syslog("mod_expedition_safor::getNextValue return ".$this->prefix.$yymm."-".$num);
150 150
 		return $this->prefix.$yymm."-".$num;
@@ -158,9 +158,9 @@  discard block
 block discarded – undo
158 158
 	 *	@param	Object		$objforref	Shipment object
159 159
 	 *	@return string      			Next free value
160 160
 	 */
161
-	function expedition_get_num($objsoc,$objforref)
161
+	function expedition_get_num($objsoc, $objforref)
162 162
 	{
163 163
         // phpcs:enable
164
-		return $this->getNextValue($objsoc,$objforref);
164
+		return $this->getNextValue($objsoc, $objforref);
165 165
 	}
166 166
 }
Please login to merge, or discard this patch.
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -131,10 +131,12 @@  discard block
 block discarded – undo
131 131
 		if ($resql)
132 132
 		{
133 133
 			$obj = $db->fetch_object($resql);
134
-			if ($obj) $max = intval($obj->max);
135
-			else $max=0;
136
-		}
137
-		else
134
+			if ($obj) {
135
+			    $max = intval($obj->max);
136
+			} else {
137
+			    $max=0;
138
+			}
139
+		} else
138 140
 		{
139 141
 			dol_syslog("mod_expedition_safor::getNextValue", LOG_DEBUG);
140 142
 			return -1;
@@ -143,8 +145,13 @@  discard block
 block discarded – undo
143 145
 		$date=time();
144 146
 		$yymm = strftime("%y%m",$date);
145 147
 
146
-		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
147
-		else $num = sprintf("%04s",$max+1);
148
+		if ($max >= (pow(10, 4) - 1)) {
149
+		    $num=$max+1;
150
+		}
151
+		// If counter > 9999, we do not format on 4 chars, we take number as it is
152
+		else {
153
+		    $num = sprintf("%04s",$max+1);
154
+		}
148 155
 
149 156
 		dol_syslog("mod_expedition_safor::getNextValue return ".$this->prefix.$yymm."-".$num);
150 157
 		return $this->prefix.$yymm."-".$num;
Please login to merge, or discard this patch.