@@ -24,14 +24,14 @@ |
||
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 |
@@ -21,13 +21,13 @@ discard block |
||
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 |
||
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 | }); |
@@ -27,19 +27,19 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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')?'§ion_dir='.urlencode(GETPOST('section_dir','alpha')):'').(!empty($withproject)?'&withproject=1':'')); |
|
153 | + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(GETPOST('section_dir', 'alpha') ? '§ion_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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | { |
@@ -24,7 +24,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -115,56 +115,56 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -116,29 +116,29 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -69,37 +69,37 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -22,7 +22,7 @@ discard block |
||
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 |
||
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 |
||
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"> <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"> <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 |
||
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 |
||
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 |
||
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 | } |
@@ -21,7 +21,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |