@@ -74,24 +74,24 @@ discard block |
||
74 | 74 | */ |
75 | 75 | function dol_getImageSize($file, $url = false) |
76 | 76 | { |
77 | - $ret=array(); |
|
77 | + $ret=array(); |
|
78 | 78 | |
79 | - if (image_format_supported($file) < 0) return $ret; |
|
79 | + if (image_format_supported($file) < 0) return $ret; |
|
80 | 80 | |
81 | - $filetoread = $file; |
|
82 | - if (!$url) |
|
83 | - { |
|
84 | - $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
85 | - } |
|
81 | + $filetoread = $file; |
|
82 | + if (!$url) |
|
83 | + { |
|
84 | + $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
85 | + } |
|
86 | 86 | |
87 | - if ($filetoread) |
|
88 | - { |
|
89 | - $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image |
|
90 | - $ret['width']=$infoImg[0]; // Largeur de l'image |
|
91 | - $ret['height']=$infoImg[1]; // Hauteur de l'image |
|
92 | - } |
|
87 | + if ($filetoread) |
|
88 | + { |
|
89 | + $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image |
|
90 | + $ret['width']=$infoImg[0]; // Largeur de l'image |
|
91 | + $ret['height']=$infoImg[1]; // Hauteur de l'image |
|
92 | + } |
|
93 | 93 | |
94 | - return $ret; |
|
94 | + return $ret; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | |
@@ -108,191 +108,191 @@ discard block |
||
108 | 108 | */ |
109 | 109 | function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $src_y=0) |
110 | 110 | { |
111 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
112 | - |
|
113 | - global $conf,$langs; |
|
114 | - |
|
115 | - dol_syslog("dol_imageResizeOrCrop file=".$file." mode=".$mode." newWidth=".$newWidth." newHeight=".$newHeight." src_x=".$src_x." src_y=".$src_y); |
|
116 | - |
|
117 | - // Clean parameters |
|
118 | - $file=trim($file); |
|
119 | - |
|
120 | - // Check parameters |
|
121 | - if (! $file) |
|
122 | - { |
|
123 | - // Si le fichier n'a pas ete indique |
|
124 | - return 'Bad parameter file'; |
|
125 | - } |
|
126 | - elseif (! file_exists($file)) |
|
127 | - { |
|
128 | - // Si le fichier passe en parametre n'existe pas |
|
129 | - return $langs->trans("ErrorFileNotFound",$file); |
|
130 | - } |
|
131 | - elseif(image_format_supported($file) < 0) |
|
132 | - { |
|
133 | - return 'This filename '.$file.' does not seem to be an image filename.'; |
|
134 | - } |
|
135 | - elseif(!is_numeric($newWidth) && !is_numeric($newHeight)) |
|
136 | - { |
|
137 | - return 'Wrong value for parameter newWidth or newHeight'; |
|
138 | - } |
|
139 | - elseif ($mode == 0 && $newWidth <= 0 && $newHeight <= 0) |
|
140 | - { |
|
141 | - return 'At least newHeight or newWidth must be defined for resizing'; |
|
142 | - } |
|
143 | - elseif ($mode == 1 && ($newWidth <= 0 || $newHeight <= 0)) |
|
144 | - { |
|
145 | - return 'Both newHeight or newWidth must be defined for croping'; |
|
146 | - } |
|
147 | - |
|
148 | - $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
149 | - |
|
150 | - $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image |
|
151 | - $imgWidth = $infoImg[0]; // Largeur de l'image |
|
152 | - $imgHeight = $infoImg[1]; // Hauteur de l'image |
|
153 | - |
|
154 | - if ($mode == 0) // If resize, we check parameters |
|
155 | - { |
|
156 | - if ($newWidth <= 0) |
|
157 | - { |
|
158 | - $newWidth=intval(($newHeight / $imgHeight) * $imgWidth); // Keep ratio |
|
159 | - } |
|
160 | - if ($newHeight <= 0) |
|
161 | - { |
|
162 | - $newHeight=intval(($newWidth / $imgWidth) * $imgHeight); // Keep ratio |
|
163 | - } |
|
164 | - } |
|
165 | - |
|
166 | - $imgfonction=''; |
|
167 | - switch($infoImg[2]) |
|
168 | - { |
|
169 | - case 1: // IMG_GIF |
|
170 | - $imgfonction = 'imagecreatefromgif'; |
|
171 | - break; |
|
172 | - case 2: // IMG_JPG |
|
173 | - $imgfonction = 'imagecreatefromjpeg'; |
|
174 | - break; |
|
175 | - case 3: // IMG_PNG |
|
176 | - $imgfonction = 'imagecreatefrompng'; |
|
177 | - break; |
|
178 | - case 4: // IMG_WBMP |
|
179 | - $imgfonction = 'imagecreatefromwbmp'; |
|
180 | - break; |
|
181 | - } |
|
182 | - if ($imgfonction) |
|
183 | - { |
|
184 | - if (! function_exists($imgfonction)) |
|
185 | - { |
|
186 | - // Fonctions de conversion non presente dans ce PHP |
|
187 | - return 'Resize not possible. This PHP does not support GD functions '.$imgfonction; |
|
188 | - } |
|
189 | - } |
|
190 | - |
|
191 | - // Initialisation des variables selon l'extension de l'image |
|
192 | - switch($infoImg[2]) |
|
193 | - { |
|
194 | - case 1: // Gif |
|
195 | - $img = imagecreatefromgif($filetoread); |
|
196 | - $extImg = '.gif'; // File name extension of image |
|
197 | - $newquality='NU'; // Quality is not used for this format |
|
198 | - break; |
|
199 | - case 2: // Jpg |
|
200 | - $img = imagecreatefromjpeg($filetoread); |
|
201 | - $extImg = '.jpg'; |
|
202 | - $newquality=100; // % quality maximum |
|
203 | - break; |
|
204 | - case 3: // Png |
|
205 | - $img = imagecreatefrompng($filetoread); |
|
206 | - $extImg = '.png'; |
|
207 | - $newquality=0; // No compression (0-9) |
|
208 | - break; |
|
209 | - case 4: // Bmp |
|
210 | - $img = imagecreatefromwbmp($filetoread); |
|
211 | - $extImg = '.bmp'; |
|
212 | - $newquality='NU'; // Quality is not used for this format |
|
213 | - break; |
|
214 | - } |
|
215 | - |
|
216 | - // Create empty image |
|
217 | - if ($infoImg[2] == 1) |
|
218 | - { |
|
219 | - // Compatibilite image GIF |
|
220 | - $imgThumb = imagecreate($newWidth, $newHeight); |
|
221 | - } |
|
222 | - else |
|
223 | - { |
|
224 | - $imgThumb = imagecreatetruecolor($newWidth, $newHeight); |
|
225 | - } |
|
226 | - |
|
227 | - // Activate antialiasing for better quality |
|
228 | - if (function_exists('imageantialias')) |
|
229 | - { |
|
230 | - imageantialias($imgThumb, true); |
|
231 | - } |
|
232 | - |
|
233 | - // This is to keep transparent alpha channel if exists (PHP >= 4.2) |
|
234 | - if (function_exists('imagesavealpha')) |
|
235 | - { |
|
236 | - imagesavealpha($imgThumb, true); |
|
237 | - } |
|
238 | - |
|
239 | - // Initialisation des variables selon l'extension de l'image |
|
240 | - switch($infoImg[2]) |
|
241 | - { |
|
242 | - case 1: // Gif |
|
243 | - $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF |
|
244 | - imagecolortransparent($imgThumb,$trans_colour); |
|
245 | - break; |
|
246 | - case 2: // Jpg |
|
247 | - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
|
248 | - break; |
|
249 | - case 3: // Png |
|
250 | - imagealphablending($imgThumb,false); // Pour compatibilite sur certain systeme |
|
251 | - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel |
|
252 | - break; |
|
253 | - case 4: // Bmp |
|
254 | - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
|
255 | - break; |
|
256 | - } |
|
257 | - if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour); |
|
258 | - |
|
259 | - dol_syslog("dol_imageResizeOrCrop: convert image from ($imgWidth x $imgHeight) at position ($src_x x $src_y) to ($newWidth x $newHeight) as $extImg, newquality=$newquality"); |
|
260 | - //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
|
261 | - imagecopyresampled($imgThumb, $img, 0, 0, $src_x, $src_y, $newWidth, $newHeight, ($mode==0?$imgWidth:$newWidth), ($mode==0?$imgHeight:$newHeight)); // Insere l'image de base redimensionnee |
|
262 | - |
|
263 | - $imgThumbName = $file; |
|
264 | - |
|
265 | - // Check if permission are ok |
|
266 | - //$fp = fopen($imgThumbName, "w"); |
|
267 | - //fclose($fp); |
|
268 | - |
|
269 | - // Create image on disk |
|
270 | - switch($infoImg[2]) |
|
271 | - { |
|
272 | - case 1: // Gif |
|
273 | - imagegif($imgThumb, $imgThumbName); |
|
274 | - break; |
|
275 | - case 2: // Jpg |
|
276 | - imagejpeg($imgThumb, $imgThumbName, $newquality); |
|
277 | - break; |
|
278 | - case 3: // Png |
|
279 | - imagepng($imgThumb, $imgThumbName, $newquality); |
|
280 | - break; |
|
281 | - case 4: // Bmp |
|
282 | - image2wbmp($imgThumb, $imgThumbName); |
|
283 | - break; |
|
284 | - } |
|
285 | - |
|
286 | - // Set permissions on file |
|
287 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
288 | - |
|
289 | - // Free memory. This does not delete image. |
|
111 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
112 | + |
|
113 | + global $conf,$langs; |
|
114 | + |
|
115 | + dol_syslog("dol_imageResizeOrCrop file=".$file." mode=".$mode." newWidth=".$newWidth." newHeight=".$newHeight." src_x=".$src_x." src_y=".$src_y); |
|
116 | + |
|
117 | + // Clean parameters |
|
118 | + $file=trim($file); |
|
119 | + |
|
120 | + // Check parameters |
|
121 | + if (! $file) |
|
122 | + { |
|
123 | + // Si le fichier n'a pas ete indique |
|
124 | + return 'Bad parameter file'; |
|
125 | + } |
|
126 | + elseif (! file_exists($file)) |
|
127 | + { |
|
128 | + // Si le fichier passe en parametre n'existe pas |
|
129 | + return $langs->trans("ErrorFileNotFound",$file); |
|
130 | + } |
|
131 | + elseif(image_format_supported($file) < 0) |
|
132 | + { |
|
133 | + return 'This filename '.$file.' does not seem to be an image filename.'; |
|
134 | + } |
|
135 | + elseif(!is_numeric($newWidth) && !is_numeric($newHeight)) |
|
136 | + { |
|
137 | + return 'Wrong value for parameter newWidth or newHeight'; |
|
138 | + } |
|
139 | + elseif ($mode == 0 && $newWidth <= 0 && $newHeight <= 0) |
|
140 | + { |
|
141 | + return 'At least newHeight or newWidth must be defined for resizing'; |
|
142 | + } |
|
143 | + elseif ($mode == 1 && ($newWidth <= 0 || $newHeight <= 0)) |
|
144 | + { |
|
145 | + return 'Both newHeight or newWidth must be defined for croping'; |
|
146 | + } |
|
147 | + |
|
148 | + $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
149 | + |
|
150 | + $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image |
|
151 | + $imgWidth = $infoImg[0]; // Largeur de l'image |
|
152 | + $imgHeight = $infoImg[1]; // Hauteur de l'image |
|
153 | + |
|
154 | + if ($mode == 0) // If resize, we check parameters |
|
155 | + { |
|
156 | + if ($newWidth <= 0) |
|
157 | + { |
|
158 | + $newWidth=intval(($newHeight / $imgHeight) * $imgWidth); // Keep ratio |
|
159 | + } |
|
160 | + if ($newHeight <= 0) |
|
161 | + { |
|
162 | + $newHeight=intval(($newWidth / $imgWidth) * $imgHeight); // Keep ratio |
|
163 | + } |
|
164 | + } |
|
165 | + |
|
166 | + $imgfonction=''; |
|
167 | + switch($infoImg[2]) |
|
168 | + { |
|
169 | + case 1: // IMG_GIF |
|
170 | + $imgfonction = 'imagecreatefromgif'; |
|
171 | + break; |
|
172 | + case 2: // IMG_JPG |
|
173 | + $imgfonction = 'imagecreatefromjpeg'; |
|
174 | + break; |
|
175 | + case 3: // IMG_PNG |
|
176 | + $imgfonction = 'imagecreatefrompng'; |
|
177 | + break; |
|
178 | + case 4: // IMG_WBMP |
|
179 | + $imgfonction = 'imagecreatefromwbmp'; |
|
180 | + break; |
|
181 | + } |
|
182 | + if ($imgfonction) |
|
183 | + { |
|
184 | + if (! function_exists($imgfonction)) |
|
185 | + { |
|
186 | + // Fonctions de conversion non presente dans ce PHP |
|
187 | + return 'Resize not possible. This PHP does not support GD functions '.$imgfonction; |
|
188 | + } |
|
189 | + } |
|
190 | + |
|
191 | + // Initialisation des variables selon l'extension de l'image |
|
192 | + switch($infoImg[2]) |
|
193 | + { |
|
194 | + case 1: // Gif |
|
195 | + $img = imagecreatefromgif($filetoread); |
|
196 | + $extImg = '.gif'; // File name extension of image |
|
197 | + $newquality='NU'; // Quality is not used for this format |
|
198 | + break; |
|
199 | + case 2: // Jpg |
|
200 | + $img = imagecreatefromjpeg($filetoread); |
|
201 | + $extImg = '.jpg'; |
|
202 | + $newquality=100; // % quality maximum |
|
203 | + break; |
|
204 | + case 3: // Png |
|
205 | + $img = imagecreatefrompng($filetoread); |
|
206 | + $extImg = '.png'; |
|
207 | + $newquality=0; // No compression (0-9) |
|
208 | + break; |
|
209 | + case 4: // Bmp |
|
210 | + $img = imagecreatefromwbmp($filetoread); |
|
211 | + $extImg = '.bmp'; |
|
212 | + $newquality='NU'; // Quality is not used for this format |
|
213 | + break; |
|
214 | + } |
|
215 | + |
|
216 | + // Create empty image |
|
217 | + if ($infoImg[2] == 1) |
|
218 | + { |
|
219 | + // Compatibilite image GIF |
|
220 | + $imgThumb = imagecreate($newWidth, $newHeight); |
|
221 | + } |
|
222 | + else |
|
223 | + { |
|
224 | + $imgThumb = imagecreatetruecolor($newWidth, $newHeight); |
|
225 | + } |
|
226 | + |
|
227 | + // Activate antialiasing for better quality |
|
228 | + if (function_exists('imageantialias')) |
|
229 | + { |
|
230 | + imageantialias($imgThumb, true); |
|
231 | + } |
|
232 | + |
|
233 | + // This is to keep transparent alpha channel if exists (PHP >= 4.2) |
|
234 | + if (function_exists('imagesavealpha')) |
|
235 | + { |
|
236 | + imagesavealpha($imgThumb, true); |
|
237 | + } |
|
238 | + |
|
239 | + // Initialisation des variables selon l'extension de l'image |
|
240 | + switch($infoImg[2]) |
|
241 | + { |
|
242 | + case 1: // Gif |
|
243 | + $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF |
|
244 | + imagecolortransparent($imgThumb,$trans_colour); |
|
245 | + break; |
|
246 | + case 2: // Jpg |
|
247 | + $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
|
248 | + break; |
|
249 | + case 3: // Png |
|
250 | + imagealphablending($imgThumb,false); // Pour compatibilite sur certain systeme |
|
251 | + $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel |
|
252 | + break; |
|
253 | + case 4: // Bmp |
|
254 | + $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
|
255 | + break; |
|
256 | + } |
|
257 | + if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour); |
|
258 | + |
|
259 | + dol_syslog("dol_imageResizeOrCrop: convert image from ($imgWidth x $imgHeight) at position ($src_x x $src_y) to ($newWidth x $newHeight) as $extImg, newquality=$newquality"); |
|
260 | + //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
|
261 | + imagecopyresampled($imgThumb, $img, 0, 0, $src_x, $src_y, $newWidth, $newHeight, ($mode==0?$imgWidth:$newWidth), ($mode==0?$imgHeight:$newHeight)); // Insere l'image de base redimensionnee |
|
262 | + |
|
263 | + $imgThumbName = $file; |
|
264 | + |
|
265 | + // Check if permission are ok |
|
266 | + //$fp = fopen($imgThumbName, "w"); |
|
267 | + //fclose($fp); |
|
268 | + |
|
269 | + // Create image on disk |
|
270 | + switch($infoImg[2]) |
|
271 | + { |
|
272 | + case 1: // Gif |
|
273 | + imagegif($imgThumb, $imgThumbName); |
|
274 | + break; |
|
275 | + case 2: // Jpg |
|
276 | + imagejpeg($imgThumb, $imgThumbName, $newquality); |
|
277 | + break; |
|
278 | + case 3: // Png |
|
279 | + imagepng($imgThumb, $imgThumbName, $newquality); |
|
280 | + break; |
|
281 | + case 4: // Bmp |
|
282 | + image2wbmp($imgThumb, $imgThumbName); |
|
283 | + break; |
|
284 | + } |
|
285 | + |
|
286 | + // Set permissions on file |
|
287 | + if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
288 | + |
|
289 | + // Free memory. This does not delete image. |
|
290 | 290 | imagedestroy($img); |
291 | - imagedestroy($imgThumb); |
|
291 | + imagedestroy($imgThumb); |
|
292 | 292 | |
293 | - clearstatcache(); // File was replaced by a modified one, so we clear file caches. |
|
293 | + clearstatcache(); // File was replaced by a modified one, so we clear file caches. |
|
294 | 294 | |
295 | - return $imgThumbName; |
|
295 | + return $imgThumbName; |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | |
@@ -351,247 +351,247 @@ discard block |
||
351 | 351 | */ |
352 | 352 | function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $quality=50, $outdir='thumbs', $targetformat=0) |
353 | 353 | { |
354 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
354 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
|
355 | 355 | |
356 | - global $conf,$langs; |
|
356 | + global $conf,$langs; |
|
357 | 357 | |
358 | - dol_syslog("vignette file=".$file." extName=".$extName." maxWidth=".$maxWidth." maxHeight=".$maxHeight." quality=".$quality." outdir=".$outdir." targetformat=".$targetformat); |
|
358 | + dol_syslog("vignette file=".$file." extName=".$extName." maxWidth=".$maxWidth." maxHeight=".$maxHeight." quality=".$quality." outdir=".$outdir." targetformat=".$targetformat); |
|
359 | 359 | |
360 | - // Clean parameters |
|
361 | - $file=trim($file); |
|
360 | + // Clean parameters |
|
361 | + $file=trim($file); |
|
362 | 362 | |
363 | - // Check parameters |
|
364 | - if (! $file) |
|
365 | - { |
|
366 | - // Si le fichier n'a pas ete indique |
|
367 | - return 'ErrorBadParameters'; |
|
368 | - } |
|
369 | - elseif (! file_exists($file)) |
|
370 | - { |
|
371 | - // Si le fichier passe en parametre n'existe pas |
|
363 | + // Check parameters |
|
364 | + if (! $file) |
|
365 | + { |
|
366 | + // Si le fichier n'a pas ete indique |
|
367 | + return 'ErrorBadParameters'; |
|
368 | + } |
|
369 | + elseif (! file_exists($file)) |
|
370 | + { |
|
371 | + // Si le fichier passe en parametre n'existe pas |
|
372 | 372 | dol_syslog($langs->trans("ErrorFileNotFound",$file),LOG_ERR); |
373 | - return $langs->trans("ErrorFileNotFound",$file); |
|
374 | - } |
|
375 | - elseif(image_format_supported($file) < 0) |
|
376 | - { |
|
373 | + return $langs->trans("ErrorFileNotFound",$file); |
|
374 | + } |
|
375 | + elseif(image_format_supported($file) < 0) |
|
376 | + { |
|
377 | 377 | dol_syslog('This file '.$file.' does not seem to be an image format file name.',LOG_WARNING); |
378 | - return 'ErrorBadImageFormat'; |
|
379 | - } |
|
380 | - elseif(!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1){ |
|
381 | - // Si la largeur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) |
|
378 | + return 'ErrorBadImageFormat'; |
|
379 | + } |
|
380 | + elseif(!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1){ |
|
381 | + // Si la largeur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) |
|
382 | 382 | dol_syslog('Wrong value for parameter maxWidth',LOG_ERR); |
383 | - return 'Error: Wrong value for parameter maxWidth'; |
|
384 | - } |
|
385 | - elseif(!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1){ |
|
386 | - // Si la hauteur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) |
|
383 | + return 'Error: Wrong value for parameter maxWidth'; |
|
384 | + } |
|
385 | + elseif(!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1){ |
|
386 | + // Si la hauteur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) |
|
387 | 387 | dol_syslog('Wrong value for parameter maxHeight',LOG_ERR); |
388 | - return 'Error: Wrong value for parameter maxHeight'; |
|
389 | - } |
|
390 | - |
|
391 | - $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
392 | - |
|
393 | - $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image |
|
394 | - $imgWidth = $infoImg[0]; // Largeur de l'image |
|
395 | - $imgHeight = $infoImg[1]; // Hauteur de l'image |
|
396 | - |
|
397 | - if ($maxWidth == -1) $maxWidth=$infoImg[0]; // If size is -1, we keep unchanged |
|
398 | - if ($maxHeight == -1) $maxHeight=$infoImg[1]; // If size is -1, we keep unchanged |
|
399 | - |
|
400 | - // Si l'image est plus petite que la largeur et la hauteur max, on ne cree pas de vignette |
|
401 | - if ($infoImg[0] < $maxWidth && $infoImg[1] < $maxHeight) |
|
402 | - { |
|
403 | - // On cree toujours les vignettes |
|
404 | - dol_syslog("File size is smaller than thumb size",LOG_DEBUG); |
|
405 | - //return 'Le fichier '.$file.' ne necessite pas de creation de vignette'; |
|
406 | - } |
|
407 | - |
|
408 | - $imgfonction=''; |
|
409 | - switch($infoImg[2]) |
|
410 | - { |
|
411 | - case IMAGETYPE_GIF: // 1 |
|
412 | - $imgfonction = 'imagecreatefromgif'; |
|
413 | - break; |
|
414 | - case IMAGETYPE_JPEG: // 2 |
|
415 | - $imgfonction = 'imagecreatefromjpeg'; |
|
416 | - break; |
|
417 | - case IMAGETYPE_PNG: // 3 |
|
418 | - $imgfonction = 'imagecreatefrompng'; |
|
419 | - break; |
|
420 | - case IMAGETYPE_BMP: // 6 |
|
388 | + return 'Error: Wrong value for parameter maxHeight'; |
|
389 | + } |
|
390 | + |
|
391 | + $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
392 | + |
|
393 | + $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image |
|
394 | + $imgWidth = $infoImg[0]; // Largeur de l'image |
|
395 | + $imgHeight = $infoImg[1]; // Hauteur de l'image |
|
396 | + |
|
397 | + if ($maxWidth == -1) $maxWidth=$infoImg[0]; // If size is -1, we keep unchanged |
|
398 | + if ($maxHeight == -1) $maxHeight=$infoImg[1]; // If size is -1, we keep unchanged |
|
399 | + |
|
400 | + // Si l'image est plus petite que la largeur et la hauteur max, on ne cree pas de vignette |
|
401 | + if ($infoImg[0] < $maxWidth && $infoImg[1] < $maxHeight) |
|
402 | + { |
|
403 | + // On cree toujours les vignettes |
|
404 | + dol_syslog("File size is smaller than thumb size",LOG_DEBUG); |
|
405 | + //return 'Le fichier '.$file.' ne necessite pas de creation de vignette'; |
|
406 | + } |
|
407 | + |
|
408 | + $imgfonction=''; |
|
409 | + switch($infoImg[2]) |
|
410 | + { |
|
411 | + case IMAGETYPE_GIF: // 1 |
|
412 | + $imgfonction = 'imagecreatefromgif'; |
|
413 | + break; |
|
414 | + case IMAGETYPE_JPEG: // 2 |
|
415 | + $imgfonction = 'imagecreatefromjpeg'; |
|
416 | + break; |
|
417 | + case IMAGETYPE_PNG: // 3 |
|
418 | + $imgfonction = 'imagecreatefrompng'; |
|
419 | + break; |
|
420 | + case IMAGETYPE_BMP: // 6 |
|
421 | 421 | // Not supported by PHP GD |
422 | - break; |
|
423 | - case IMAGETYPE_WBMP: // 15 |
|
424 | - $imgfonction = 'imagecreatefromwbmp'; |
|
425 | - break; |
|
426 | - } |
|
427 | - if ($imgfonction) |
|
428 | - { |
|
429 | - if (! function_exists($imgfonction)) |
|
430 | - { |
|
431 | - // Fonctions de conversion non presente dans ce PHP |
|
432 | - return 'Error: Creation of thumbs not possible. This PHP does not support GD function '.$imgfonction; |
|
433 | - } |
|
434 | - } |
|
435 | - |
|
436 | - // On cree le repertoire contenant les vignettes |
|
437 | - $dirthumb = dirname($file).($outdir?'/'.$outdir:''); // Chemin du dossier contenant les vignettes |
|
438 | - dol_mkdir($dirthumb); |
|
439 | - |
|
440 | - // Initialisation des variables selon l'extension de l'image |
|
441 | - $img=null; |
|
442 | - switch($infoImg[2]) |
|
443 | - { |
|
444 | - case IMAGETYPE_GIF: // 1 |
|
445 | - $img = imagecreatefromgif($filetoread); |
|
446 | - $extImg = '.gif'; // Extension de l'image |
|
447 | - break; |
|
448 | - case IMAGETYPE_JPEG: // 2 |
|
449 | - $img = imagecreatefromjpeg($filetoread); |
|
450 | - $extImg = (preg_match('/\.jpeg$/',$file)?'.jpeg':'.jpg'); // Extension de l'image |
|
451 | - break; |
|
452 | - case IMAGETYPE_PNG: // 3 |
|
453 | - $img = imagecreatefrompng($filetoread); |
|
454 | - $extImg = '.png'; |
|
455 | - break; |
|
456 | - case IMAGETYPE_BMP: // 6 |
|
422 | + break; |
|
423 | + case IMAGETYPE_WBMP: // 15 |
|
424 | + $imgfonction = 'imagecreatefromwbmp'; |
|
425 | + break; |
|
426 | + } |
|
427 | + if ($imgfonction) |
|
428 | + { |
|
429 | + if (! function_exists($imgfonction)) |
|
430 | + { |
|
431 | + // Fonctions de conversion non presente dans ce PHP |
|
432 | + return 'Error: Creation of thumbs not possible. This PHP does not support GD function '.$imgfonction; |
|
433 | + } |
|
434 | + } |
|
435 | + |
|
436 | + // On cree le repertoire contenant les vignettes |
|
437 | + $dirthumb = dirname($file).($outdir?'/'.$outdir:''); // Chemin du dossier contenant les vignettes |
|
438 | + dol_mkdir($dirthumb); |
|
439 | + |
|
440 | + // Initialisation des variables selon l'extension de l'image |
|
441 | + $img=null; |
|
442 | + switch($infoImg[2]) |
|
443 | + { |
|
444 | + case IMAGETYPE_GIF: // 1 |
|
445 | + $img = imagecreatefromgif($filetoread); |
|
446 | + $extImg = '.gif'; // Extension de l'image |
|
447 | + break; |
|
448 | + case IMAGETYPE_JPEG: // 2 |
|
449 | + $img = imagecreatefromjpeg($filetoread); |
|
450 | + $extImg = (preg_match('/\.jpeg$/',$file)?'.jpeg':'.jpg'); // Extension de l'image |
|
451 | + break; |
|
452 | + case IMAGETYPE_PNG: // 3 |
|
453 | + $img = imagecreatefrompng($filetoread); |
|
454 | + $extImg = '.png'; |
|
455 | + break; |
|
456 | + case IMAGETYPE_BMP: // 6 |
|
457 | 457 | // Not supported by PHP GD |
458 | - $extImg = '.bmp'; |
|
459 | - break; |
|
460 | - case IMAGETYPE_WBMP: // 15 |
|
461 | - $img = imagecreatefromwbmp($filetoread); |
|
462 | - $extImg = '.bmp'; |
|
463 | - break; |
|
464 | - } |
|
458 | + $extImg = '.bmp'; |
|
459 | + break; |
|
460 | + case IMAGETYPE_WBMP: // 15 |
|
461 | + $img = imagecreatefromwbmp($filetoread); |
|
462 | + $extImg = '.bmp'; |
|
463 | + break; |
|
464 | + } |
|
465 | 465 | if (! is_resource($img)) |
466 | 466 | { |
467 | 467 | dol_syslog('Failed to detect type of image. We found infoImg[2]='.$infoImg[2], LOG_WARNING); |
468 | 468 | return 0; |
469 | 469 | } |
470 | 470 | |
471 | - // Initialisation des dimensions de la vignette si elles sont superieures a l'original |
|
472 | - if($maxWidth > $imgWidth){ $maxWidth = $imgWidth; } |
|
473 | - if($maxHeight > $imgHeight){ $maxHeight = $imgHeight; } |
|
474 | - |
|
475 | - $whFact = $maxWidth/$maxHeight; // Facteur largeur/hauteur des dimensions max de la vignette |
|
476 | - $imgWhFact = $imgWidth/$imgHeight; // Facteur largeur/hauteur de l'original |
|
477 | - |
|
478 | - // Fixe les dimensions de la vignette |
|
479 | - if($whFact < $imgWhFact) |
|
480 | - { |
|
481 | - // Si largeur determinante |
|
482 | - $thumbWidth = $maxWidth; |
|
483 | - $thumbHeight = $thumbWidth / $imgWhFact; |
|
484 | - } |
|
485 | - else |
|
486 | - { |
|
487 | - // Si hauteur determinante |
|
488 | - $thumbHeight = $maxHeight; |
|
489 | - $thumbWidth = $thumbHeight * $imgWhFact; |
|
490 | - } |
|
491 | - $thumbHeight=round($thumbHeight); |
|
492 | - $thumbWidth=round($thumbWidth); |
|
471 | + // Initialisation des dimensions de la vignette si elles sont superieures a l'original |
|
472 | + if($maxWidth > $imgWidth){ $maxWidth = $imgWidth; } |
|
473 | + if($maxHeight > $imgHeight){ $maxHeight = $imgHeight; } |
|
474 | + |
|
475 | + $whFact = $maxWidth/$maxHeight; // Facteur largeur/hauteur des dimensions max de la vignette |
|
476 | + $imgWhFact = $imgWidth/$imgHeight; // Facteur largeur/hauteur de l'original |
|
477 | + |
|
478 | + // Fixe les dimensions de la vignette |
|
479 | + if($whFact < $imgWhFact) |
|
480 | + { |
|
481 | + // Si largeur determinante |
|
482 | + $thumbWidth = $maxWidth; |
|
483 | + $thumbHeight = $thumbWidth / $imgWhFact; |
|
484 | + } |
|
485 | + else |
|
486 | + { |
|
487 | + // Si hauteur determinante |
|
488 | + $thumbHeight = $maxHeight; |
|
489 | + $thumbWidth = $thumbHeight * $imgWhFact; |
|
490 | + } |
|
491 | + $thumbHeight=round($thumbHeight); |
|
492 | + $thumbWidth=round($thumbWidth); |
|
493 | 493 | |
494 | 494 | // Define target format |
495 | 495 | if (empty($targetformat)) $targetformat=$infoImg[2]; |
496 | 496 | |
497 | - // Create empty image |
|
498 | - if ($targetformat == IMAGETYPE_GIF) |
|
499 | - { |
|
500 | - // Compatibilite image GIF |
|
501 | - $imgThumb = imagecreate($thumbWidth, $thumbHeight); |
|
502 | - } |
|
503 | - else |
|
504 | - { |
|
505 | - $imgThumb = imagecreatetruecolor($thumbWidth, $thumbHeight); |
|
506 | - } |
|
507 | - |
|
508 | - // Activate antialiasing for better quality |
|
509 | - if (function_exists('imageantialias')) |
|
510 | - { |
|
511 | - imageantialias($imgThumb, true); |
|
512 | - } |
|
513 | - |
|
514 | - // This is to keep transparent alpha channel if exists (PHP >= 4.2) |
|
515 | - if (function_exists('imagesavealpha')) |
|
516 | - { |
|
517 | - imagesavealpha($imgThumb, true); |
|
518 | - } |
|
519 | - |
|
520 | - // Initialisation des variables selon l'extension de l'image |
|
521 | - // $targetformat is 0 by default, in such case, we keep original extension |
|
522 | - switch($targetformat) |
|
523 | - { |
|
524 | - case IMAGETYPE_GIF: // 1 |
|
525 | - $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF |
|
526 | - imagecolortransparent($imgThumb,$trans_colour); |
|
497 | + // Create empty image |
|
498 | + if ($targetformat == IMAGETYPE_GIF) |
|
499 | + { |
|
500 | + // Compatibilite image GIF |
|
501 | + $imgThumb = imagecreate($thumbWidth, $thumbHeight); |
|
502 | + } |
|
503 | + else |
|
504 | + { |
|
505 | + $imgThumb = imagecreatetruecolor($thumbWidth, $thumbHeight); |
|
506 | + } |
|
507 | + |
|
508 | + // Activate antialiasing for better quality |
|
509 | + if (function_exists('imageantialias')) |
|
510 | + { |
|
511 | + imageantialias($imgThumb, true); |
|
512 | + } |
|
513 | + |
|
514 | + // This is to keep transparent alpha channel if exists (PHP >= 4.2) |
|
515 | + if (function_exists('imagesavealpha')) |
|
516 | + { |
|
517 | + imagesavealpha($imgThumb, true); |
|
518 | + } |
|
519 | + |
|
520 | + // Initialisation des variables selon l'extension de l'image |
|
521 | + // $targetformat is 0 by default, in such case, we keep original extension |
|
522 | + switch($targetformat) |
|
523 | + { |
|
524 | + case IMAGETYPE_GIF: // 1 |
|
525 | + $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF |
|
526 | + imagecolortransparent($imgThumb,$trans_colour); |
|
527 | 527 | $extImgTarget = '.gif'; |
528 | 528 | $newquality='NU'; |
529 | 529 | break; |
530 | - case IMAGETYPE_JPEG: // 2 |
|
530 | + case IMAGETYPE_JPEG: // 2 |
|
531 | 531 | $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
532 | 532 | $extImgTarget = (preg_match('/\.jpeg$/i',$file)?'.jpeg':'.jpg'); |
533 | 533 | $newquality=$quality; |
534 | 534 | break; |
535 | - case IMAGETYPE_PNG: // 3 |
|
536 | - imagealphablending($imgThumb,false); // Pour compatibilite sur certain systeme |
|
537 | - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel |
|
535 | + case IMAGETYPE_PNG: // 3 |
|
536 | + imagealphablending($imgThumb,false); // Pour compatibilite sur certain systeme |
|
537 | + $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel |
|
538 | 538 | $extImgTarget = '.png'; |
539 | 539 | $newquality=$quality-100; |
540 | 540 | $newquality=round(abs($quality-100)*9/100); |
541 | 541 | break; |
542 | - case IMAGETYPE_BMP: // 6 |
|
542 | + case IMAGETYPE_BMP: // 6 |
|
543 | 543 | // Not supported by PHP GD |
544 | 544 | $extImgTarget = '.bmp'; |
545 | 545 | $newquality='NU'; |
546 | 546 | break; |
547 | - case IMAGETYPE_WBMP: // 15 |
|
548 | - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
|
547 | + case IMAGETYPE_WBMP: // 15 |
|
548 | + $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
|
549 | 549 | $extImgTarget = '.bmp'; |
550 | 550 | $newquality='NU'; |
551 | 551 | break; |
552 | - } |
|
553 | - if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour); |
|
554 | - |
|
555 | - dol_syslog("vignette: convert image from ($imgWidth x $imgHeight) to ($thumbWidth x $thumbHeight) as $extImg, newquality=$newquality"); |
|
556 | - //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
|
557 | - imagecopyresampled($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
|
558 | - |
|
559 | - $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse |
|
560 | - $fileName = basename($fileName); |
|
561 | - //$imgThumbName = $dirthumb.'/'.getImageFileNameForSize(basename($file), $extName, $extImgTarget); // Full path of thumb file |
|
562 | - $imgThumbName = getImageFileNameForSize($file, $extName, $extImgTarget); // Full path of thumb file |
|
563 | - |
|
564 | - |
|
565 | - // Check if permission are ok |
|
566 | - //$fp = fopen($imgThumbName, "w"); |
|
567 | - //fclose($fp); |
|
568 | - |
|
569 | - // Create image on disk |
|
570 | - switch($targetformat) |
|
571 | - { |
|
572 | - case IMAGETYPE_GIF: // 1 |
|
573 | - imagegif($imgThumb, $imgThumbName); |
|
574 | - break; |
|
575 | - case IMAGETYPE_JPEG: // 2 |
|
576 | - imagejpeg($imgThumb, $imgThumbName, $newquality); |
|
577 | - break; |
|
578 | - case IMAGETYPE_PNG: // 3 |
|
579 | - imagepng($imgThumb, $imgThumbName, $newquality); |
|
580 | - break; |
|
581 | - case IMAGETYPE_BMP: // 6 |
|
552 | + } |
|
553 | + if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour); |
|
554 | + |
|
555 | + dol_syslog("vignette: convert image from ($imgWidth x $imgHeight) to ($thumbWidth x $thumbHeight) as $extImg, newquality=$newquality"); |
|
556 | + //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
|
557 | + imagecopyresampled($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
|
558 | + |
|
559 | + $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse |
|
560 | + $fileName = basename($fileName); |
|
561 | + //$imgThumbName = $dirthumb.'/'.getImageFileNameForSize(basename($file), $extName, $extImgTarget); // Full path of thumb file |
|
562 | + $imgThumbName = getImageFileNameForSize($file, $extName, $extImgTarget); // Full path of thumb file |
|
563 | + |
|
564 | + |
|
565 | + // Check if permission are ok |
|
566 | + //$fp = fopen($imgThumbName, "w"); |
|
567 | + //fclose($fp); |
|
568 | + |
|
569 | + // Create image on disk |
|
570 | + switch($targetformat) |
|
571 | + { |
|
572 | + case IMAGETYPE_GIF: // 1 |
|
573 | + imagegif($imgThumb, $imgThumbName); |
|
574 | + break; |
|
575 | + case IMAGETYPE_JPEG: // 2 |
|
576 | + imagejpeg($imgThumb, $imgThumbName, $newquality); |
|
577 | + break; |
|
578 | + case IMAGETYPE_PNG: // 3 |
|
579 | + imagepng($imgThumb, $imgThumbName, $newquality); |
|
580 | + break; |
|
581 | + case IMAGETYPE_BMP: // 6 |
|
582 | 582 | // Not supported by PHP GD |
583 | - break; |
|
584 | - case IMAGETYPE_WBMP: // 15 |
|
585 | - image2wbmp($imgThumb, $imgThumbName); |
|
586 | - break; |
|
587 | - } |
|
583 | + break; |
|
584 | + case IMAGETYPE_WBMP: // 15 |
|
585 | + image2wbmp($imgThumb, $imgThumbName); |
|
586 | + break; |
|
587 | + } |
|
588 | 588 | |
589 | - // Set permissions on file |
|
590 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
589 | + // Set permissions on file |
|
590 | + if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
591 | 591 | |
592 | 592 | // Free memory. This does not delete image. |
593 | 593 | imagedestroy($img); |
594 | 594 | imagedestroy($imgThumb); |
595 | 595 | |
596 | - return $imgThumbName; |
|
596 | + return $imgThumbName; |
|
597 | 597 | } |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | // Define size of logo small and mini |
26 | -$maxwidthsmall=270;$maxheightsmall=150; |
|
27 | -$maxwidthmini=128;$maxheightmini=72; |
|
26 | +$maxwidthsmall = 270; $maxheightsmall = 150; |
|
27 | +$maxwidthmini = 128; $maxheightmini = 72; |
|
28 | 28 | $quality = 80; |
29 | 29 | |
30 | 30 | |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | */ |
38 | 38 | function image_format_supported($file) |
39 | 39 | { |
40 | - $regeximgext='\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm|\.svg'; // See also into product.class.php |
|
40 | + $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm|\.svg'; // See also into product.class.php |
|
41 | 41 | |
42 | 42 | // Case filename is not a format image |
43 | - if (! preg_match('/('.$regeximgext.')$/i',$file,$reg)) return -1; |
|
43 | + if (!preg_match('/('.$regeximgext.')$/i', $file, $reg)) return -1; |
|
44 | 44 | |
45 | 45 | // Case filename is a format image but not supported by this PHP |
46 | - $imgfonction=''; |
|
46 | + $imgfonction = ''; |
|
47 | 47 | if (strtolower($reg[1]) == '.gif') $imgfonction = 'imagecreatefromgif'; |
48 | 48 | if (strtolower($reg[1]) == '.png') $imgfonction = 'imagecreatefrompng'; |
49 | 49 | if (strtolower($reg[1]) == '.jpg') $imgfonction = 'imagecreatefromjpeg'; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | if (strtolower($reg[1]) == '.xbm') $imgfonction = 'imagecreatefromxbm'; |
54 | 54 | if ($imgfonction) |
55 | 55 | { |
56 | - if (! function_exists($imgfonction)) |
|
56 | + if (!function_exists($imgfonction)) |
|
57 | 57 | { |
58 | 58 | // Fonctions de conversion non presente dans ce PHP |
59 | 59 | return 0; |
@@ -74,21 +74,21 @@ discard block |
||
74 | 74 | */ |
75 | 75 | function dol_getImageSize($file, $url = false) |
76 | 76 | { |
77 | - $ret=array(); |
|
77 | + $ret = array(); |
|
78 | 78 | |
79 | 79 | if (image_format_supported($file) < 0) return $ret; |
80 | 80 | |
81 | 81 | $filetoread = $file; |
82 | 82 | if (!$url) |
83 | 83 | { |
84 | - $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
84 | + $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | if ($filetoread) |
88 | 88 | { |
89 | 89 | $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image |
90 | - $ret['width']=$infoImg[0]; // Largeur de l'image |
|
91 | - $ret['height']=$infoImg[1]; // Hauteur de l'image |
|
90 | + $ret['width'] = $infoImg[0]; // Largeur de l'image |
|
91 | + $ret['height'] = $infoImg[1]; // Hauteur de l'image |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | return $ret; |
@@ -106,33 +106,33 @@ discard block |
||
106 | 106 | * @param int $src_y Position of croping image in source image (not use if mode=0) |
107 | 107 | * @return int File name if OK, error message if KO |
108 | 108 | */ |
109 | -function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $src_y=0) |
|
109 | +function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $src_y = 0) |
|
110 | 110 | { |
111 | 111 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
112 | 112 | |
113 | - global $conf,$langs; |
|
113 | + global $conf, $langs; |
|
114 | 114 | |
115 | 115 | dol_syslog("dol_imageResizeOrCrop file=".$file." mode=".$mode." newWidth=".$newWidth." newHeight=".$newHeight." src_x=".$src_x." src_y=".$src_y); |
116 | 116 | |
117 | 117 | // Clean parameters |
118 | - $file=trim($file); |
|
118 | + $file = trim($file); |
|
119 | 119 | |
120 | 120 | // Check parameters |
121 | - if (! $file) |
|
121 | + if (!$file) |
|
122 | 122 | { |
123 | 123 | // Si le fichier n'a pas ete indique |
124 | 124 | return 'Bad parameter file'; |
125 | 125 | } |
126 | - elseif (! file_exists($file)) |
|
126 | + elseif (!file_exists($file)) |
|
127 | 127 | { |
128 | 128 | // Si le fichier passe en parametre n'existe pas |
129 | - return $langs->trans("ErrorFileNotFound",$file); |
|
129 | + return $langs->trans("ErrorFileNotFound", $file); |
|
130 | 130 | } |
131 | - elseif(image_format_supported($file) < 0) |
|
131 | + elseif (image_format_supported($file) < 0) |
|
132 | 132 | { |
133 | 133 | return 'This filename '.$file.' does not seem to be an image filename.'; |
134 | 134 | } |
135 | - elseif(!is_numeric($newWidth) && !is_numeric($newHeight)) |
|
135 | + elseif (!is_numeric($newWidth) && !is_numeric($newHeight)) |
|
136 | 136 | { |
137 | 137 | return 'Wrong value for parameter newWidth or newHeight'; |
138 | 138 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | return 'Both newHeight or newWidth must be defined for croping'; |
146 | 146 | } |
147 | 147 | |
148 | - $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
148 | + $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
149 | 149 | |
150 | 150 | $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image |
151 | 151 | $imgWidth = $infoImg[0]; // Largeur de l'image |
@@ -153,18 +153,18 @@ discard block |
||
153 | 153 | |
154 | 154 | if ($mode == 0) // If resize, we check parameters |
155 | 155 | { |
156 | - if ($newWidth <= 0) |
|
156 | + if ($newWidth <= 0) |
|
157 | 157 | { |
158 | - $newWidth=intval(($newHeight / $imgHeight) * $imgWidth); // Keep ratio |
|
158 | + $newWidth = intval(($newHeight / $imgHeight) * $imgWidth); // Keep ratio |
|
159 | 159 | } |
160 | 160 | if ($newHeight <= 0) |
161 | 161 | { |
162 | - $newHeight=intval(($newWidth / $imgWidth) * $imgHeight); // Keep ratio |
|
162 | + $newHeight = intval(($newWidth / $imgWidth) * $imgHeight); // Keep ratio |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
166 | - $imgfonction=''; |
|
167 | - switch($infoImg[2]) |
|
166 | + $imgfonction = ''; |
|
167 | + switch ($infoImg[2]) |
|
168 | 168 | { |
169 | 169 | case 1: // IMG_GIF |
170 | 170 | $imgfonction = 'imagecreatefromgif'; |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | } |
182 | 182 | if ($imgfonction) |
183 | 183 | { |
184 | - if (! function_exists($imgfonction)) |
|
184 | + if (!function_exists($imgfonction)) |
|
185 | 185 | { |
186 | 186 | // Fonctions de conversion non presente dans ce PHP |
187 | 187 | return 'Resize not possible. This PHP does not support GD functions '.$imgfonction; |
@@ -189,27 +189,27 @@ discard block |
||
189 | 189 | } |
190 | 190 | |
191 | 191 | // Initialisation des variables selon l'extension de l'image |
192 | - switch($infoImg[2]) |
|
192 | + switch ($infoImg[2]) |
|
193 | 193 | { |
194 | 194 | case 1: // Gif |
195 | 195 | $img = imagecreatefromgif($filetoread); |
196 | - $extImg = '.gif'; // File name extension of image |
|
197 | - $newquality='NU'; // Quality is not used for this format |
|
196 | + $extImg = '.gif'; // File name extension of image |
|
197 | + $newquality = 'NU'; // Quality is not used for this format |
|
198 | 198 | break; |
199 | 199 | case 2: // Jpg |
200 | 200 | $img = imagecreatefromjpeg($filetoread); |
201 | 201 | $extImg = '.jpg'; |
202 | - $newquality=100; // % quality maximum |
|
202 | + $newquality = 100; // % quality maximum |
|
203 | 203 | break; |
204 | 204 | case 3: // Png |
205 | 205 | $img = imagecreatefrompng($filetoread); |
206 | 206 | $extImg = '.png'; |
207 | - $newquality=0; // No compression (0-9) |
|
207 | + $newquality = 0; // No compression (0-9) |
|
208 | 208 | break; |
209 | 209 | case 4: // Bmp |
210 | 210 | $img = imagecreatefromwbmp($filetoread); |
211 | 211 | $extImg = '.bmp'; |
212 | - $newquality='NU'; // Quality is not used for this format |
|
212 | + $newquality = 'NU'; // Quality is not used for this format |
|
213 | 213 | break; |
214 | 214 | } |
215 | 215 | |
@@ -237,18 +237,18 @@ discard block |
||
237 | 237 | } |
238 | 238 | |
239 | 239 | // Initialisation des variables selon l'extension de l'image |
240 | - switch($infoImg[2]) |
|
240 | + switch ($infoImg[2]) |
|
241 | 241 | { |
242 | 242 | case 1: // Gif |
243 | 243 | $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF |
244 | - imagecolortransparent($imgThumb,$trans_colour); |
|
244 | + imagecolortransparent($imgThumb, $trans_colour); |
|
245 | 245 | break; |
246 | 246 | case 2: // Jpg |
247 | 247 | $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
248 | 248 | break; |
249 | 249 | case 3: // Png |
250 | - imagealphablending($imgThumb,false); // Pour compatibilite sur certain systeme |
|
251 | - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel |
|
250 | + imagealphablending($imgThumb, false); // Pour compatibilite sur certain systeme |
|
251 | + $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel |
|
252 | 252 | break; |
253 | 253 | case 4: // Bmp |
254 | 254 | $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | |
259 | 259 | dol_syslog("dol_imageResizeOrCrop: convert image from ($imgWidth x $imgHeight) at position ($src_x x $src_y) to ($newWidth x $newHeight) as $extImg, newquality=$newquality"); |
260 | 260 | //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
261 | - imagecopyresampled($imgThumb, $img, 0, 0, $src_x, $src_y, $newWidth, $newHeight, ($mode==0?$imgWidth:$newWidth), ($mode==0?$imgHeight:$newHeight)); // Insere l'image de base redimensionnee |
|
261 | + imagecopyresampled($imgThumb, $img, 0, 0, $src_x, $src_y, $newWidth, $newHeight, ($mode == 0 ? $imgWidth : $newWidth), ($mode == 0 ? $imgHeight : $newHeight)); // Insere l'image de base redimensionnee |
|
262 | 262 | |
263 | 263 | $imgThumbName = $file; |
264 | 264 | |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | //fclose($fp); |
268 | 268 | |
269 | 269 | // Create image on disk |
270 | - switch($infoImg[2]) |
|
270 | + switch ($infoImg[2]) |
|
271 | 271 | { |
272 | 272 | case 1: // Gif |
273 | 273 | imagegif($imgThumb, $imgThumbName); |
@@ -284,13 +284,13 @@ discard block |
||
284 | 284 | } |
285 | 285 | |
286 | 286 | // Set permissions on file |
287 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
287 | + if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
288 | 288 | |
289 | 289 | // Free memory. This does not delete image. |
290 | 290 | imagedestroy($img); |
291 | 291 | imagedestroy($imgThumb); |
292 | 292 | |
293 | - clearstatcache(); // File was replaced by a modified one, so we clear file caches. |
|
293 | + clearstatcache(); // File was replaced by a modified one, so we clear file caches. |
|
294 | 294 | |
295 | 295 | return $imgThumbName; |
296 | 296 | } |
@@ -349,64 +349,64 @@ discard block |
||
349 | 349 | * @param int $targetformat New format of target (IMAGETYPE_GIF, IMAGETYPE_JPG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_WBMP ... or 0 to keep old format) |
350 | 350 | * @return string Full path of thumb or '' if it fails or 'Error...' if it fails |
351 | 351 | */ |
352 | -function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $quality=50, $outdir='thumbs', $targetformat=0) |
|
352 | +function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $quality = 50, $outdir = 'thumbs', $targetformat = 0) |
|
353 | 353 | { |
354 | 354 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
355 | 355 | |
356 | - global $conf,$langs; |
|
356 | + global $conf, $langs; |
|
357 | 357 | |
358 | 358 | dol_syslog("vignette file=".$file." extName=".$extName." maxWidth=".$maxWidth." maxHeight=".$maxHeight." quality=".$quality." outdir=".$outdir." targetformat=".$targetformat); |
359 | 359 | |
360 | 360 | // Clean parameters |
361 | - $file=trim($file); |
|
361 | + $file = trim($file); |
|
362 | 362 | |
363 | 363 | // Check parameters |
364 | - if (! $file) |
|
364 | + if (!$file) |
|
365 | 365 | { |
366 | 366 | // Si le fichier n'a pas ete indique |
367 | 367 | return 'ErrorBadParameters'; |
368 | 368 | } |
369 | - elseif (! file_exists($file)) |
|
369 | + elseif (!file_exists($file)) |
|
370 | 370 | { |
371 | 371 | // Si le fichier passe en parametre n'existe pas |
372 | - dol_syslog($langs->trans("ErrorFileNotFound",$file),LOG_ERR); |
|
373 | - return $langs->trans("ErrorFileNotFound",$file); |
|
372 | + dol_syslog($langs->trans("ErrorFileNotFound", $file), LOG_ERR); |
|
373 | + return $langs->trans("ErrorFileNotFound", $file); |
|
374 | 374 | } |
375 | - elseif(image_format_supported($file) < 0) |
|
375 | + elseif (image_format_supported($file) < 0) |
|
376 | 376 | { |
377 | - dol_syslog('This file '.$file.' does not seem to be an image format file name.',LOG_WARNING); |
|
377 | + dol_syslog('This file '.$file.' does not seem to be an image format file name.', LOG_WARNING); |
|
378 | 378 | return 'ErrorBadImageFormat'; |
379 | 379 | } |
380 | - elseif(!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1){ |
|
380 | + elseif (!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1) { |
|
381 | 381 | // Si la largeur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) |
382 | - dol_syslog('Wrong value for parameter maxWidth',LOG_ERR); |
|
382 | + dol_syslog('Wrong value for parameter maxWidth', LOG_ERR); |
|
383 | 383 | return 'Error: Wrong value for parameter maxWidth'; |
384 | 384 | } |
385 | - elseif(!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1){ |
|
385 | + elseif (!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1) { |
|
386 | 386 | // Si la hauteur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) |
387 | - dol_syslog('Wrong value for parameter maxHeight',LOG_ERR); |
|
387 | + dol_syslog('Wrong value for parameter maxHeight', LOG_ERR); |
|
388 | 388 | return 'Error: Wrong value for parameter maxHeight'; |
389 | 389 | } |
390 | 390 | |
391 | - $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
391 | + $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image |
|
392 | 392 | |
393 | 393 | $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image |
394 | 394 | $imgWidth = $infoImg[0]; // Largeur de l'image |
395 | 395 | $imgHeight = $infoImg[1]; // Hauteur de l'image |
396 | 396 | |
397 | - if ($maxWidth == -1) $maxWidth=$infoImg[0]; // If size is -1, we keep unchanged |
|
398 | - if ($maxHeight == -1) $maxHeight=$infoImg[1]; // If size is -1, we keep unchanged |
|
397 | + if ($maxWidth == -1) $maxWidth = $infoImg[0]; // If size is -1, we keep unchanged |
|
398 | + if ($maxHeight == -1) $maxHeight = $infoImg[1]; // If size is -1, we keep unchanged |
|
399 | 399 | |
400 | 400 | // Si l'image est plus petite que la largeur et la hauteur max, on ne cree pas de vignette |
401 | 401 | if ($infoImg[0] < $maxWidth && $infoImg[1] < $maxHeight) |
402 | 402 | { |
403 | 403 | // On cree toujours les vignettes |
404 | - dol_syslog("File size is smaller than thumb size",LOG_DEBUG); |
|
404 | + dol_syslog("File size is smaller than thumb size", LOG_DEBUG); |
|
405 | 405 | //return 'Le fichier '.$file.' ne necessite pas de creation de vignette'; |
406 | 406 | } |
407 | 407 | |
408 | - $imgfonction=''; |
|
409 | - switch($infoImg[2]) |
|
408 | + $imgfonction = ''; |
|
409 | + switch ($infoImg[2]) |
|
410 | 410 | { |
411 | 411 | case IMAGETYPE_GIF: // 1 |
412 | 412 | $imgfonction = 'imagecreatefromgif'; |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | } |
427 | 427 | if ($imgfonction) |
428 | 428 | { |
429 | - if (! function_exists($imgfonction)) |
|
429 | + if (!function_exists($imgfonction)) |
|
430 | 430 | { |
431 | 431 | // Fonctions de conversion non presente dans ce PHP |
432 | 432 | return 'Error: Creation of thumbs not possible. This PHP does not support GD function '.$imgfonction; |
@@ -434,12 +434,12 @@ discard block |
||
434 | 434 | } |
435 | 435 | |
436 | 436 | // On cree le repertoire contenant les vignettes |
437 | - $dirthumb = dirname($file).($outdir?'/'.$outdir:''); // Chemin du dossier contenant les vignettes |
|
437 | + $dirthumb = dirname($file).($outdir ? '/'.$outdir : ''); // Chemin du dossier contenant les vignettes |
|
438 | 438 | dol_mkdir($dirthumb); |
439 | 439 | |
440 | 440 | // Initialisation des variables selon l'extension de l'image |
441 | - $img=null; |
|
442 | - switch($infoImg[2]) |
|
441 | + $img = null; |
|
442 | + switch ($infoImg[2]) |
|
443 | 443 | { |
444 | 444 | case IMAGETYPE_GIF: // 1 |
445 | 445 | $img = imagecreatefromgif($filetoread); |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | break; |
448 | 448 | case IMAGETYPE_JPEG: // 2 |
449 | 449 | $img = imagecreatefromjpeg($filetoread); |
450 | - $extImg = (preg_match('/\.jpeg$/',$file)?'.jpeg':'.jpg'); // Extension de l'image |
|
450 | + $extImg = (preg_match('/\.jpeg$/', $file) ? '.jpeg' : '.jpg'); // Extension de l'image |
|
451 | 451 | break; |
452 | 452 | case IMAGETYPE_PNG: // 3 |
453 | 453 | $img = imagecreatefrompng($filetoread); |
@@ -462,21 +462,21 @@ discard block |
||
462 | 462 | $extImg = '.bmp'; |
463 | 463 | break; |
464 | 464 | } |
465 | - if (! is_resource($img)) |
|
465 | + if (!is_resource($img)) |
|
466 | 466 | { |
467 | 467 | dol_syslog('Failed to detect type of image. We found infoImg[2]='.$infoImg[2], LOG_WARNING); |
468 | 468 | return 0; |
469 | 469 | } |
470 | 470 | |
471 | 471 | // Initialisation des dimensions de la vignette si elles sont superieures a l'original |
472 | - if($maxWidth > $imgWidth){ $maxWidth = $imgWidth; } |
|
473 | - if($maxHeight > $imgHeight){ $maxHeight = $imgHeight; } |
|
472 | + if ($maxWidth > $imgWidth) { $maxWidth = $imgWidth; } |
|
473 | + if ($maxHeight > $imgHeight) { $maxHeight = $imgHeight; } |
|
474 | 474 | |
475 | - $whFact = $maxWidth/$maxHeight; // Facteur largeur/hauteur des dimensions max de la vignette |
|
476 | - $imgWhFact = $imgWidth/$imgHeight; // Facteur largeur/hauteur de l'original |
|
475 | + $whFact = $maxWidth / $maxHeight; // Facteur largeur/hauteur des dimensions max de la vignette |
|
476 | + $imgWhFact = $imgWidth / $imgHeight; // Facteur largeur/hauteur de l'original |
|
477 | 477 | |
478 | 478 | // Fixe les dimensions de la vignette |
479 | - if($whFact < $imgWhFact) |
|
479 | + if ($whFact < $imgWhFact) |
|
480 | 480 | { |
481 | 481 | // Si largeur determinante |
482 | 482 | $thumbWidth = $maxWidth; |
@@ -488,11 +488,11 @@ discard block |
||
488 | 488 | $thumbHeight = $maxHeight; |
489 | 489 | $thumbWidth = $thumbHeight * $imgWhFact; |
490 | 490 | } |
491 | - $thumbHeight=round($thumbHeight); |
|
492 | - $thumbWidth=round($thumbWidth); |
|
491 | + $thumbHeight = round($thumbHeight); |
|
492 | + $thumbWidth = round($thumbWidth); |
|
493 | 493 | |
494 | 494 | // Define target format |
495 | - if (empty($targetformat)) $targetformat=$infoImg[2]; |
|
495 | + if (empty($targetformat)) $targetformat = $infoImg[2]; |
|
496 | 496 | |
497 | 497 | // Create empty image |
498 | 498 | if ($targetformat == IMAGETYPE_GIF) |
@@ -519,35 +519,35 @@ discard block |
||
519 | 519 | |
520 | 520 | // Initialisation des variables selon l'extension de l'image |
521 | 521 | // $targetformat is 0 by default, in such case, we keep original extension |
522 | - switch($targetformat) |
|
522 | + switch ($targetformat) |
|
523 | 523 | { |
524 | 524 | case IMAGETYPE_GIF: // 1 |
525 | 525 | $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF |
526 | - imagecolortransparent($imgThumb,$trans_colour); |
|
526 | + imagecolortransparent($imgThumb, $trans_colour); |
|
527 | 527 | $extImgTarget = '.gif'; |
528 | - $newquality='NU'; |
|
528 | + $newquality = 'NU'; |
|
529 | 529 | break; |
530 | 530 | case IMAGETYPE_JPEG: // 2 |
531 | 531 | $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
532 | - $extImgTarget = (preg_match('/\.jpeg$/i',$file)?'.jpeg':'.jpg'); |
|
533 | - $newquality=$quality; |
|
532 | + $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '.jpg'); |
|
533 | + $newquality = $quality; |
|
534 | 534 | break; |
535 | 535 | case IMAGETYPE_PNG: // 3 |
536 | - imagealphablending($imgThumb,false); // Pour compatibilite sur certain systeme |
|
537 | - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel |
|
536 | + imagealphablending($imgThumb, false); // Pour compatibilite sur certain systeme |
|
537 | + $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel |
|
538 | 538 | $extImgTarget = '.png'; |
539 | - $newquality=$quality-100; |
|
540 | - $newquality=round(abs($quality-100)*9/100); |
|
539 | + $newquality = $quality - 100; |
|
540 | + $newquality = round(abs($quality - 100) * 9 / 100); |
|
541 | 541 | break; |
542 | 542 | case IMAGETYPE_BMP: // 6 |
543 | 543 | // Not supported by PHP GD |
544 | 544 | $extImgTarget = '.bmp'; |
545 | - $newquality='NU'; |
|
545 | + $newquality = 'NU'; |
|
546 | 546 | break; |
547 | 547 | case IMAGETYPE_WBMP: // 15 |
548 | 548 | $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
549 | 549 | $extImgTarget = '.bmp'; |
550 | - $newquality='NU'; |
|
550 | + $newquality = 'NU'; |
|
551 | 551 | break; |
552 | 552 | } |
553 | 553 | if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour); |
@@ -556,10 +556,10 @@ discard block |
||
556 | 556 | //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
557 | 557 | imagecopyresampled($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
558 | 558 | |
559 | - $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse |
|
559 | + $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i', '', $file); // On enleve extension quelquesoit la casse |
|
560 | 560 | $fileName = basename($fileName); |
561 | 561 | //$imgThumbName = $dirthumb.'/'.getImageFileNameForSize(basename($file), $extName, $extImgTarget); // Full path of thumb file |
562 | - $imgThumbName = getImageFileNameForSize($file, $extName, $extImgTarget); // Full path of thumb file |
|
562 | + $imgThumbName = getImageFileNameForSize($file, $extName, $extImgTarget); // Full path of thumb file |
|
563 | 563 | |
564 | 564 | |
565 | 565 | // Check if permission are ok |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | //fclose($fp); |
568 | 568 | |
569 | 569 | // Create image on disk |
570 | - switch($targetformat) |
|
570 | + switch ($targetformat) |
|
571 | 571 | { |
572 | 572 | case IMAGETYPE_GIF: // 1 |
573 | 573 | imagegif($imgThumb, $imgThumbName); |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | } |
588 | 588 | |
589 | 589 | // Set permissions on file |
590 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
590 | + if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
591 | 591 | |
592 | 592 | // Free memory. This does not delete image. |
593 | 593 | imagedestroy($img); |
@@ -40,17 +40,33 @@ discard block |
||
40 | 40 | $regeximgext='\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm|\.svg'; // See also into product.class.php |
41 | 41 | |
42 | 42 | // Case filename is not a format image |
43 | - if (! preg_match('/('.$regeximgext.')$/i',$file,$reg)) return -1; |
|
43 | + if (! preg_match('/('.$regeximgext.')$/i',$file,$reg)) { |
|
44 | + return -1; |
|
45 | + } |
|
44 | 46 | |
45 | 47 | // Case filename is a format image but not supported by this PHP |
46 | 48 | $imgfonction=''; |
47 | - if (strtolower($reg[1]) == '.gif') $imgfonction = 'imagecreatefromgif'; |
|
48 | - if (strtolower($reg[1]) == '.png') $imgfonction = 'imagecreatefrompng'; |
|
49 | - if (strtolower($reg[1]) == '.jpg') $imgfonction = 'imagecreatefromjpeg'; |
|
50 | - if (strtolower($reg[1]) == '.jpeg') $imgfonction = 'imagecreatefromjpeg'; |
|
51 | - if (strtolower($reg[1]) == '.bmp') $imgfonction = 'imagecreatefromwbmp'; |
|
52 | - if (strtolower($reg[1]) == '.xpm') $imgfonction = 'imagecreatefromxpm'; |
|
53 | - if (strtolower($reg[1]) == '.xbm') $imgfonction = 'imagecreatefromxbm'; |
|
49 | + if (strtolower($reg[1]) == '.gif') { |
|
50 | + $imgfonction = 'imagecreatefromgif'; |
|
51 | + } |
|
52 | + if (strtolower($reg[1]) == '.png') { |
|
53 | + $imgfonction = 'imagecreatefrompng'; |
|
54 | + } |
|
55 | + if (strtolower($reg[1]) == '.jpg') { |
|
56 | + $imgfonction = 'imagecreatefromjpeg'; |
|
57 | + } |
|
58 | + if (strtolower($reg[1]) == '.jpeg') { |
|
59 | + $imgfonction = 'imagecreatefromjpeg'; |
|
60 | + } |
|
61 | + if (strtolower($reg[1]) == '.bmp') { |
|
62 | + $imgfonction = 'imagecreatefromwbmp'; |
|
63 | + } |
|
64 | + if (strtolower($reg[1]) == '.xpm') { |
|
65 | + $imgfonction = 'imagecreatefromxpm'; |
|
66 | + } |
|
67 | + if (strtolower($reg[1]) == '.xbm') { |
|
68 | + $imgfonction = 'imagecreatefromxbm'; |
|
69 | + } |
|
54 | 70 | if ($imgfonction) |
55 | 71 | { |
56 | 72 | if (! function_exists($imgfonction)) |
@@ -76,7 +92,9 @@ discard block |
||
76 | 92 | { |
77 | 93 | $ret=array(); |
78 | 94 | |
79 | - if (image_format_supported($file) < 0) return $ret; |
|
95 | + if (image_format_supported($file) < 0) { |
|
96 | + return $ret; |
|
97 | + } |
|
80 | 98 | |
81 | 99 | $filetoread = $file; |
82 | 100 | if (!$url) |
@@ -122,25 +140,20 @@ discard block |
||
122 | 140 | { |
123 | 141 | // Si le fichier n'a pas ete indique |
124 | 142 | return 'Bad parameter file'; |
125 | - } |
|
126 | - elseif (! file_exists($file)) |
|
143 | + } elseif (! file_exists($file)) |
|
127 | 144 | { |
128 | 145 | // Si le fichier passe en parametre n'existe pas |
129 | 146 | return $langs->trans("ErrorFileNotFound",$file); |
130 | - } |
|
131 | - elseif(image_format_supported($file) < 0) |
|
147 | + } elseif(image_format_supported($file) < 0) |
|
132 | 148 | { |
133 | 149 | return 'This filename '.$file.' does not seem to be an image filename.'; |
134 | - } |
|
135 | - elseif(!is_numeric($newWidth) && !is_numeric($newHeight)) |
|
150 | + } elseif(!is_numeric($newWidth) && !is_numeric($newHeight)) |
|
136 | 151 | { |
137 | 152 | return 'Wrong value for parameter newWidth or newHeight'; |
138 | - } |
|
139 | - elseif ($mode == 0 && $newWidth <= 0 && $newHeight <= 0) |
|
153 | + } elseif ($mode == 0 && $newWidth <= 0 && $newHeight <= 0) |
|
140 | 154 | { |
141 | 155 | return 'At least newHeight or newWidth must be defined for resizing'; |
142 | - } |
|
143 | - elseif ($mode == 1 && ($newWidth <= 0 || $newHeight <= 0)) |
|
156 | + } elseif ($mode == 1 && ($newWidth <= 0 || $newHeight <= 0)) |
|
144 | 157 | { |
145 | 158 | return 'Both newHeight or newWidth must be defined for croping'; |
146 | 159 | } |
@@ -151,11 +164,14 @@ discard block |
||
151 | 164 | $imgWidth = $infoImg[0]; // Largeur de l'image |
152 | 165 | $imgHeight = $infoImg[1]; // Hauteur de l'image |
153 | 166 | |
154 | - if ($mode == 0) // If resize, we check parameters |
|
167 | + if ($mode == 0) { |
|
168 | + // If resize, we check parameters |
|
155 | 169 | { |
156 | 170 | if ($newWidth <= 0) |
157 | 171 | { |
158 | - $newWidth=intval(($newHeight / $imgHeight) * $imgWidth); // Keep ratio |
|
172 | + $newWidth=intval(($newHeight / $imgHeight) * $imgWidth); |
|
173 | + } |
|
174 | + // Keep ratio |
|
159 | 175 | } |
160 | 176 | if ($newHeight <= 0) |
161 | 177 | { |
@@ -218,8 +234,7 @@ discard block |
||
218 | 234 | { |
219 | 235 | // Compatibilite image GIF |
220 | 236 | $imgThumb = imagecreate($newWidth, $newHeight); |
221 | - } |
|
222 | - else |
|
237 | + } else |
|
223 | 238 | { |
224 | 239 | $imgThumb = imagecreatetruecolor($newWidth, $newHeight); |
225 | 240 | } |
@@ -254,7 +269,9 @@ discard block |
||
254 | 269 | $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); |
255 | 270 | break; |
256 | 271 | } |
257 | - if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour); |
|
272 | + if (function_exists("imagefill")) { |
|
273 | + imagefill($imgThumb, 0, 0, $trans_colour); |
|
274 | + } |
|
258 | 275 | |
259 | 276 | dol_syslog("dol_imageResizeOrCrop: convert image from ($imgWidth x $imgHeight) at position ($src_x x $src_y) to ($newWidth x $newHeight) as $extImg, newquality=$newquality"); |
260 | 277 | //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
@@ -284,7 +301,9 @@ discard block |
||
284 | 301 | } |
285 | 302 | |
286 | 303 | // Set permissions on file |
287 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
304 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
305 | + @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
306 | + } |
|
288 | 307 | |
289 | 308 | // Free memory. This does not delete image. |
290 | 309 | imagedestroy($img); |
@@ -365,24 +384,20 @@ discard block |
||
365 | 384 | { |
366 | 385 | // Si le fichier n'a pas ete indique |
367 | 386 | return 'ErrorBadParameters'; |
368 | - } |
|
369 | - elseif (! file_exists($file)) |
|
387 | + } elseif (! file_exists($file)) |
|
370 | 388 | { |
371 | 389 | // Si le fichier passe en parametre n'existe pas |
372 | 390 | dol_syslog($langs->trans("ErrorFileNotFound",$file),LOG_ERR); |
373 | 391 | return $langs->trans("ErrorFileNotFound",$file); |
374 | - } |
|
375 | - elseif(image_format_supported($file) < 0) |
|
392 | + } elseif(image_format_supported($file) < 0) |
|
376 | 393 | { |
377 | 394 | dol_syslog('This file '.$file.' does not seem to be an image format file name.',LOG_WARNING); |
378 | 395 | return 'ErrorBadImageFormat'; |
379 | - } |
|
380 | - elseif(!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1){ |
|
396 | + } elseif(!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1){ |
|
381 | 397 | // Si la largeur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) |
382 | 398 | dol_syslog('Wrong value for parameter maxWidth',LOG_ERR); |
383 | 399 | return 'Error: Wrong value for parameter maxWidth'; |
384 | - } |
|
385 | - elseif(!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1){ |
|
400 | + } elseif(!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1){ |
|
386 | 401 | // Si la hauteur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) |
387 | 402 | dol_syslog('Wrong value for parameter maxHeight',LOG_ERR); |
388 | 403 | return 'Error: Wrong value for parameter maxHeight'; |
@@ -394,8 +409,14 @@ discard block |
||
394 | 409 | $imgWidth = $infoImg[0]; // Largeur de l'image |
395 | 410 | $imgHeight = $infoImg[1]; // Hauteur de l'image |
396 | 411 | |
397 | - if ($maxWidth == -1) $maxWidth=$infoImg[0]; // If size is -1, we keep unchanged |
|
398 | - if ($maxHeight == -1) $maxHeight=$infoImg[1]; // If size is -1, we keep unchanged |
|
412 | + if ($maxWidth == -1) { |
|
413 | + $maxWidth=$infoImg[0]; |
|
414 | + } |
|
415 | + // If size is -1, we keep unchanged |
|
416 | + if ($maxHeight == -1) { |
|
417 | + $maxHeight=$infoImg[1]; |
|
418 | + } |
|
419 | + // If size is -1, we keep unchanged |
|
399 | 420 | |
400 | 421 | // Si l'image est plus petite que la largeur et la hauteur max, on ne cree pas de vignette |
401 | 422 | if ($infoImg[0] < $maxWidth && $infoImg[1] < $maxHeight) |
@@ -481,8 +502,7 @@ discard block |
||
481 | 502 | // Si largeur determinante |
482 | 503 | $thumbWidth = $maxWidth; |
483 | 504 | $thumbHeight = $thumbWidth / $imgWhFact; |
484 | - } |
|
485 | - else |
|
505 | + } else |
|
486 | 506 | { |
487 | 507 | // Si hauteur determinante |
488 | 508 | $thumbHeight = $maxHeight; |
@@ -492,15 +512,16 @@ discard block |
||
492 | 512 | $thumbWidth=round($thumbWidth); |
493 | 513 | |
494 | 514 | // Define target format |
495 | - if (empty($targetformat)) $targetformat=$infoImg[2]; |
|
515 | + if (empty($targetformat)) { |
|
516 | + $targetformat=$infoImg[2]; |
|
517 | + } |
|
496 | 518 | |
497 | 519 | // Create empty image |
498 | 520 | if ($targetformat == IMAGETYPE_GIF) |
499 | 521 | { |
500 | 522 | // Compatibilite image GIF |
501 | 523 | $imgThumb = imagecreate($thumbWidth, $thumbHeight); |
502 | - } |
|
503 | - else |
|
524 | + } else |
|
504 | 525 | { |
505 | 526 | $imgThumb = imagecreatetruecolor($thumbWidth, $thumbHeight); |
506 | 527 | } |
@@ -550,7 +571,9 @@ discard block |
||
550 | 571 | $newquality='NU'; |
551 | 572 | break; |
552 | 573 | } |
553 | - if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour); |
|
574 | + if (function_exists("imagefill")) { |
|
575 | + imagefill($imgThumb, 0, 0, $trans_colour); |
|
576 | + } |
|
554 | 577 | |
555 | 578 | dol_syslog("vignette: convert image from ($imgWidth x $imgHeight) to ($thumbWidth x $thumbHeight) as $extImg, newquality=$newquality"); |
556 | 579 | //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee |
@@ -587,7 +610,9 @@ discard block |
||
587 | 610 | } |
588 | 611 | |
589 | 612 | // Set permissions on file |
590 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
613 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
614 | + @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); |
|
615 | + } |
|
591 | 616 | |
592 | 617 | // Free memory. This does not delete image. |
593 | 618 | imagedestroy($img); |
@@ -34,80 +34,80 @@ discard block |
||
34 | 34 | */ |
35 | 35 | function shipping_prepare_head($object) |
36 | 36 | { |
37 | - global $db, $langs, $conf, $user; |
|
37 | + global $db, $langs, $conf, $user; |
|
38 | 38 | |
39 | - // Load translation files required by the page |
|
39 | + // Load translation files required by the page |
|
40 | 40 | $langs->loadLangs(array("sendings","deliveries")); |
41 | 41 | |
42 | - $h = 0; |
|
43 | - $head = array(); |
|
44 | - |
|
45 | - $head[$h][0] = DOL_URL_ROOT."/expedition/card.php?id=".$object->id; |
|
46 | - $head[$h][1] = $langs->trans("SendingCard"); |
|
47 | - $head[$h][2] = 'shipping'; |
|
48 | - $h++; |
|
49 | - |
|
50 | - if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire) |
|
51 | - { |
|
52 | - // delivery link |
|
53 | - $object->fetchObjectLinked($object->id,$object->element); |
|
54 | - if (count($object->linkedObjectsIds['delivery']) > 0) // If there is a delivery |
|
55 | - { |
|
56 | - // Take first one element of array |
|
57 | - $tmp = reset($object->linkedObjectsIds['delivery']); |
|
58 | - |
|
59 | - $head[$h][0] = DOL_URL_ROOT."/livraison/card.php?id=".$tmp; |
|
60 | - $head[$h][1] = $langs->trans("DeliveryCard"); |
|
61 | - $head[$h][2] = 'delivery'; |
|
62 | - $h++; |
|
63 | - } |
|
64 | - } |
|
65 | - |
|
66 | - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
67 | - { |
|
68 | - $objectsrc = $object; |
|
69 | - if ($object->origin == 'commande' && $object->origin_id > 0) |
|
70 | - { |
|
71 | - $objectsrc = new Commande($db); |
|
72 | - $objectsrc->fetch($object->origin_id); |
|
73 | - } |
|
74 | - $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external')); |
|
75 | - $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->id; |
|
76 | - $head[$h][1] = $langs->trans("ContactsAddresses"); |
|
77 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
78 | - $head[$h][2] = 'contact'; |
|
79 | - $h++; |
|
80 | - } |
|
81 | - |
|
82 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
42 | + $h = 0; |
|
43 | + $head = array(); |
|
44 | + |
|
45 | + $head[$h][0] = DOL_URL_ROOT."/expedition/card.php?id=".$object->id; |
|
46 | + $head[$h][1] = $langs->trans("SendingCard"); |
|
47 | + $head[$h][2] = 'shipping'; |
|
48 | + $h++; |
|
49 | + |
|
50 | + if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire) |
|
51 | + { |
|
52 | + // delivery link |
|
53 | + $object->fetchObjectLinked($object->id,$object->element); |
|
54 | + if (count($object->linkedObjectsIds['delivery']) > 0) // If there is a delivery |
|
55 | + { |
|
56 | + // Take first one element of array |
|
57 | + $tmp = reset($object->linkedObjectsIds['delivery']); |
|
58 | + |
|
59 | + $head[$h][0] = DOL_URL_ROOT."/livraison/card.php?id=".$tmp; |
|
60 | + $head[$h][1] = $langs->trans("DeliveryCard"); |
|
61 | + $head[$h][2] = 'delivery'; |
|
62 | + $h++; |
|
63 | + } |
|
64 | + } |
|
65 | + |
|
66 | + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
67 | + { |
|
68 | + $objectsrc = $object; |
|
69 | + if ($object->origin == 'commande' && $object->origin_id > 0) |
|
70 | + { |
|
71 | + $objectsrc = new Commande($db); |
|
72 | + $objectsrc->fetch($object->origin_id); |
|
73 | + } |
|
74 | + $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external')); |
|
75 | + $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->id; |
|
76 | + $head[$h][1] = $langs->trans("ContactsAddresses"); |
|
77 | + if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
78 | + $head[$h][2] = 'contact'; |
|
79 | + $h++; |
|
80 | + } |
|
81 | + |
|
82 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
83 | 83 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
84 | - $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
85 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
84 | + $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
85 | + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
86 | 86 | $nbLinks=Link::count($db, $object->element, $object->id); |
87 | - $head[$h][0] = DOL_URL_ROOT.'/expedition/document.php?id='.$object->id; |
|
88 | - $head[$h][1] = $langs->trans('Documents'); |
|
89 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
90 | - $head[$h][2] = 'documents'; |
|
91 | - $h++; |
|
87 | + $head[$h][0] = DOL_URL_ROOT.'/expedition/document.php?id='.$object->id; |
|
88 | + $head[$h][1] = $langs->trans('Documents'); |
|
89 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
90 | + $head[$h][2] = 'documents'; |
|
91 | + $h++; |
|
92 | 92 | |
93 | 93 | $nbNote = 0; |
94 | 94 | if (!empty($object->note_private)) $nbNote++; |
95 | 95 | if (!empty($object->note_public)) $nbNote++; |
96 | - $head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$object->id; |
|
97 | - $head[$h][1] = $langs->trans("Notes"); |
|
98 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
99 | - $head[$h][2] = 'note'; |
|
100 | - $h++; |
|
101 | - |
|
102 | - // Show more tabs from modules |
|
103 | - // Entries must be declared in modules descriptor with line |
|
96 | + $head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$object->id; |
|
97 | + $head[$h][1] = $langs->trans("Notes"); |
|
98 | + if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
99 | + $head[$h][2] = 'note'; |
|
100 | + $h++; |
|
101 | + |
|
102 | + // Show more tabs from modules |
|
103 | + // Entries must be declared in modules descriptor with line |
|
104 | 104 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
105 | 105 | // $this->tabs = array('entity:-tabname); to remove a tab |
106 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery'); |
|
106 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery'); |
|
107 | 107 | |
108 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery','remove'); |
|
108 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery','remove'); |
|
109 | 109 | |
110 | - return $head; |
|
110 | + return $head; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | |
@@ -119,39 +119,39 @@ discard block |
||
119 | 119 | */ |
120 | 120 | function delivery_prepare_head($object) |
121 | 121 | { |
122 | - global $langs, $conf, $user; |
|
122 | + global $langs, $conf, $user; |
|
123 | 123 | |
124 | - // Load translation files required by the page |
|
124 | + // Load translation files required by the page |
|
125 | 125 | $langs->loadLangs(array("sendings","deliveries")); |
126 | 126 | |
127 | - $h = 0; |
|
128 | - $head = array(); |
|
129 | - |
|
130 | - if ($conf->expedition_bon->enabled && $user->rights->expedition->lire) |
|
131 | - { |
|
132 | - $head[$h][0] = DOL_URL_ROOT."/expedition/card.php?id=".$object->origin_id; |
|
133 | - $head[$h][1] = $langs->trans("SendingCard"); |
|
134 | - $head[$h][2] = 'shipping'; |
|
135 | - $h++; |
|
136 | - } |
|
137 | - |
|
138 | - $head[$h][0] = DOL_URL_ROOT."/livraison/card.php?id=".$object->id; |
|
139 | - $head[$h][1] = $langs->trans("DeliveryCard"); |
|
140 | - $head[$h][2] = 'delivery'; |
|
141 | - $h++; |
|
142 | - |
|
143 | - $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->origin_id; |
|
144 | - $head[$h][1] = $langs->trans("ContactsAddresses"); |
|
145 | - $head[$h][2] = 'contact'; |
|
146 | - $h++; |
|
147 | - |
|
148 | - $head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$object->origin_id; |
|
149 | - $head[$h][1] = $langs->trans("Notes"); |
|
150 | - $head[$h][2] = 'note'; |
|
151 | - $h++; |
|
152 | - |
|
153 | - // Show more tabs from modules |
|
154 | - // Entries must be declared in modules descriptor with line |
|
127 | + $h = 0; |
|
128 | + $head = array(); |
|
129 | + |
|
130 | + if ($conf->expedition_bon->enabled && $user->rights->expedition->lire) |
|
131 | + { |
|
132 | + $head[$h][0] = DOL_URL_ROOT."/expedition/card.php?id=".$object->origin_id; |
|
133 | + $head[$h][1] = $langs->trans("SendingCard"); |
|
134 | + $head[$h][2] = 'shipping'; |
|
135 | + $h++; |
|
136 | + } |
|
137 | + |
|
138 | + $head[$h][0] = DOL_URL_ROOT."/livraison/card.php?id=".$object->id; |
|
139 | + $head[$h][1] = $langs->trans("DeliveryCard"); |
|
140 | + $head[$h][2] = 'delivery'; |
|
141 | + $h++; |
|
142 | + |
|
143 | + $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->origin_id; |
|
144 | + $head[$h][1] = $langs->trans("ContactsAddresses"); |
|
145 | + $head[$h][2] = 'contact'; |
|
146 | + $h++; |
|
147 | + |
|
148 | + $head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$object->origin_id; |
|
149 | + $head[$h][1] = $langs->trans("Notes"); |
|
150 | + $head[$h][2] = 'note'; |
|
151 | + $h++; |
|
152 | + |
|
153 | + // Show more tabs from modules |
|
154 | + // Entries must be declared in modules descriptor with line |
|
155 | 155 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
156 | 156 | // $this->tabs = array('entity:-tabname); to remove a tab |
157 | 157 | // complete_head_from_modules use $object->id for this link so we temporary change it |
@@ -160,10 +160,10 @@ discard block |
||
160 | 160 | |
161 | 161 | complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery'); |
162 | 162 | |
163 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery','remove'); |
|
163 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery','remove'); |
|
164 | 164 | |
165 | - $object->id = $tmpObjectId; |
|
166 | - return $head; |
|
165 | + $object->id = $tmpObjectId; |
|
166 | + return $head; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -176,179 +176,179 @@ discard block |
||
176 | 176 | */ |
177 | 177 | function show_list_sending_receive($origin,$origin_id,$filter='') |
178 | 178 | { |
179 | - global $db, $conf, $langs, $bc; |
|
180 | - global $form; |
|
181 | - |
|
182 | - $product_static=new Product($db); |
|
183 | - $expedition=new Expedition($db); |
|
184 | - $warehousestatic=new Entrepot($db); |
|
185 | - |
|
186 | - $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end,"; |
|
187 | - $sql.= " ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id,"; |
|
188 | - $sql.= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,"; |
|
189 | - //if ($conf->livraison_bon->enabled) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received,"; |
|
190 | - $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch,'; |
|
191 | - $sql.= ' p.description as product_desc'; |
|
192 | - $sql.= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; |
|
193 | - $sql.= ", ".MAIN_DB_PREFIX."expedition as e"; |
|
194 | - $sql.= ", ".MAIN_DB_PREFIX.$origin."det as obj"; |
|
195 | - //if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid AND obj.rowid = ld.fk_origin_line"; |
|
196 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; |
|
197 | - //TODO Add link to expeditiondet_batch |
|
198 | - $sql.= " WHERE e.entity IN (".getEntity('expedition').")"; |
|
199 | - $sql.= " AND obj.fk_".$origin." = ".$origin_id; |
|
200 | - $sql.= " AND obj.rowid = ed.fk_origin_line"; |
|
201 | - $sql.= " AND ed.fk_expedition = e.rowid"; |
|
202 | - if ($filter) $sql.= $filter; |
|
203 | - |
|
204 | - $sql.= " ORDER BY obj.fk_product"; |
|
205 | - |
|
206 | - dol_syslog("show_list_sending_receive", LOG_DEBUG); |
|
207 | - $resql = $db->query($sql); |
|
208 | - if ($resql) |
|
209 | - { |
|
210 | - $num = $db->num_rows($resql); |
|
211 | - $i = 0; |
|
212 | - |
|
213 | - if ($num) |
|
214 | - { |
|
215 | - if ($filter) print load_fiche_titre($langs->trans("OtherSendingsForSameOrder")); |
|
216 | - else print load_fiche_titre($langs->trans("SendingsAndReceivingForSameOrder")); |
|
217 | - |
|
218 | - print '<table class="liste" width="100%">'; |
|
219 | - print '<tr class="liste_titre">'; |
|
220 | - //print '<td align="left">'.$langs->trans("QtyOrdered").'</td>'; |
|
221 | - print '<td align="left">'.$langs->trans("SendingSheet").'</td>'; |
|
222 | - print '<td align="left">'.$langs->trans("Description").'</td>'; |
|
223 | - print '<td align="center">'.$langs->trans("DateCreation").'</td>'; |
|
224 | - print '<td align="center">'.$langs->trans("DateDeliveryPlanned").'</td>'; |
|
225 | - print '<td align="center">'.$langs->trans("QtyPreparedOrShipped").'</td>'; |
|
226 | - if (! empty($conf->stock->enabled)) |
|
227 | - { |
|
179 | + global $db, $conf, $langs, $bc; |
|
180 | + global $form; |
|
181 | + |
|
182 | + $product_static=new Product($db); |
|
183 | + $expedition=new Expedition($db); |
|
184 | + $warehousestatic=new Entrepot($db); |
|
185 | + |
|
186 | + $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end,"; |
|
187 | + $sql.= " ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id,"; |
|
188 | + $sql.= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,"; |
|
189 | + //if ($conf->livraison_bon->enabled) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received,"; |
|
190 | + $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch,'; |
|
191 | + $sql.= ' p.description as product_desc'; |
|
192 | + $sql.= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; |
|
193 | + $sql.= ", ".MAIN_DB_PREFIX."expedition as e"; |
|
194 | + $sql.= ", ".MAIN_DB_PREFIX.$origin."det as obj"; |
|
195 | + //if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid AND obj.rowid = ld.fk_origin_line"; |
|
196 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; |
|
197 | + //TODO Add link to expeditiondet_batch |
|
198 | + $sql.= " WHERE e.entity IN (".getEntity('expedition').")"; |
|
199 | + $sql.= " AND obj.fk_".$origin." = ".$origin_id; |
|
200 | + $sql.= " AND obj.rowid = ed.fk_origin_line"; |
|
201 | + $sql.= " AND ed.fk_expedition = e.rowid"; |
|
202 | + if ($filter) $sql.= $filter; |
|
203 | + |
|
204 | + $sql.= " ORDER BY obj.fk_product"; |
|
205 | + |
|
206 | + dol_syslog("show_list_sending_receive", LOG_DEBUG); |
|
207 | + $resql = $db->query($sql); |
|
208 | + if ($resql) |
|
209 | + { |
|
210 | + $num = $db->num_rows($resql); |
|
211 | + $i = 0; |
|
212 | + |
|
213 | + if ($num) |
|
214 | + { |
|
215 | + if ($filter) print load_fiche_titre($langs->trans("OtherSendingsForSameOrder")); |
|
216 | + else print load_fiche_titre($langs->trans("SendingsAndReceivingForSameOrder")); |
|
217 | + |
|
218 | + print '<table class="liste" width="100%">'; |
|
219 | + print '<tr class="liste_titre">'; |
|
220 | + //print '<td align="left">'.$langs->trans("QtyOrdered").'</td>'; |
|
221 | + print '<td align="left">'.$langs->trans("SendingSheet").'</td>'; |
|
222 | + print '<td align="left">'.$langs->trans("Description").'</td>'; |
|
223 | + print '<td align="center">'.$langs->trans("DateCreation").'</td>'; |
|
224 | + print '<td align="center">'.$langs->trans("DateDeliveryPlanned").'</td>'; |
|
225 | + print '<td align="center">'.$langs->trans("QtyPreparedOrShipped").'</td>'; |
|
226 | + if (! empty($conf->stock->enabled)) |
|
227 | + { |
|
228 | 228 | print '<td>'.$langs->trans("Warehouse").'</td>'; |
229 | - } |
|
230 | - /*TODO Add link to expeditiondet_batch |
|
229 | + } |
|
230 | + /*TODO Add link to expeditiondet_batch |
|
231 | 231 | if (! empty($conf->productbatch->enabled)) |
232 | 232 | { |
233 | 233 | print '<td>'; |
234 | 234 | print '</td>'; |
235 | 235 | }*/ |
236 | - if (! empty($conf->livraison_bon->enabled)) |
|
237 | - { |
|
238 | - print '<td>'.$langs->trans("DeliveryOrder").'</td>'; |
|
239 | - //print '<td align="center">'.$langs->trans("QtyReceived").'</td>'; |
|
240 | - print '<td align="right">'.$langs->trans("DeliveryDate").'</td>'; |
|
241 | - } |
|
242 | - print "</tr>\n"; |
|
243 | - |
|
244 | - while ($i < $num) |
|
245 | - { |
|
246 | - $objp = $db->fetch_object($resql); |
|
247 | - |
|
248 | - print '<tr class="oddeven">'; |
|
249 | - |
|
250 | - // Sending id |
|
251 | - print '<td align="left" class="nowrap">'; |
|
252 | - print '<a href="'.DOL_URL_ROOT.'/expedition/card.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->exp_ref.'<a>'; |
|
253 | - print '</td>'; |
|
254 | - |
|
255 | - // Description |
|
256 | - if ($objp->fk_product > 0) |
|
257 | - { |
|
258 | - // Define output language |
|
259 | - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) |
|
260 | - { |
|
261 | - $object = new $origin($db); |
|
262 | - $object->fetch($origin_id); |
|
263 | - $object->fetch_thirdparty(); |
|
264 | - |
|
265 | - $prod = new Product($db); |
|
266 | - $prod->id=$objp->fk_product; |
|
267 | - $prod->getMultiLangs(); |
|
268 | - |
|
269 | - $outputlangs = $langs; |
|
270 | - $newlang=''; |
|
271 | - if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; |
|
272 | - if (empty($newlang)) $newlang=$object->thirdparty->default_lang; |
|
273 | - if (! empty($newlang)) |
|
274 | - { |
|
275 | - $outputlangs = new Translate("",$conf); |
|
276 | - $outputlangs->setDefaultLang($newlang); |
|
277 | - } |
|
278 | - |
|
279 | - $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; |
|
280 | - } |
|
281 | - else |
|
282 | - { |
|
283 | - $label = (! empty($objp->label)?$objp->label:$objp->product_label); |
|
284 | - } |
|
285 | - |
|
286 | - print '<td>'; |
|
287 | - |
|
288 | - // Show product and description |
|
289 | - $product_static->type=$objp->fk_product_type; |
|
290 | - $product_static->id=$objp->fk_product; |
|
291 | - $product_static->ref=$objp->ref; |
|
292 | - $product_static->status_batch=$objp->product_tobatch; |
|
293 | - $text=$product_static->getNomUrl(1); |
|
294 | - $text.= ' - '.$label; |
|
295 | - $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description)); |
|
296 | - print $form->textwithtooltip($text,$description,3,'','',$i); |
|
297 | - |
|
298 | - // Show range |
|
299 | - print_date_range($objp->date_start,$objp->date_end); |
|
300 | - |
|
301 | - // Add description in form |
|
302 | - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) |
|
303 | - { |
|
304 | - print (! empty($objp->description) && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):''; |
|
305 | - } |
|
306 | - |
|
307 | - print '</td>'; |
|
308 | - } |
|
309 | - else |
|
310 | - { |
|
311 | - print "<td>"; |
|
312 | - if ($objp->fk_product_type==1) $text = img_object($langs->trans('Service'),'service'); |
|
313 | - else $text = img_object($langs->trans('Product'),'product'); |
|
314 | - |
|
315 | - if (! empty($objp->label)) { |
|
316 | - $text.= ' <strong>'.$objp->label.'</strong>'; |
|
317 | - print $form->textwithtooltip($text,$objp->description,3,'','',$i); |
|
318 | - } else { |
|
319 | - print $text.' '.nl2br($objp->description); |
|
320 | - } |
|
321 | - |
|
322 | - // Show range |
|
323 | - print_date_range($objp->date_start,$objp->date_end); |
|
324 | - print "</td>\n"; |
|
325 | - } |
|
326 | - |
|
327 | - //print '<td align="center">'.$objp->qty_asked.'</td>'; |
|
328 | - |
|
329 | - // Date creation |
|
330 | - print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_creation),'day').'</td>'; |
|
331 | - |
|
332 | - // Date shipping creation |
|
333 | - print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_delivery),'day').'</td>'; |
|
334 | - |
|
335 | - // Qty shipped |
|
336 | - print '<td align="center">'.$objp->qty_shipped.'</td>'; |
|
337 | - |
|
338 | - // Warehouse |
|
339 | - if (! empty($conf->stock->enabled)) |
|
340 | - { |
|
341 | - print '<td>'; |
|
342 | - if ($objp->warehouse_id > 0) |
|
343 | - { |
|
344 | - $warehousestatic->fetch($objp->warehouse_id); |
|
345 | - print $warehousestatic->getNomUrl(1); |
|
346 | - } |
|
347 | - print '</td>'; |
|
348 | - } |
|
349 | - |
|
350 | - // Batch number managment |
|
351 | - /*TODO Add link to expeditiondet_batch |
|
236 | + if (! empty($conf->livraison_bon->enabled)) |
|
237 | + { |
|
238 | + print '<td>'.$langs->trans("DeliveryOrder").'</td>'; |
|
239 | + //print '<td align="center">'.$langs->trans("QtyReceived").'</td>'; |
|
240 | + print '<td align="right">'.$langs->trans("DeliveryDate").'</td>'; |
|
241 | + } |
|
242 | + print "</tr>\n"; |
|
243 | + |
|
244 | + while ($i < $num) |
|
245 | + { |
|
246 | + $objp = $db->fetch_object($resql); |
|
247 | + |
|
248 | + print '<tr class="oddeven">'; |
|
249 | + |
|
250 | + // Sending id |
|
251 | + print '<td align="left" class="nowrap">'; |
|
252 | + print '<a href="'.DOL_URL_ROOT.'/expedition/card.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->exp_ref.'<a>'; |
|
253 | + print '</td>'; |
|
254 | + |
|
255 | + // Description |
|
256 | + if ($objp->fk_product > 0) |
|
257 | + { |
|
258 | + // Define output language |
|
259 | + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) |
|
260 | + { |
|
261 | + $object = new $origin($db); |
|
262 | + $object->fetch($origin_id); |
|
263 | + $object->fetch_thirdparty(); |
|
264 | + |
|
265 | + $prod = new Product($db); |
|
266 | + $prod->id=$objp->fk_product; |
|
267 | + $prod->getMultiLangs(); |
|
268 | + |
|
269 | + $outputlangs = $langs; |
|
270 | + $newlang=''; |
|
271 | + if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; |
|
272 | + if (empty($newlang)) $newlang=$object->thirdparty->default_lang; |
|
273 | + if (! empty($newlang)) |
|
274 | + { |
|
275 | + $outputlangs = new Translate("",$conf); |
|
276 | + $outputlangs->setDefaultLang($newlang); |
|
277 | + } |
|
278 | + |
|
279 | + $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; |
|
280 | + } |
|
281 | + else |
|
282 | + { |
|
283 | + $label = (! empty($objp->label)?$objp->label:$objp->product_label); |
|
284 | + } |
|
285 | + |
|
286 | + print '<td>'; |
|
287 | + |
|
288 | + // Show product and description |
|
289 | + $product_static->type=$objp->fk_product_type; |
|
290 | + $product_static->id=$objp->fk_product; |
|
291 | + $product_static->ref=$objp->ref; |
|
292 | + $product_static->status_batch=$objp->product_tobatch; |
|
293 | + $text=$product_static->getNomUrl(1); |
|
294 | + $text.= ' - '.$label; |
|
295 | + $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description)); |
|
296 | + print $form->textwithtooltip($text,$description,3,'','',$i); |
|
297 | + |
|
298 | + // Show range |
|
299 | + print_date_range($objp->date_start,$objp->date_end); |
|
300 | + |
|
301 | + // Add description in form |
|
302 | + if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) |
|
303 | + { |
|
304 | + print (! empty($objp->description) && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):''; |
|
305 | + } |
|
306 | + |
|
307 | + print '</td>'; |
|
308 | + } |
|
309 | + else |
|
310 | + { |
|
311 | + print "<td>"; |
|
312 | + if ($objp->fk_product_type==1) $text = img_object($langs->trans('Service'),'service'); |
|
313 | + else $text = img_object($langs->trans('Product'),'product'); |
|
314 | + |
|
315 | + if (! empty($objp->label)) { |
|
316 | + $text.= ' <strong>'.$objp->label.'</strong>'; |
|
317 | + print $form->textwithtooltip($text,$objp->description,3,'','',$i); |
|
318 | + } else { |
|
319 | + print $text.' '.nl2br($objp->description); |
|
320 | + } |
|
321 | + |
|
322 | + // Show range |
|
323 | + print_date_range($objp->date_start,$objp->date_end); |
|
324 | + print "</td>\n"; |
|
325 | + } |
|
326 | + |
|
327 | + //print '<td align="center">'.$objp->qty_asked.'</td>'; |
|
328 | + |
|
329 | + // Date creation |
|
330 | + print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_creation),'day').'</td>'; |
|
331 | + |
|
332 | + // Date shipping creation |
|
333 | + print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_delivery),'day').'</td>'; |
|
334 | + |
|
335 | + // Qty shipped |
|
336 | + print '<td align="center">'.$objp->qty_shipped.'</td>'; |
|
337 | + |
|
338 | + // Warehouse |
|
339 | + if (! empty($conf->stock->enabled)) |
|
340 | + { |
|
341 | + print '<td>'; |
|
342 | + if ($objp->warehouse_id > 0) |
|
343 | + { |
|
344 | + $warehousestatic->fetch($objp->warehouse_id); |
|
345 | + print $warehousestatic->getNomUrl(1); |
|
346 | + } |
|
347 | + print '</td>'; |
|
348 | + } |
|
349 | + |
|
350 | + // Batch number managment |
|
351 | + /*TODO Add link to expeditiondet_batch |
|
352 | 352 | if (! empty($conf->productbatch->enabled)) |
353 | 353 | { |
354 | 354 | var_dump($objp->edrowid); |
@@ -379,60 +379,60 @@ discard block |
||
379 | 379 | } |
380 | 380 | }*/ |
381 | 381 | |
382 | - // Informations on receipt |
|
383 | - if (! empty($conf->livraison_bon->enabled)) |
|
384 | - { |
|
385 | - include_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php'; |
|
386 | - $expedition->id=$objp->sendingid; |
|
387 | - $expedition->fetchObjectLinked($expedition->id,$expedition->element); |
|
388 | - //var_dump($expedition->linkedObjects); |
|
389 | - |
|
390 | - $receiving=''; |
|
391 | - if (count($expedition->linkedObjects['delivery']) > 0) $receiving=reset($expedition->linkedObjects['delivery']); // Take first link |
|
392 | - |
|
393 | - if (! empty($receiving)) |
|
394 | - { |
|
395 | - // $expedition->fk_origin_line = id of det line of order |
|
396 | - // $receiving->fk_origin_line = id of det line of order |
|
397 | - // $receiving->origin may be 'shipping' |
|
398 | - // $receiving->origin_id may be id of shipping |
|
399 | - |
|
400 | - // Ref |
|
401 | - print '<td>'; |
|
402 | - print $receiving->getNomUrl($db); |
|
403 | - //print '<a href="'.DOL_URL_ROOT.'/livraison/card.php?id='.$livraison_id.'">'.img_object($langs->trans("ShowReceiving"),'sending').' '.$objp->livraison_ref.'<a>'; |
|
404 | - print '</td>'; |
|
405 | - // Qty received |
|
406 | - //print '<td align="center">'; |
|
407 | - // TODO No solution for the moment to link a line det of receipt with a line det of shipping, |
|
408 | - // so no way to know the qty received for this line of shipping. |
|
409 | - //print $langs->trans("FeatureNotYetAvailable"); |
|
410 | - //print '</td>'; |
|
411 | - // Date shipping real |
|
412 | - print '<td align="right">'; |
|
413 | - print dol_print_date($receiving->date_delivery,'day'); |
|
414 | - print '</td>'; |
|
415 | - } |
|
416 | - else |
|
417 | - { |
|
418 | - //print '<td> </td>'; |
|
419 | - print '<td> </td>'; |
|
420 | - print '<td> </td>'; |
|
421 | - } |
|
422 | - } |
|
423 | - print '</tr>'; |
|
424 | - $i++; |
|
425 | - } |
|
426 | - |
|
427 | - print '</table>'; |
|
428 | - } |
|
429 | - $db->free($resql); |
|
430 | - } |
|
431 | - else |
|
432 | - { |
|
433 | - dol_print_error($db); |
|
434 | - } |
|
435 | - |
|
436 | - return 1; |
|
382 | + // Informations on receipt |
|
383 | + if (! empty($conf->livraison_bon->enabled)) |
|
384 | + { |
|
385 | + include_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php'; |
|
386 | + $expedition->id=$objp->sendingid; |
|
387 | + $expedition->fetchObjectLinked($expedition->id,$expedition->element); |
|
388 | + //var_dump($expedition->linkedObjects); |
|
389 | + |
|
390 | + $receiving=''; |
|
391 | + if (count($expedition->linkedObjects['delivery']) > 0) $receiving=reset($expedition->linkedObjects['delivery']); // Take first link |
|
392 | + |
|
393 | + if (! empty($receiving)) |
|
394 | + { |
|
395 | + // $expedition->fk_origin_line = id of det line of order |
|
396 | + // $receiving->fk_origin_line = id of det line of order |
|
397 | + // $receiving->origin may be 'shipping' |
|
398 | + // $receiving->origin_id may be id of shipping |
|
399 | + |
|
400 | + // Ref |
|
401 | + print '<td>'; |
|
402 | + print $receiving->getNomUrl($db); |
|
403 | + //print '<a href="'.DOL_URL_ROOT.'/livraison/card.php?id='.$livraison_id.'">'.img_object($langs->trans("ShowReceiving"),'sending').' '.$objp->livraison_ref.'<a>'; |
|
404 | + print '</td>'; |
|
405 | + // Qty received |
|
406 | + //print '<td align="center">'; |
|
407 | + // TODO No solution for the moment to link a line det of receipt with a line det of shipping, |
|
408 | + // so no way to know the qty received for this line of shipping. |
|
409 | + //print $langs->trans("FeatureNotYetAvailable"); |
|
410 | + //print '</td>'; |
|
411 | + // Date shipping real |
|
412 | + print '<td align="right">'; |
|
413 | + print dol_print_date($receiving->date_delivery,'day'); |
|
414 | + print '</td>'; |
|
415 | + } |
|
416 | + else |
|
417 | + { |
|
418 | + //print '<td> </td>'; |
|
419 | + print '<td> </td>'; |
|
420 | + print '<td> </td>'; |
|
421 | + } |
|
422 | + } |
|
423 | + print '</tr>'; |
|
424 | + $i++; |
|
425 | + } |
|
426 | + |
|
427 | + print '</table>'; |
|
428 | + } |
|
429 | + $db->free($resql); |
|
430 | + } |
|
431 | + else |
|
432 | + { |
|
433 | + dol_print_error($db); |
|
434 | + } |
|
435 | + |
|
436 | + return 1; |
|
437 | 437 | } |
438 | 438 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | global $db, $langs, $conf, $user; |
38 | 38 | |
39 | 39 | // Load translation files required by the page |
40 | - $langs->loadLangs(array("sendings","deliveries")); |
|
40 | + $langs->loadLangs(array("sendings", "deliveries")); |
|
41 | 41 | |
42 | 42 | $h = 0; |
43 | 43 | $head = array(); |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire) |
51 | 51 | { |
52 | 52 | // delivery link |
53 | - $object->fetchObjectLinked($object->id,$object->element); |
|
54 | - if (count($object->linkedObjectsIds['delivery']) > 0) // If there is a delivery |
|
53 | + $object->fetchObjectLinked($object->id, $object->element); |
|
54 | + if (count($object->linkedObjectsIds['delivery']) > 0) // If there is a delivery |
|
55 | 55 | { |
56 | 56 | // Take first one element of array |
57 | 57 | $tmp = reset($object->linkedObjectsIds['delivery']); |
@@ -71,22 +71,22 @@ discard block |
||
71 | 71 | $objectsrc = new Commande($db); |
72 | 72 | $objectsrc->fetch($object->origin_id); |
73 | 73 | } |
74 | - $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external')); |
|
74 | + $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external')); |
|
75 | 75 | $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->id; |
76 | 76 | $head[$h][1] = $langs->trans("ContactsAddresses"); |
77 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
77 | + if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>'; |
|
78 | 78 | $head[$h][2] = 'contact'; |
79 | 79 | $h++; |
80 | 80 | } |
81 | 81 | |
82 | 82 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
83 | 83 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
84 | - $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
85 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
86 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
84 | + $upload_dir = $conf->commande->dir_output."/".dol_sanitizeFileName($object->ref); |
|
85 | + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
86 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
87 | 87 | $head[$h][0] = DOL_URL_ROOT.'/expedition/document.php?id='.$object->id; |
88 | 88 | $head[$h][1] = $langs->trans('Documents'); |
89 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
89 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
90 | 90 | $head[$h][2] = 'documents'; |
91 | 91 | $h++; |
92 | 92 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | if (!empty($object->note_public)) $nbNote++; |
96 | 96 | $head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$object->id; |
97 | 97 | $head[$h][1] = $langs->trans("Notes"); |
98 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
98 | + if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>'; |
|
99 | 99 | $head[$h][2] = 'note'; |
100 | 100 | $h++; |
101 | 101 | |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | // Entries must be declared in modules descriptor with line |
104 | 104 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
105 | 105 | // $this->tabs = array('entity:-tabname); to remove a tab |
106 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery'); |
|
106 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery'); |
|
107 | 107 | |
108 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery','remove'); |
|
108 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery', 'remove'); |
|
109 | 109 | |
110 | 110 | return $head; |
111 | 111 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | global $langs, $conf, $user; |
123 | 123 | |
124 | 124 | // Load translation files required by the page |
125 | - $langs->loadLangs(array("sendings","deliveries")); |
|
125 | + $langs->loadLangs(array("sendings", "deliveries")); |
|
126 | 126 | |
127 | 127 | $h = 0; |
128 | 128 | $head = array(); |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | $tmpObjectId = $object->id; |
159 | 159 | $object->id = $object->origin_id; |
160 | 160 | |
161 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery'); |
|
161 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery'); |
|
162 | 162 | |
163 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery','remove'); |
|
163 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery', 'remove'); |
|
164 | 164 | |
165 | 165 | $object->id = $tmpObjectId; |
166 | 166 | return $head; |
@@ -174,34 +174,34 @@ discard block |
||
174 | 174 | * @param string $filter Filter |
175 | 175 | * @return int <0 if KO, >0 if OK |
176 | 176 | */ |
177 | -function show_list_sending_receive($origin,$origin_id,$filter='') |
|
177 | +function show_list_sending_receive($origin, $origin_id, $filter = '') |
|
178 | 178 | { |
179 | 179 | global $db, $conf, $langs, $bc; |
180 | 180 | global $form; |
181 | 181 | |
182 | - $product_static=new Product($db); |
|
183 | - $expedition=new Expedition($db); |
|
184 | - $warehousestatic=new Entrepot($db); |
|
182 | + $product_static = new Product($db); |
|
183 | + $expedition = new Expedition($db); |
|
184 | + $warehousestatic = new Entrepot($db); |
|
185 | 185 | |
186 | 186 | $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end,"; |
187 | - $sql.= " ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id,"; |
|
188 | - $sql.= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,"; |
|
187 | + $sql .= " ed.rowid as edrowid, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot as warehouse_id,"; |
|
188 | + $sql .= " e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,"; |
|
189 | 189 | //if ($conf->livraison_bon->enabled) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received,"; |
190 | - $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch,'; |
|
191 | - $sql.= ' p.description as product_desc'; |
|
192 | - $sql.= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; |
|
193 | - $sql.= ", ".MAIN_DB_PREFIX."expedition as e"; |
|
194 | - $sql.= ", ".MAIN_DB_PREFIX.$origin."det as obj"; |
|
190 | + $sql .= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch,'; |
|
191 | + $sql .= ' p.description as product_desc'; |
|
192 | + $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; |
|
193 | + $sql .= ", ".MAIN_DB_PREFIX."expedition as e"; |
|
194 | + $sql .= ", ".MAIN_DB_PREFIX.$origin."det as obj"; |
|
195 | 195 | //if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid AND obj.rowid = ld.fk_origin_line"; |
196 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; |
|
196 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; |
|
197 | 197 | //TODO Add link to expeditiondet_batch |
198 | - $sql.= " WHERE e.entity IN (".getEntity('expedition').")"; |
|
199 | - $sql.= " AND obj.fk_".$origin." = ".$origin_id; |
|
200 | - $sql.= " AND obj.rowid = ed.fk_origin_line"; |
|
201 | - $sql.= " AND ed.fk_expedition = e.rowid"; |
|
202 | - if ($filter) $sql.= $filter; |
|
198 | + $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; |
|
199 | + $sql .= " AND obj.fk_".$origin." = ".$origin_id; |
|
200 | + $sql .= " AND obj.rowid = ed.fk_origin_line"; |
|
201 | + $sql .= " AND ed.fk_expedition = e.rowid"; |
|
202 | + if ($filter) $sql .= $filter; |
|
203 | 203 | |
204 | - $sql.= " ORDER BY obj.fk_product"; |
|
204 | + $sql .= " ORDER BY obj.fk_product"; |
|
205 | 205 | |
206 | 206 | dol_syslog("show_list_sending_receive", LOG_DEBUG); |
207 | 207 | $resql = $db->query($sql); |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | print '<td align="center">'.$langs->trans("DateCreation").'</td>'; |
224 | 224 | print '<td align="center">'.$langs->trans("DateDeliveryPlanned").'</td>'; |
225 | 225 | print '<td align="center">'.$langs->trans("QtyPreparedOrShipped").'</td>'; |
226 | - if (! empty($conf->stock->enabled)) |
|
226 | + if (!empty($conf->stock->enabled)) |
|
227 | 227 | { |
228 | 228 | print '<td>'.$langs->trans("Warehouse").'</td>'; |
229 | 229 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | print '<td>'; |
234 | 234 | print '</td>'; |
235 | 235 | }*/ |
236 | - if (! empty($conf->livraison_bon->enabled)) |
|
236 | + if (!empty($conf->livraison_bon->enabled)) |
|
237 | 237 | { |
238 | 238 | print '<td>'.$langs->trans("DeliveryOrder").'</td>'; |
239 | 239 | //print '<td align="center">'.$langs->trans("QtyReceived").'</td>'; |
@@ -249,59 +249,59 @@ discard block |
||
249 | 249 | |
250 | 250 | // Sending id |
251 | 251 | print '<td align="left" class="nowrap">'; |
252 | - print '<a href="'.DOL_URL_ROOT.'/expedition/card.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->exp_ref.'<a>'; |
|
252 | + print '<a href="'.DOL_URL_ROOT.'/expedition/card.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"), 'sending').' '.$objp->exp_ref.'<a>'; |
|
253 | 253 | print '</td>'; |
254 | 254 | |
255 | 255 | // Description |
256 | 256 | if ($objp->fk_product > 0) |
257 | 257 | { |
258 | 258 | // Define output language |
259 | - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) |
|
259 | + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) |
|
260 | 260 | { |
261 | 261 | $object = new $origin($db); |
262 | 262 | $object->fetch($origin_id); |
263 | 263 | $object->fetch_thirdparty(); |
264 | 264 | |
265 | 265 | $prod = new Product($db); |
266 | - $prod->id=$objp->fk_product; |
|
266 | + $prod->id = $objp->fk_product; |
|
267 | 267 | $prod->getMultiLangs(); |
268 | 268 | |
269 | 269 | $outputlangs = $langs; |
270 | - $newlang=''; |
|
271 | - if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; |
|
272 | - if (empty($newlang)) $newlang=$object->thirdparty->default_lang; |
|
273 | - if (! empty($newlang)) |
|
270 | + $newlang = ''; |
|
271 | + if (empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; |
|
272 | + if (empty($newlang)) $newlang = $object->thirdparty->default_lang; |
|
273 | + if (!empty($newlang)) |
|
274 | 274 | { |
275 | - $outputlangs = new Translate("",$conf); |
|
275 | + $outputlangs = new Translate("", $conf); |
|
276 | 276 | $outputlangs->setDefaultLang($newlang); |
277 | 277 | } |
278 | 278 | |
279 | - $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; |
|
279 | + $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; |
|
280 | 280 | } |
281 | 281 | else |
282 | 282 | { |
283 | - $label = (! empty($objp->label)?$objp->label:$objp->product_label); |
|
283 | + $label = (!empty($objp->label) ? $objp->label : $objp->product_label); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | print '<td>'; |
287 | 287 | |
288 | 288 | // Show product and description |
289 | - $product_static->type=$objp->fk_product_type; |
|
290 | - $product_static->id=$objp->fk_product; |
|
291 | - $product_static->ref=$objp->ref; |
|
292 | - $product_static->status_batch=$objp->product_tobatch; |
|
293 | - $text=$product_static->getNomUrl(1); |
|
294 | - $text.= ' - '.$label; |
|
295 | - $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description)); |
|
296 | - print $form->textwithtooltip($text,$description,3,'','',$i); |
|
289 | + $product_static->type = $objp->fk_product_type; |
|
290 | + $product_static->id = $objp->fk_product; |
|
291 | + $product_static->ref = $objp->ref; |
|
292 | + $product_static->status_batch = $objp->product_tobatch; |
|
293 | + $text = $product_static->getNomUrl(1); |
|
294 | + $text .= ' - '.$label; |
|
295 | + $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($objp->description)); |
|
296 | + print $form->textwithtooltip($text, $description, 3, '', '', $i); |
|
297 | 297 | |
298 | 298 | // Show range |
299 | - print_date_range($objp->date_start,$objp->date_end); |
|
299 | + print_date_range($objp->date_start, $objp->date_end); |
|
300 | 300 | |
301 | 301 | // Add description in form |
302 | - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) |
|
302 | + if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) |
|
303 | 303 | { |
304 | - print (! empty($objp->description) && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):''; |
|
304 | + print (!empty($objp->description) && $objp->description != $objp->product) ? '<br>'.dol_htmlentitiesbr($objp->description) : ''; |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | print '</td>'; |
@@ -309,34 +309,34 @@ discard block |
||
309 | 309 | else |
310 | 310 | { |
311 | 311 | print "<td>"; |
312 | - if ($objp->fk_product_type==1) $text = img_object($langs->trans('Service'),'service'); |
|
313 | - else $text = img_object($langs->trans('Product'),'product'); |
|
312 | + if ($objp->fk_product_type == 1) $text = img_object($langs->trans('Service'), 'service'); |
|
313 | + else $text = img_object($langs->trans('Product'), 'product'); |
|
314 | 314 | |
315 | - if (! empty($objp->label)) { |
|
316 | - $text.= ' <strong>'.$objp->label.'</strong>'; |
|
317 | - print $form->textwithtooltip($text,$objp->description,3,'','',$i); |
|
315 | + if (!empty($objp->label)) { |
|
316 | + $text .= ' <strong>'.$objp->label.'</strong>'; |
|
317 | + print $form->textwithtooltip($text, $objp->description, 3, '', '', $i); |
|
318 | 318 | } else { |
319 | 319 | print $text.' '.nl2br($objp->description); |
320 | 320 | } |
321 | 321 | |
322 | 322 | // Show range |
323 | - print_date_range($objp->date_start,$objp->date_end); |
|
323 | + print_date_range($objp->date_start, $objp->date_end); |
|
324 | 324 | print "</td>\n"; |
325 | 325 | } |
326 | 326 | |
327 | 327 | //print '<td align="center">'.$objp->qty_asked.'</td>'; |
328 | 328 | |
329 | 329 | // Date creation |
330 | - print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_creation),'day').'</td>'; |
|
330 | + print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_creation), 'day').'</td>'; |
|
331 | 331 | |
332 | 332 | // Date shipping creation |
333 | - print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_delivery),'day').'</td>'; |
|
333 | + print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_delivery), 'day').'</td>'; |
|
334 | 334 | |
335 | 335 | // Qty shipped |
336 | 336 | print '<td align="center">'.$objp->qty_shipped.'</td>'; |
337 | 337 | |
338 | 338 | // Warehouse |
339 | - if (! empty($conf->stock->enabled)) |
|
339 | + if (!empty($conf->stock->enabled)) |
|
340 | 340 | { |
341 | 341 | print '<td>'; |
342 | 342 | if ($objp->warehouse_id > 0) |
@@ -380,17 +380,17 @@ discard block |
||
380 | 380 | }*/ |
381 | 381 | |
382 | 382 | // Informations on receipt |
383 | - if (! empty($conf->livraison_bon->enabled)) |
|
383 | + if (!empty($conf->livraison_bon->enabled)) |
|
384 | 384 | { |
385 | 385 | include_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php'; |
386 | - $expedition->id=$objp->sendingid; |
|
387 | - $expedition->fetchObjectLinked($expedition->id,$expedition->element); |
|
386 | + $expedition->id = $objp->sendingid; |
|
387 | + $expedition->fetchObjectLinked($expedition->id, $expedition->element); |
|
388 | 388 | //var_dump($expedition->linkedObjects); |
389 | 389 | |
390 | - $receiving=''; |
|
391 | - if (count($expedition->linkedObjects['delivery']) > 0) $receiving=reset($expedition->linkedObjects['delivery']); // Take first link |
|
390 | + $receiving = ''; |
|
391 | + if (count($expedition->linkedObjects['delivery']) > 0) $receiving = reset($expedition->linkedObjects['delivery']); // Take first link |
|
392 | 392 | |
393 | - if (! empty($receiving)) |
|
393 | + if (!empty($receiving)) |
|
394 | 394 | { |
395 | 395 | // $expedition->fk_origin_line = id of det line of order |
396 | 396 | // $receiving->fk_origin_line = id of det line of order |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | //print '</td>'; |
411 | 411 | // Date shipping real |
412 | 412 | print '<td align="right">'; |
413 | - print dol_print_date($receiving->date_delivery,'day'); |
|
413 | + print dol_print_date($receiving->date_delivery, 'day'); |
|
414 | 414 | print '</td>'; |
415 | 415 | } |
416 | 416 | else |
@@ -51,10 +51,12 @@ discard block |
||
51 | 51 | { |
52 | 52 | // delivery link |
53 | 53 | $object->fetchObjectLinked($object->id,$object->element); |
54 | - if (count($object->linkedObjectsIds['delivery']) > 0) // If there is a delivery |
|
54 | + if (count($object->linkedObjectsIds['delivery']) > 0) { |
|
55 | + // If there is a delivery |
|
55 | 56 | { |
56 | 57 | // Take first one element of array |
57 | 58 | $tmp = reset($object->linkedObjectsIds['delivery']); |
59 | + } |
|
58 | 60 | |
59 | 61 | $head[$h][0] = DOL_URL_ROOT."/livraison/card.php?id=".$tmp; |
60 | 62 | $head[$h][1] = $langs->trans("DeliveryCard"); |
@@ -74,7 +76,9 @@ discard block |
||
74 | 76 | $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external')); |
75 | 77 | $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->id; |
76 | 78 | $head[$h][1] = $langs->trans("ContactsAddresses"); |
77 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
79 | + if ($nbContact > 0) { |
|
80 | + $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
81 | + } |
|
78 | 82 | $head[$h][2] = 'contact'; |
79 | 83 | $h++; |
80 | 84 | } |
@@ -86,16 +90,24 @@ discard block |
||
86 | 90 | $nbLinks=Link::count($db, $object->element, $object->id); |
87 | 91 | $head[$h][0] = DOL_URL_ROOT.'/expedition/document.php?id='.$object->id; |
88 | 92 | $head[$h][1] = $langs->trans('Documents'); |
89 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
93 | + if (($nbFiles+$nbLinks) > 0) { |
|
94 | + $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
95 | + } |
|
90 | 96 | $head[$h][2] = 'documents'; |
91 | 97 | $h++; |
92 | 98 | |
93 | 99 | $nbNote = 0; |
94 | - if (!empty($object->note_private)) $nbNote++; |
|
95 | - if (!empty($object->note_public)) $nbNote++; |
|
100 | + if (!empty($object->note_private)) { |
|
101 | + $nbNote++; |
|
102 | + } |
|
103 | + if (!empty($object->note_public)) { |
|
104 | + $nbNote++; |
|
105 | + } |
|
96 | 106 | $head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$object->id; |
97 | 107 | $head[$h][1] = $langs->trans("Notes"); |
98 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
108 | + if ($nbNote > 0) { |
|
109 | + $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
110 | + } |
|
99 | 111 | $head[$h][2] = 'note'; |
100 | 112 | $h++; |
101 | 113 | |
@@ -199,7 +211,9 @@ discard block |
||
199 | 211 | $sql.= " AND obj.fk_".$origin." = ".$origin_id; |
200 | 212 | $sql.= " AND obj.rowid = ed.fk_origin_line"; |
201 | 213 | $sql.= " AND ed.fk_expedition = e.rowid"; |
202 | - if ($filter) $sql.= $filter; |
|
214 | + if ($filter) { |
|
215 | + $sql.= $filter; |
|
216 | + } |
|
203 | 217 | |
204 | 218 | $sql.= " ORDER BY obj.fk_product"; |
205 | 219 | |
@@ -212,8 +226,11 @@ discard block |
||
212 | 226 | |
213 | 227 | if ($num) |
214 | 228 | { |
215 | - if ($filter) print load_fiche_titre($langs->trans("OtherSendingsForSameOrder")); |
|
216 | - else print load_fiche_titre($langs->trans("SendingsAndReceivingForSameOrder")); |
|
229 | + if ($filter) { |
|
230 | + print load_fiche_titre($langs->trans("OtherSendingsForSameOrder")); |
|
231 | + } else { |
|
232 | + print load_fiche_titre($langs->trans("SendingsAndReceivingForSameOrder")); |
|
233 | + } |
|
217 | 234 | |
218 | 235 | print '<table class="liste" width="100%">'; |
219 | 236 | print '<tr class="liste_titre">'; |
@@ -268,8 +285,12 @@ discard block |
||
268 | 285 | |
269 | 286 | $outputlangs = $langs; |
270 | 287 | $newlang=''; |
271 | - if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; |
|
272 | - if (empty($newlang)) $newlang=$object->thirdparty->default_lang; |
|
288 | + if (empty($newlang) && ! empty($_REQUEST['lang_id'])) { |
|
289 | + $newlang=$_REQUEST['lang_id']; |
|
290 | + } |
|
291 | + if (empty($newlang)) { |
|
292 | + $newlang=$object->thirdparty->default_lang; |
|
293 | + } |
|
273 | 294 | if (! empty($newlang)) |
274 | 295 | { |
275 | 296 | $outputlangs = new Translate("",$conf); |
@@ -277,8 +298,7 @@ discard block |
||
277 | 298 | } |
278 | 299 | |
279 | 300 | $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; |
280 | - } |
|
281 | - else |
|
301 | + } else |
|
282 | 302 | { |
283 | 303 | $label = (! empty($objp->label)?$objp->label:$objp->product_label); |
284 | 304 | } |
@@ -305,12 +325,14 @@ discard block |
||
305 | 325 | } |
306 | 326 | |
307 | 327 | print '</td>'; |
308 | - } |
|
309 | - else |
|
328 | + } else |
|
310 | 329 | { |
311 | 330 | print "<td>"; |
312 | - if ($objp->fk_product_type==1) $text = img_object($langs->trans('Service'),'service'); |
|
313 | - else $text = img_object($langs->trans('Product'),'product'); |
|
331 | + if ($objp->fk_product_type==1) { |
|
332 | + $text = img_object($langs->trans('Service'),'service'); |
|
333 | + } else { |
|
334 | + $text = img_object($langs->trans('Product'),'product'); |
|
335 | + } |
|
314 | 336 | |
315 | 337 | if (! empty($objp->label)) { |
316 | 338 | $text.= ' <strong>'.$objp->label.'</strong>'; |
@@ -388,7 +410,10 @@ discard block |
||
388 | 410 | //var_dump($expedition->linkedObjects); |
389 | 411 | |
390 | 412 | $receiving=''; |
391 | - if (count($expedition->linkedObjects['delivery']) > 0) $receiving=reset($expedition->linkedObjects['delivery']); // Take first link |
|
413 | + if (count($expedition->linkedObjects['delivery']) > 0) { |
|
414 | + $receiving=reset($expedition->linkedObjects['delivery']); |
|
415 | + } |
|
416 | + // Take first link |
|
392 | 417 | |
393 | 418 | if (! empty($receiving)) |
394 | 419 | { |
@@ -412,8 +437,7 @@ discard block |
||
412 | 437 | print '<td align="right">'; |
413 | 438 | print dol_print_date($receiving->date_delivery,'day'); |
414 | 439 | print '</td>'; |
415 | - } |
|
416 | - else |
|
440 | + } else |
|
417 | 441 | { |
418 | 442 | //print '<td> </td>'; |
419 | 443 | print '<td> </td>'; |
@@ -427,8 +451,7 @@ discard block |
||
427 | 451 | print '</table>'; |
428 | 452 | } |
429 | 453 | $db->free($resql); |
430 | - } |
|
431 | - else |
|
454 | + } else |
|
432 | 455 | { |
433 | 456 | dol_print_error($db); |
434 | 457 | } |
@@ -34,45 +34,45 @@ discard block |
||
34 | 34 | */ |
35 | 35 | function reception_prepare_head(Reception $object) |
36 | 36 | { |
37 | - global $db, $langs, $conf, $user; |
|
37 | + global $db, $langs, $conf, $user; |
|
38 | 38 | |
39 | - $langs->load("sendings"); |
|
40 | - $langs->load("deliveries"); |
|
39 | + $langs->load("sendings"); |
|
40 | + $langs->load("deliveries"); |
|
41 | 41 | |
42 | - $h = 0; |
|
43 | - $head = array(); |
|
42 | + $h = 0; |
|
43 | + $head = array(); |
|
44 | 44 | |
45 | - $head[$h][0] = DOL_URL_ROOT."/reception/card.php?id=".$object->id; |
|
46 | - $head[$h][1] = $langs->trans("ReceptionCard"); |
|
47 | - $head[$h][2] = 'reception'; |
|
48 | - $h++; |
|
45 | + $head[$h][0] = DOL_URL_ROOT."/reception/card.php?id=".$object->id; |
|
46 | + $head[$h][1] = $langs->trans("ReceptionCard"); |
|
47 | + $head[$h][2] = 'reception'; |
|
48 | + $h++; |
|
49 | 49 | |
50 | 50 | |
51 | 51 | |
52 | - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
53 | - { |
|
54 | - $objectsrc = $object; |
|
55 | - if ($object->origin == 'commande' && $object->origin_id > 0) |
|
56 | - { |
|
57 | - $objectsrc = new Commande($db); |
|
58 | - $objectsrc->fetch($object->origin_id); |
|
59 | - } |
|
60 | - $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external')); |
|
61 | - $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id; |
|
62 | - $head[$h][1] = $langs->trans("ContactsAddresses"); |
|
63 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
64 | - $head[$h][2] = 'contact'; |
|
65 | - $h++; |
|
66 | - } |
|
52 | + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
53 | + { |
|
54 | + $objectsrc = $object; |
|
55 | + if ($object->origin == 'commande' && $object->origin_id > 0) |
|
56 | + { |
|
57 | + $objectsrc = new Commande($db); |
|
58 | + $objectsrc->fetch($object->origin_id); |
|
59 | + } |
|
60 | + $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external')); |
|
61 | + $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id; |
|
62 | + $head[$h][1] = $langs->trans("ContactsAddresses"); |
|
63 | + if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
64 | + $head[$h][2] = 'contact'; |
|
65 | + $h++; |
|
66 | + } |
|
67 | 67 | |
68 | 68 | $nbNote = 0; |
69 | 69 | if (!empty($object->note_private)) $nbNote++; |
70 | 70 | if (!empty($object->note_public)) $nbNote++; |
71 | - $head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id; |
|
72 | - $head[$h][1] = $langs->trans("Notes"); |
|
73 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
74 | - $head[$h][2] = 'note'; |
|
75 | - $h++; |
|
71 | + $head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id; |
|
72 | + $head[$h][1] = $langs->trans("Notes"); |
|
73 | + if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
74 | + $head[$h][2] = 'note'; |
|
75 | + $h++; |
|
76 | 76 | |
77 | 77 | |
78 | 78 | |
@@ -91,39 +91,39 @@ discard block |
||
91 | 91 | */ |
92 | 92 | function reception_admin_prepare_head() |
93 | 93 | { |
94 | - global $langs, $conf, $user; |
|
95 | - $langs->load("receptions"); |
|
94 | + global $langs, $conf, $user; |
|
95 | + $langs->load("receptions"); |
|
96 | 96 | |
97 | - $h = 0; |
|
98 | - $head = array(); |
|
97 | + $h = 0; |
|
98 | + $head = array(); |
|
99 | 99 | |
100 | - $head[$h][0] = DOL_URL_ROOT."/admin/reception_setup.php"; |
|
101 | - $head[$h][1] = $langs->trans("Reception"); |
|
102 | - $head[$h][2] = 'reception'; |
|
103 | - $h++; |
|
100 | + $head[$h][0] = DOL_URL_ROOT."/admin/reception_setup.php"; |
|
101 | + $head[$h][1] = $langs->trans("Reception"); |
|
102 | + $head[$h][2] = 'reception'; |
|
103 | + $h++; |
|
104 | 104 | |
105 | 105 | |
106 | - if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION)) |
|
107 | - { |
|
108 | - $head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php'; |
|
109 | - $head[$h][1] = $langs->trans("ExtraFields"); |
|
110 | - $head[$h][2] = 'attributes_reception'; |
|
111 | - $h++; |
|
112 | - } |
|
106 | + if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION)) |
|
107 | + { |
|
108 | + $head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php'; |
|
109 | + $head[$h][1] = $langs->trans("ExtraFields"); |
|
110 | + $head[$h][2] = 'attributes_reception'; |
|
111 | + $h++; |
|
112 | + } |
|
113 | 113 | |
114 | - if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION)) |
|
115 | - { |
|
116 | - $head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php'; |
|
117 | - $head[$h][1] = $langs->trans("ExtraFieldsLines"); |
|
118 | - $head[$h][2] = 'attributeslines_reception'; |
|
119 | - $h++; |
|
120 | - } |
|
114 | + if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION)) |
|
115 | + { |
|
116 | + $head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php'; |
|
117 | + $head[$h][1] = $langs->trans("ExtraFieldsLines"); |
|
118 | + $head[$h][2] = 'attributeslines_reception'; |
|
119 | + $h++; |
|
120 | + } |
|
121 | 121 | |
122 | 122 | |
123 | 123 | |
124 | - complete_head_from_modules($conf,$langs,null,$head,$h,'reception_admin','remove'); |
|
124 | + complete_head_from_modules($conf,$langs,null,$head,$h,'reception_admin','remove'); |
|
125 | 125 | |
126 | - return $head; |
|
126 | + return $head; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | $objectsrc = new Commande($db); |
58 | 58 | $objectsrc->fetch($object->origin_id); |
59 | 59 | } |
60 | - $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external')); |
|
60 | + $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external')); |
|
61 | 61 | $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id; |
62 | 62 | $head[$h][1] = $langs->trans("ContactsAddresses"); |
63 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
63 | + if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>'; |
|
64 | 64 | $head[$h][2] = 'contact'; |
65 | 65 | $h++; |
66 | 66 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | if (!empty($object->note_public)) $nbNote++; |
71 | 71 | $head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id; |
72 | 72 | $head[$h][1] = $langs->trans("Notes"); |
73 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
73 | + if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>'; |
|
74 | 74 | $head[$h][2] = 'note'; |
75 | 75 | $h++; |
76 | 76 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | |
81 | 81 | |
82 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'order','remove'); |
|
82 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'order', 'remove'); |
|
83 | 83 | |
84 | 84 | return $head; |
85 | 85 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $h++; |
104 | 104 | |
105 | 105 | |
106 | - if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION)) |
|
106 | + if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION)) |
|
107 | 107 | { |
108 | 108 | $head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php'; |
109 | 109 | $head[$h][1] = $langs->trans("ExtraFields"); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $h++; |
112 | 112 | } |
113 | 113 | |
114 | - if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION)) |
|
114 | + if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION)) |
|
115 | 115 | { |
116 | 116 | $head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php'; |
117 | 117 | $head[$h][1] = $langs->trans("ExtraFieldsLines"); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | |
122 | 122 | |
123 | 123 | |
124 | - complete_head_from_modules($conf,$langs,null,$head,$h,'reception_admin','remove'); |
|
124 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'reception_admin', 'remove'); |
|
125 | 125 | |
126 | 126 | return $head; |
127 | 127 | } |
@@ -60,17 +60,25 @@ |
||
60 | 60 | $nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external')); |
61 | 61 | $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id; |
62 | 62 | $head[$h][1] = $langs->trans("ContactsAddresses"); |
63 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
63 | + if ($nbContact > 0) { |
|
64 | + $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
65 | + } |
|
64 | 66 | $head[$h][2] = 'contact'; |
65 | 67 | $h++; |
66 | 68 | } |
67 | 69 | |
68 | 70 | $nbNote = 0; |
69 | - if (!empty($object->note_private)) $nbNote++; |
|
70 | - if (!empty($object->note_public)) $nbNote++; |
|
71 | + if (!empty($object->note_private)) { |
|
72 | + $nbNote++; |
|
73 | + } |
|
74 | + if (!empty($object->note_public)) { |
|
75 | + $nbNote++; |
|
76 | + } |
|
71 | 77 | $head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id; |
72 | 78 | $head[$h][1] = $langs->trans("Notes"); |
73 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
79 | + if ($nbNote > 0) { |
|
80 | + $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
81 | + } |
|
74 | 82 | $head[$h][2] = 'note'; |
75 | 83 | $h++; |
76 | 84 |
@@ -31,39 +31,39 @@ discard block |
||
31 | 31 | */ |
32 | 32 | function propal_prepare_head($object) |
33 | 33 | { |
34 | - global $db, $langs, $conf, $user; |
|
35 | - $langs->loadLangs(array('propal', 'compta', 'companies')); |
|
36 | - |
|
37 | - $h = 0; |
|
38 | - $head = array(); |
|
39 | - |
|
40 | - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/card.php?id='.$object->id; |
|
41 | - $head[$h][1] = $langs->trans('ProposalCard'); |
|
42 | - $head[$h][2] = 'comm'; |
|
43 | - $h++; |
|
44 | - |
|
45 | - if ((empty($conf->commande->enabled) && ((! empty($conf->expedition_bon->enabled) && $user->rights->expedition->lire) |
|
46 | - || (! empty($conf->livraison_bon->enabled) && $user->rights->expedition->livraison->lire)))) |
|
47 | - { |
|
48 | - $langs->load("sendings"); |
|
49 | - $text = ''; |
|
50 | - $head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?id='.$object->id; |
|
51 | - if ($conf->expedition_bon->enabled) $text=$langs->trans("Shipment"); |
|
52 | - if ($conf->livraison_bon->enabled) $text.='/'.$langs->trans("Receivings"); |
|
53 | - $head[$h][1] = $text; |
|
54 | - $head[$h][2] = 'shipping'; |
|
55 | - $h++; |
|
56 | - } |
|
57 | - |
|
58 | - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
59 | - { |
|
60 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
61 | - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id; |
|
62 | - $head[$h][1] = $langs->trans('ContactsAddresses'); |
|
63 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
64 | - $head[$h][2] = 'contact'; |
|
65 | - $h++; |
|
66 | - } |
|
34 | + global $db, $langs, $conf, $user; |
|
35 | + $langs->loadLangs(array('propal', 'compta', 'companies')); |
|
36 | + |
|
37 | + $h = 0; |
|
38 | + $head = array(); |
|
39 | + |
|
40 | + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/card.php?id='.$object->id; |
|
41 | + $head[$h][1] = $langs->trans('ProposalCard'); |
|
42 | + $head[$h][2] = 'comm'; |
|
43 | + $h++; |
|
44 | + |
|
45 | + if ((empty($conf->commande->enabled) && ((! empty($conf->expedition_bon->enabled) && $user->rights->expedition->lire) |
|
46 | + || (! empty($conf->livraison_bon->enabled) && $user->rights->expedition->livraison->lire)))) |
|
47 | + { |
|
48 | + $langs->load("sendings"); |
|
49 | + $text = ''; |
|
50 | + $head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?id='.$object->id; |
|
51 | + if ($conf->expedition_bon->enabled) $text=$langs->trans("Shipment"); |
|
52 | + if ($conf->livraison_bon->enabled) $text.='/'.$langs->trans("Receivings"); |
|
53 | + $head[$h][1] = $text; |
|
54 | + $head[$h][2] = 'shipping'; |
|
55 | + $h++; |
|
56 | + } |
|
57 | + |
|
58 | + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
|
59 | + { |
|
60 | + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
61 | + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id; |
|
62 | + $head[$h][1] = $langs->trans('ContactsAddresses'); |
|
63 | + if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
64 | + $head[$h][2] = 'contact'; |
|
65 | + $h++; |
|
66 | + } |
|
67 | 67 | |
68 | 68 | // Show more tabs from modules |
69 | 69 | // Entries must be declared in modules descriptor with line |
@@ -73,35 +73,35 @@ discard block |
||
73 | 73 | |
74 | 74 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
75 | 75 | { |
76 | - $nbNote = 0; |
|
76 | + $nbNote = 0; |
|
77 | 77 | if(!empty($object->note_private)) $nbNote++; |
78 | - if(!empty($object->note_public)) $nbNote++; |
|
79 | - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?id='.$object->id; |
|
80 | - $head[$h][1] = $langs->trans('Notes'); |
|
81 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
82 | - $head[$h][2] = 'note'; |
|
83 | - $h++; |
|
78 | + if(!empty($object->note_public)) $nbNote++; |
|
79 | + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?id='.$object->id; |
|
80 | + $head[$h][1] = $langs->trans('Notes'); |
|
81 | + if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
82 | + $head[$h][2] = 'note'; |
|
83 | + $h++; |
|
84 | 84 | } |
85 | 85 | |
86 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
86 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
87 | 87 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
88 | 88 | $upload_dir = $conf->propal->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref); |
89 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
89 | + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
90 | 90 | $nbLinks=Link::count($db, $object->element, $object->id); |
91 | - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id; |
|
92 | - $head[$h][1] = $langs->trans('Documents'); |
|
93 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
94 | - $head[$h][2] = 'document'; |
|
95 | - $h++; |
|
91 | + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id; |
|
92 | + $head[$h][1] = $langs->trans('Documents'); |
|
93 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
94 | + $head[$h][2] = 'document'; |
|
95 | + $h++; |
|
96 | 96 | |
97 | - $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?id='.$object->id; |
|
98 | - $head[$h][1] = $langs->trans('Info'); |
|
99 | - $head[$h][2] = 'info'; |
|
100 | - $h++; |
|
97 | + $head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?id='.$object->id; |
|
98 | + $head[$h][1] = $langs->trans('Info'); |
|
99 | + $head[$h][2] = 'info'; |
|
100 | + $h++; |
|
101 | 101 | |
102 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'propal','remove'); |
|
102 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'propal','remove'); |
|
103 | 103 | |
104 | - return $head; |
|
104 | + return $head; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -111,24 +111,24 @@ discard block |
||
111 | 111 | */ |
112 | 112 | function propal_admin_prepare_head() |
113 | 113 | { |
114 | - global $langs, $conf, $user; |
|
114 | + global $langs, $conf, $user; |
|
115 | 115 | |
116 | - $h = 0; |
|
117 | - $head = array(); |
|
116 | + $h = 0; |
|
117 | + $head = array(); |
|
118 | 118 | |
119 | - $head[$h][0] = DOL_URL_ROOT.'/admin/propal.php'; |
|
120 | - $head[$h][1] = $langs->trans("Miscellaneous"); |
|
121 | - $head[$h][2] = 'general'; |
|
122 | - $h++; |
|
119 | + $head[$h][0] = DOL_URL_ROOT.'/admin/propal.php'; |
|
120 | + $head[$h][1] = $langs->trans("Miscellaneous"); |
|
121 | + $head[$h][2] = 'general'; |
|
122 | + $h++; |
|
123 | 123 | |
124 | - // Show more tabs from modules |
|
125 | - // Entries must be declared in modules descriptor with line |
|
126 | - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
127 | - // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
|
128 | - complete_head_from_modules($conf,$langs,null,$head,$h,'propal_admin'); |
|
124 | + // Show more tabs from modules |
|
125 | + // Entries must be declared in modules descriptor with line |
|
126 | + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
127 | + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
|
128 | + complete_head_from_modules($conf,$langs,null,$head,$h,'propal_admin'); |
|
129 | 129 | |
130 | - $head[$h][0] = DOL_URL_ROOT.'/comm/admin/propal_extrafields.php'; |
|
131 | - $head[$h][1] = $langs->trans("ExtraFields"); |
|
130 | + $head[$h][0] = DOL_URL_ROOT.'/comm/admin/propal_extrafields.php'; |
|
131 | + $head[$h][1] = $langs->trans("ExtraFields"); |
|
132 | 132 | $head[$h][2] = 'attributes'; |
133 | 133 | $h++; |
134 | 134 | |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | $head[$h][2] = 'attributeslines'; |
138 | 138 | $h++; |
139 | 139 | |
140 | - complete_head_from_modules($conf,$langs,null,$head,$h,'propal_admin','remove'); |
|
140 | + complete_head_from_modules($conf,$langs,null,$head,$h,'propal_admin','remove'); |
|
141 | 141 | |
142 | - return $head; |
|
142 | + return $head; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | $head[$h][2] = 'comm'; |
43 | 43 | $h++; |
44 | 44 | |
45 | - if ((empty($conf->commande->enabled) && ((! empty($conf->expedition_bon->enabled) && $user->rights->expedition->lire) |
|
46 | - || (! empty($conf->livraison_bon->enabled) && $user->rights->expedition->livraison->lire)))) |
|
45 | + if ((empty($conf->commande->enabled) && ((!empty($conf->expedition_bon->enabled) && $user->rights->expedition->lire) |
|
46 | + || (!empty($conf->livraison_bon->enabled) && $user->rights->expedition->livraison->lire)))) |
|
47 | 47 | { |
48 | 48 | $langs->load("sendings"); |
49 | 49 | $text = ''; |
50 | 50 | $head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?id='.$object->id; |
51 | - if ($conf->expedition_bon->enabled) $text=$langs->trans("Shipment"); |
|
52 | - if ($conf->livraison_bon->enabled) $text.='/'.$langs->trans("Receivings"); |
|
51 | + if ($conf->expedition_bon->enabled) $text = $langs->trans("Shipment"); |
|
52 | + if ($conf->livraison_bon->enabled) $text .= '/'.$langs->trans("Receivings"); |
|
53 | 53 | $head[$h][1] = $text; |
54 | 54 | $head[$h][2] = 'shipping'; |
55 | 55 | $h++; |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | |
58 | 58 | if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) |
59 | 59 | { |
60 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
60 | + $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); |
|
61 | 61 | $head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id; |
62 | 62 | $head[$h][1] = $langs->trans('ContactsAddresses'); |
63 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
63 | + if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>'; |
|
64 | 64 | $head[$h][2] = 'contact'; |
65 | 65 | $h++; |
66 | 66 | } |
@@ -69,28 +69,28 @@ discard block |
||
69 | 69 | // Entries must be declared in modules descriptor with line |
70 | 70 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
71 | 71 | // $this->tabs = array('entity:-tabname); to remove a tab |
72 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'propal'); |
|
72 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'propal'); |
|
73 | 73 | |
74 | 74 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
75 | 75 | { |
76 | 76 | $nbNote = 0; |
77 | - if(!empty($object->note_private)) $nbNote++; |
|
78 | - if(!empty($object->note_public)) $nbNote++; |
|
77 | + if (!empty($object->note_private)) $nbNote++; |
|
78 | + if (!empty($object->note_public)) $nbNote++; |
|
79 | 79 | $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?id='.$object->id; |
80 | 80 | $head[$h][1] = $langs->trans('Notes'); |
81 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
81 | + if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>'; |
|
82 | 82 | $head[$h][2] = 'note'; |
83 | 83 | $h++; |
84 | 84 | } |
85 | 85 | |
86 | 86 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
87 | 87 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
88 | - $upload_dir = $conf->propal->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref); |
|
89 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
90 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
88 | + $upload_dir = $conf->propal->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref); |
|
89 | + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
90 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
91 | 91 | $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id; |
92 | 92 | $head[$h][1] = $langs->trans('Documents'); |
93 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
93 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
94 | 94 | $head[$h][2] = 'document'; |
95 | 95 | $h++; |
96 | 96 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $head[$h][2] = 'info'; |
100 | 100 | $h++; |
101 | 101 | |
102 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'propal','remove'); |
|
102 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'propal', 'remove'); |
|
103 | 103 | |
104 | 104 | return $head; |
105 | 105 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | // Entries must be declared in modules descriptor with line |
126 | 126 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
127 | 127 | // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
128 | - complete_head_from_modules($conf,$langs,null,$head,$h,'propal_admin'); |
|
128 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'propal_admin'); |
|
129 | 129 | |
130 | 130 | $head[$h][0] = DOL_URL_ROOT.'/comm/admin/propal_extrafields.php'; |
131 | 131 | $head[$h][1] = $langs->trans("ExtraFields"); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | $head[$h][2] = 'attributeslines'; |
138 | 138 | $h++; |
139 | 139 | |
140 | - complete_head_from_modules($conf,$langs,null,$head,$h,'propal_admin','remove'); |
|
140 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'propal_admin', 'remove'); |
|
141 | 141 | |
142 | 142 | return $head; |
143 | 143 | } |
@@ -48,8 +48,12 @@ discard block |
||
48 | 48 | $langs->load("sendings"); |
49 | 49 | $text = ''; |
50 | 50 | $head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?id='.$object->id; |
51 | - if ($conf->expedition_bon->enabled) $text=$langs->trans("Shipment"); |
|
52 | - if ($conf->livraison_bon->enabled) $text.='/'.$langs->trans("Receivings"); |
|
51 | + if ($conf->expedition_bon->enabled) { |
|
52 | + $text=$langs->trans("Shipment"); |
|
53 | + } |
|
54 | + if ($conf->livraison_bon->enabled) { |
|
55 | + $text.='/'.$langs->trans("Receivings"); |
|
56 | + } |
|
53 | 57 | $head[$h][1] = $text; |
54 | 58 | $head[$h][2] = 'shipping'; |
55 | 59 | $h++; |
@@ -60,7 +64,9 @@ discard block |
||
60 | 64 | $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
61 | 65 | $head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id; |
62 | 66 | $head[$h][1] = $langs->trans('ContactsAddresses'); |
63 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
67 | + if ($nbContact > 0) { |
|
68 | + $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
69 | + } |
|
64 | 70 | $head[$h][2] = 'contact'; |
65 | 71 | $h++; |
66 | 72 | } |
@@ -74,11 +80,17 @@ discard block |
||
74 | 80 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
75 | 81 | { |
76 | 82 | $nbNote = 0; |
77 | - if(!empty($object->note_private)) $nbNote++; |
|
78 | - if(!empty($object->note_public)) $nbNote++; |
|
83 | + if(!empty($object->note_private)) { |
|
84 | + $nbNote++; |
|
85 | + } |
|
86 | + if(!empty($object->note_public)) { |
|
87 | + $nbNote++; |
|
88 | + } |
|
79 | 89 | $head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?id='.$object->id; |
80 | 90 | $head[$h][1] = $langs->trans('Notes'); |
81 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
91 | + if ($nbNote > 0) { |
|
92 | + $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
93 | + } |
|
82 | 94 | $head[$h][2] = 'note'; |
83 | 95 | $h++; |
84 | 96 | } |
@@ -90,7 +102,9 @@ discard block |
||
90 | 102 | $nbLinks=Link::count($db, $object->element, $object->id); |
91 | 103 | $head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id; |
92 | 104 | $head[$h][1] = $langs->trans('Documents'); |
93 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
105 | + if (($nbFiles+$nbLinks) > 0) { |
|
106 | + $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
107 | + } |
|
94 | 108 | $head[$h][2] = 'document'; |
95 | 109 | $h++; |
96 | 110 |
@@ -29,53 +29,53 @@ discard block |
||
29 | 29 | */ |
30 | 30 | function expensereport_prepare_head($object) |
31 | 31 | { |
32 | - global $db, $langs, $conf; |
|
32 | + global $db, $langs, $conf; |
|
33 | 33 | |
34 | - $h = 0; |
|
35 | - $head = array(); |
|
34 | + $h = 0; |
|
35 | + $head = array(); |
|
36 | 36 | |
37 | - $head[$h][0] = DOL_URL_ROOT . '/expensereport/card.php?id=' . $object->id; |
|
38 | - $head[$h][1] = $langs->trans("Card"); |
|
39 | - $head[$h][2] = 'card'; |
|
40 | - $h++; |
|
37 | + $head[$h][0] = DOL_URL_ROOT . '/expensereport/card.php?id=' . $object->id; |
|
38 | + $head[$h][1] = $langs->trans("Card"); |
|
39 | + $head[$h][2] = 'card'; |
|
40 | + $h++; |
|
41 | 41 | |
42 | - // Show more tabs from modules |
|
43 | - // Entries must be declared in modules descriptor with line |
|
42 | + // Show more tabs from modules |
|
43 | + // Entries must be declared in modules descriptor with line |
|
44 | 44 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
45 | 45 | // $this->tabs = array('entity:-tabname); to remove a tab |
46 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport'); |
|
46 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport'); |
|
47 | 47 | |
48 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
48 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
49 | 49 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
50 | - $upload_dir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
51 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
50 | + $upload_dir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
51 | + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
52 | 52 | $nbLinks=Link::count($db, $object->element, $object->id); |
53 | - $head[$h][0] = DOL_URL_ROOT.'/expensereport/document.php?id='.$object->id; |
|
54 | - $head[$h][1] = $langs->trans('Documents'); |
|
55 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
56 | - $head[$h][2] = 'documents'; |
|
57 | - $h++; |
|
58 | - |
|
59 | - if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
|
60 | - { |
|
61 | - $nbNote = 0; |
|
62 | - if(!empty($object->note_private)) $nbNote++; |
|
63 | - if(!empty($object->note_public)) $nbNote++; |
|
64 | - $head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id; |
|
65 | - $head[$h][1] = $langs->trans('Notes'); |
|
66 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
67 | - $head[$h][2] = 'note'; |
|
68 | - $h++; |
|
69 | - } |
|
70 | - |
|
71 | - $head[$h][0] = DOL_URL_ROOT . '/expensereport/info.php?id=' . $object->id; |
|
72 | - $head[$h][1] = $langs->trans("Info"); |
|
73 | - $head[$h][2] = 'info'; |
|
74 | - $h++; |
|
75 | - |
|
76 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport','remove'); |
|
77 | - |
|
78 | - return $head; |
|
53 | + $head[$h][0] = DOL_URL_ROOT.'/expensereport/document.php?id='.$object->id; |
|
54 | + $head[$h][1] = $langs->trans('Documents'); |
|
55 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
56 | + $head[$h][2] = 'documents'; |
|
57 | + $h++; |
|
58 | + |
|
59 | + if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
|
60 | + { |
|
61 | + $nbNote = 0; |
|
62 | + if(!empty($object->note_private)) $nbNote++; |
|
63 | + if(!empty($object->note_public)) $nbNote++; |
|
64 | + $head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id; |
|
65 | + $head[$h][1] = $langs->trans('Notes'); |
|
66 | + if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
67 | + $head[$h][2] = 'note'; |
|
68 | + $h++; |
|
69 | + } |
|
70 | + |
|
71 | + $head[$h][0] = DOL_URL_ROOT . '/expensereport/info.php?id=' . $object->id; |
|
72 | + $head[$h][1] = $langs->trans("Info"); |
|
73 | + $head[$h][2] = 'info'; |
|
74 | + $h++; |
|
75 | + |
|
76 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport','remove'); |
|
77 | + |
|
78 | + return $head; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -88,15 +88,15 @@ discard block |
||
88 | 88 | function payment_expensereport_prepare_head(PaymentExpenseReport $object) |
89 | 89 | { |
90 | 90 | |
91 | - global $langs, $conf; |
|
91 | + global $langs, $conf; |
|
92 | 92 | |
93 | - $h = 0; |
|
94 | - $head = array(); |
|
93 | + $h = 0; |
|
94 | + $head = array(); |
|
95 | 95 | |
96 | - $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$object->id; |
|
97 | - $head[$h][1] = $langs->trans("Card"); |
|
98 | - $head[$h][2] = 'payment'; |
|
99 | - $h++; |
|
96 | + $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$object->id; |
|
97 | + $head[$h][1] = $langs->trans("Card"); |
|
98 | + $head[$h][2] = 'payment'; |
|
99 | + $h++; |
|
100 | 100 | |
101 | 101 | // Show more tabs from modules |
102 | 102 | // Entries must be declared in modules descriptor with line |
@@ -104,14 +104,14 @@ discard block |
||
104 | 104 | // $this->tabs = array('entity:-tabname); to remove a tab |
105 | 105 | complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport'); |
106 | 106 | |
107 | - $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/info.php?id='.$object->id; |
|
108 | - $head[$h][1] = $langs->trans("Info"); |
|
109 | - $head[$h][2] = 'info'; |
|
110 | - $h++; |
|
107 | + $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/info.php?id='.$object->id; |
|
108 | + $head[$h][1] = $langs->trans("Info"); |
|
109 | + $head[$h][2] = 'info'; |
|
110 | + $h++; |
|
111 | 111 | |
112 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport', 'remove'); |
|
112 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport', 'remove'); |
|
113 | 113 | |
114 | - return $head; |
|
114 | + return $head; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -121,42 +121,42 @@ discard block |
||
121 | 121 | */ |
122 | 122 | function expensereport_admin_prepare_head() |
123 | 123 | { |
124 | - global $langs, $conf, $user; |
|
125 | - |
|
126 | - $h = 0; |
|
127 | - $head = array(); |
|
128 | - |
|
129 | - $h = 0; |
|
130 | - |
|
131 | - $head[$h][0] = DOL_URL_ROOT."/admin/expensereport.php"; |
|
132 | - $head[$h][1] = $langs->trans("ExpenseReports"); |
|
133 | - $head[$h][2] = 'expensereport'; |
|
134 | - $h++; |
|
135 | - |
|
136 | - if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) |
|
137 | - { |
|
138 | - $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_ik.php"; |
|
139 | - $head[$h][1] = $langs->trans("ExpenseReportsIk"); |
|
140 | - $head[$h][2] = 'expenseik'; |
|
141 | - $h++; |
|
142 | - } |
|
143 | - |
|
144 | - if (!empty($conf->global->MAIN_USE_EXPENSE_RULE)) |
|
145 | - { |
|
146 | - $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_rules.php"; |
|
147 | - $head[$h][1] = $langs->trans("ExpenseReportsRules"); |
|
148 | - $head[$h][2] = 'expenserules'; |
|
149 | - $h++; |
|
150 | - } |
|
151 | - |
|
152 | - // Show more tabs from modules |
|
153 | - // Entries must be declared in modules descriptor with line |
|
154 | - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
155 | - // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
|
156 | - complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin'); |
|
157 | - |
|
158 | - $head[$h][0] = DOL_URL_ROOT.'/admin/expensereport_extrafields.php'; |
|
159 | - $head[$h][1] = $langs->trans("ExtraFields"); |
|
124 | + global $langs, $conf, $user; |
|
125 | + |
|
126 | + $h = 0; |
|
127 | + $head = array(); |
|
128 | + |
|
129 | + $h = 0; |
|
130 | + |
|
131 | + $head[$h][0] = DOL_URL_ROOT."/admin/expensereport.php"; |
|
132 | + $head[$h][1] = $langs->trans("ExpenseReports"); |
|
133 | + $head[$h][2] = 'expensereport'; |
|
134 | + $h++; |
|
135 | + |
|
136 | + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) |
|
137 | + { |
|
138 | + $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_ik.php"; |
|
139 | + $head[$h][1] = $langs->trans("ExpenseReportsIk"); |
|
140 | + $head[$h][2] = 'expenseik'; |
|
141 | + $h++; |
|
142 | + } |
|
143 | + |
|
144 | + if (!empty($conf->global->MAIN_USE_EXPENSE_RULE)) |
|
145 | + { |
|
146 | + $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_rules.php"; |
|
147 | + $head[$h][1] = $langs->trans("ExpenseReportsRules"); |
|
148 | + $head[$h][2] = 'expenserules'; |
|
149 | + $h++; |
|
150 | + } |
|
151 | + |
|
152 | + // Show more tabs from modules |
|
153 | + // Entries must be declared in modules descriptor with line |
|
154 | + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
155 | + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
|
156 | + complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin'); |
|
157 | + |
|
158 | + $head[$h][0] = DOL_URL_ROOT.'/admin/expensereport_extrafields.php'; |
|
159 | + $head[$h][1] = $langs->trans("ExtraFields"); |
|
160 | 160 | $head[$h][2] = 'attributes'; |
161 | 161 | $h++; |
162 | 162 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | $h++; |
168 | 168 | */ |
169 | 169 | |
170 | - complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin','remove'); |
|
170 | + complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin','remove'); |
|
171 | 171 | |
172 | 172 | return $head; |
173 | 173 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $h = 0; |
35 | 35 | $head = array(); |
36 | 36 | |
37 | - $head[$h][0] = DOL_URL_ROOT . '/expensereport/card.php?id=' . $object->id; |
|
37 | + $head[$h][0] = DOL_URL_ROOT.'/expensereport/card.php?id='.$object->id; |
|
38 | 38 | $head[$h][1] = $langs->trans("Card"); |
39 | 39 | $head[$h][2] = 'card'; |
40 | 40 | $h++; |
@@ -43,37 +43,37 @@ discard block |
||
43 | 43 | // Entries must be declared in modules descriptor with line |
44 | 44 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
45 | 45 | // $this->tabs = array('entity:-tabname); to remove a tab |
46 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport'); |
|
46 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'expensereport'); |
|
47 | 47 | |
48 | 48 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
49 | 49 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
50 | - $upload_dir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
51 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
52 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
50 | + $upload_dir = $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref); |
|
51 | + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
52 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
53 | 53 | $head[$h][0] = DOL_URL_ROOT.'/expensereport/document.php?id='.$object->id; |
54 | 54 | $head[$h][1] = $langs->trans('Documents'); |
55 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
55 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
56 | 56 | $head[$h][2] = 'documents'; |
57 | 57 | $h++; |
58 | 58 | |
59 | 59 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
60 | 60 | { |
61 | 61 | $nbNote = 0; |
62 | - if(!empty($object->note_private)) $nbNote++; |
|
63 | - if(!empty($object->note_public)) $nbNote++; |
|
62 | + if (!empty($object->note_private)) $nbNote++; |
|
63 | + if (!empty($object->note_public)) $nbNote++; |
|
64 | 64 | $head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id; |
65 | 65 | $head[$h][1] = $langs->trans('Notes'); |
66 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
66 | + if ($nbNote > 0) $head[$h][1] .= ' <span class="badge">'.$nbNote.'</span>'; |
|
67 | 67 | $head[$h][2] = 'note'; |
68 | 68 | $h++; |
69 | 69 | } |
70 | 70 | |
71 | - $head[$h][0] = DOL_URL_ROOT . '/expensereport/info.php?id=' . $object->id; |
|
71 | + $head[$h][0] = DOL_URL_ROOT.'/expensereport/info.php?id='.$object->id; |
|
72 | 72 | $head[$h][1] = $langs->trans("Info"); |
73 | 73 | $head[$h][2] = 'info'; |
74 | 74 | $h++; |
75 | 75 | |
76 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport','remove'); |
|
76 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'expensereport', 'remove'); |
|
77 | 77 | |
78 | 78 | return $head; |
79 | 79 | } |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | // Entries must be declared in modules descriptor with line |
103 | 103 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
104 | 104 | // $this->tabs = array('entity:-tabname); to remove a tab |
105 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport'); |
|
105 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_expensereport'); |
|
106 | 106 | |
107 | 107 | $head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/info.php?id='.$object->id; |
108 | 108 | $head[$h][1] = $langs->trans("Info"); |
109 | 109 | $head[$h][2] = 'info'; |
110 | 110 | $h++; |
111 | 111 | |
112 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport', 'remove'); |
|
112 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_expensereport', 'remove'); |
|
113 | 113 | |
114 | 114 | return $head; |
115 | 115 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | // Entries must be declared in modules descriptor with line |
154 | 154 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
155 | 155 | // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab |
156 | - complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin'); |
|
156 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'expensereport_admin'); |
|
157 | 157 | |
158 | 158 | $head[$h][0] = DOL_URL_ROOT.'/admin/expensereport_extrafields.php'; |
159 | 159 | $head[$h][1] = $langs->trans("ExtraFields"); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | $h++; |
168 | 168 | */ |
169 | 169 | |
170 | - complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin','remove'); |
|
170 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'expensereport_admin', 'remove'); |
|
171 | 171 | |
172 | 172 | return $head; |
173 | 173 | } |
@@ -52,18 +52,26 @@ |
||
52 | 52 | $nbLinks=Link::count($db, $object->element, $object->id); |
53 | 53 | $head[$h][0] = DOL_URL_ROOT.'/expensereport/document.php?id='.$object->id; |
54 | 54 | $head[$h][1] = $langs->trans('Documents'); |
55 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
55 | + if (($nbFiles+$nbLinks) > 0) { |
|
56 | + $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
57 | + } |
|
56 | 58 | $head[$h][2] = 'documents'; |
57 | 59 | $h++; |
58 | 60 | |
59 | 61 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
60 | 62 | { |
61 | 63 | $nbNote = 0; |
62 | - if(!empty($object->note_private)) $nbNote++; |
|
63 | - if(!empty($object->note_public)) $nbNote++; |
|
64 | + if(!empty($object->note_private)) { |
|
65 | + $nbNote++; |
|
66 | + } |
|
67 | + if(!empty($object->note_public)) { |
|
68 | + $nbNote++; |
|
69 | + } |
|
64 | 70 | $head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id; |
65 | 71 | $head[$h][1] = $langs->trans('Notes'); |
66 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
72 | + if ($nbNote > 0) { |
|
73 | + $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
74 | + } |
|
67 | 75 | $head[$h][2] = 'note'; |
68 | 76 | $h++; |
69 | 77 | } |
@@ -35,61 +35,61 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function tree_showpad(&$fulltree,$key,$silent=0) |
37 | 37 | { |
38 | - $pos=1; |
|
39 | - |
|
40 | - // Loop on each pos, because we will output an img for each pos |
|
41 | - while ($pos <= $fulltree[$key]['level'] && $fulltree[$key]['level'] > 0) |
|
42 | - { |
|
43 | - // Process for column $pos |
|
44 | - |
|
45 | - $atleastoneofthislevelafter=0; |
|
46 | - $nbofdirinsub=0; |
|
47 | - $nbofdocinsub=0; |
|
48 | - $found=0; |
|
49 | - //print 'x'.$key; |
|
50 | - foreach($fulltree as $key2 => $val2) |
|
51 | - { |
|
38 | + $pos=1; |
|
39 | + |
|
40 | + // Loop on each pos, because we will output an img for each pos |
|
41 | + while ($pos <= $fulltree[$key]['level'] && $fulltree[$key]['level'] > 0) |
|
42 | + { |
|
43 | + // Process for column $pos |
|
44 | + |
|
45 | + $atleastoneofthislevelafter=0; |
|
46 | + $nbofdirinsub=0; |
|
47 | + $nbofdocinsub=0; |
|
48 | + $found=0; |
|
49 | + //print 'x'.$key; |
|
50 | + foreach($fulltree as $key2 => $val2) |
|
51 | + { |
|
52 | 52 | //print "x".$pos." ".$key2." ".$found." ".$fulltree[$key2]['level']; |
53 | - if ($found == 1) // We are after the entry to show |
|
54 | - { |
|
55 | - if ($fulltree[$key2]['level'] > $pos) |
|
56 | - { |
|
57 | - $nbofdirinsub++; |
|
58 | - if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) $nbofdocinsub+=$fulltree[$key2]['cachenbofdoc']; |
|
59 | - } |
|
60 | - if ($fulltree[$key2]['level'] == $pos) |
|
61 | - { |
|
62 | - $atleastoneofthislevelafter=1; |
|
63 | - } |
|
64 | - if ($fulltree[$key2]['level'] <= $pos) |
|
65 | - { |
|
66 | - break; |
|
67 | - } |
|
68 | - } |
|
69 | - if ($key2 == $key) // We found ourself, so now every lower level will be counted |
|
70 | - { |
|
71 | - $found=1; |
|
72 | - } |
|
73 | - } |
|
74 | - //print $atleastoneofthislevelafter; |
|
75 | - |
|
76 | - if (! $silent) |
|
77 | - { |
|
78 | - if ($atleastoneofthislevelafter) |
|
79 | - { |
|
80 | - if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branch.gif'); |
|
81 | - else print img_picto_common('','treemenu/line.gif'); |
|
82 | - } |
|
83 | - else |
|
84 | - { |
|
85 | - if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branchbottom.gif'); |
|
86 | - else print img_picto_common('','treemenu/linebottom.gif'); |
|
87 | - } |
|
88 | - } |
|
89 | - $pos++; |
|
90 | - } |
|
91 | - |
|
92 | - return array($atleastoneofthislevelafter,$nbofdirinsub,$nbofdocinsub); |
|
53 | + if ($found == 1) // We are after the entry to show |
|
54 | + { |
|
55 | + if ($fulltree[$key2]['level'] > $pos) |
|
56 | + { |
|
57 | + $nbofdirinsub++; |
|
58 | + if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) $nbofdocinsub+=$fulltree[$key2]['cachenbofdoc']; |
|
59 | + } |
|
60 | + if ($fulltree[$key2]['level'] == $pos) |
|
61 | + { |
|
62 | + $atleastoneofthislevelafter=1; |
|
63 | + } |
|
64 | + if ($fulltree[$key2]['level'] <= $pos) |
|
65 | + { |
|
66 | + break; |
|
67 | + } |
|
68 | + } |
|
69 | + if ($key2 == $key) // We found ourself, so now every lower level will be counted |
|
70 | + { |
|
71 | + $found=1; |
|
72 | + } |
|
73 | + } |
|
74 | + //print $atleastoneofthislevelafter; |
|
75 | + |
|
76 | + if (! $silent) |
|
77 | + { |
|
78 | + if ($atleastoneofthislevelafter) |
|
79 | + { |
|
80 | + if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branch.gif'); |
|
81 | + else print img_picto_common('','treemenu/line.gif'); |
|
82 | + } |
|
83 | + else |
|
84 | + { |
|
85 | + if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branchbottom.gif'); |
|
86 | + else print img_picto_common('','treemenu/linebottom.gif'); |
|
87 | + } |
|
88 | + } |
|
89 | + $pos++; |
|
90 | + } |
|
91 | + |
|
92 | + return array($atleastoneofthislevelafter,$nbofdirinsub,$nbofdocinsub); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded=array(); |
121 | 121 | |
122 | 122 | if ($rang == 0) |
123 | - { |
|
124 | - // Test also done with jstree and dynatree (not able to have <a> inside label) |
|
125 | - print '<script type="text/javascript" language="javascript"> |
|
123 | + { |
|
124 | + // Test also done with jstree and dynatree (not able to have <a> inside label) |
|
125 | + print '<script type="text/javascript" language="javascript"> |
|
126 | 126 | $(document).ready(function(){ |
127 | 127 | $("#'.$iddivjstree.'").treeview({ |
128 | 128 | collapsed: true, |
@@ -136,94 +136,94 @@ discard block |
||
136 | 136 | }) |
137 | 137 | </script>'; |
138 | 138 | |
139 | - print '<ul id="'.$iddivjstree.'">'; |
|
140 | - } |
|
141 | - |
|
142 | - if ($rang > 50) |
|
143 | - { |
|
144 | - return; // Protect against infinite loop. Max 50 depth |
|
145 | - } |
|
146 | - |
|
147 | - //ballayage du tableau |
|
148 | - $sizeoftab=count($tab); |
|
149 | - $ulprinted=0; |
|
150 | - for ($x=0; $x < $sizeoftab; $x++) |
|
151 | - { |
|
152 | - //var_dump($tab[$x]);exit; |
|
153 | - // If an element has $pere for parent |
|
154 | - if ($tab[$x]['fk_menu'] != -1 && $tab[$x]['fk_menu'] == $pere['rowid']) |
|
155 | - { |
|
156 | - //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n"; |
|
157 | - if (empty($ulprinted) && ! empty($pere['rowid'])) |
|
158 | - { |
|
159 | - if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) |
|
160 | - { |
|
161 | - dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING); |
|
162 | - continue; |
|
163 | - } |
|
139 | + print '<ul id="'.$iddivjstree.'">'; |
|
140 | + } |
|
141 | + |
|
142 | + if ($rang > 50) |
|
143 | + { |
|
144 | + return; // Protect against infinite loop. Max 50 depth |
|
145 | + } |
|
146 | + |
|
147 | + //ballayage du tableau |
|
148 | + $sizeoftab=count($tab); |
|
149 | + $ulprinted=0; |
|
150 | + for ($x=0; $x < $sizeoftab; $x++) |
|
151 | + { |
|
152 | + //var_dump($tab[$x]);exit; |
|
153 | + // If an element has $pere for parent |
|
154 | + if ($tab[$x]['fk_menu'] != -1 && $tab[$x]['fk_menu'] == $pere['rowid']) |
|
155 | + { |
|
156 | + //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n"; |
|
157 | + if (empty($ulprinted) && ! empty($pere['rowid'])) |
|
158 | + { |
|
159 | + if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) |
|
160 | + { |
|
161 | + dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING); |
|
162 | + continue; |
|
163 | + } |
|
164 | 164 | |
165 | 165 | print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++; |
166 | - } |
|
167 | - print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>'; |
|
168 | - if ($showfk) |
|
169 | - { |
|
170 | - print '<table class="nobordernopadding centpercent"><tr><td>'; |
|
171 | - print '<strong> '; |
|
172 | - print $tab[$x]['title']; |
|
173 | - print ' (fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')'; |
|
174 | - print '</td><td align="right">'; |
|
175 | - print $tab[$x]['buttons']; |
|
176 | - print '</td></tr></table>'; |
|
177 | - } |
|
178 | - else |
|
179 | - { |
|
180 | - print $tab[$x]['entry']; |
|
181 | - } |
|
182 | - //print ' -> A '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n"; |
|
183 | - $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1); |
|
184 | - // And now we search all its sons of lower level |
|
185 | - tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk); |
|
186 | - print '</li>'; |
|
187 | - } |
|
188 | - elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu']) |
|
189 | - { |
|
190 | - //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n"; |
|
191 | - if (empty($ulprinted) && ! empty($pere['rowid'])) |
|
192 | - { |
|
193 | - if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) |
|
194 | - { |
|
195 | - dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING); |
|
196 | - //print 'Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.'; |
|
166 | + } |
|
167 | + print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>'; |
|
168 | + if ($showfk) |
|
169 | + { |
|
170 | + print '<table class="nobordernopadding centpercent"><tr><td>'; |
|
171 | + print '<strong> '; |
|
172 | + print $tab[$x]['title']; |
|
173 | + print ' (fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')'; |
|
174 | + print '</td><td align="right">'; |
|
175 | + print $tab[$x]['buttons']; |
|
176 | + print '</td></tr></table>'; |
|
177 | + } |
|
178 | + else |
|
179 | + { |
|
180 | + print $tab[$x]['entry']; |
|
181 | + } |
|
182 | + //print ' -> A '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n"; |
|
183 | + $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1); |
|
184 | + // And now we search all its sons of lower level |
|
185 | + tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk); |
|
186 | + print '</li>'; |
|
187 | + } |
|
188 | + elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu']) |
|
189 | + { |
|
190 | + //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n"; |
|
191 | + if (empty($ulprinted) && ! empty($pere['rowid'])) |
|
192 | + { |
|
193 | + if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) |
|
194 | + { |
|
195 | + dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING); |
|
196 | + //print 'Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.'; |
|
197 | 197 | continue; |
198 | - } |
|
199 | - |
|
200 | - print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++; |
|
201 | - } |
|
202 | - print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>'; |
|
203 | - if ($showfk) |
|
204 | - { |
|
205 | - print '<table class="nobordernopadding centpercent"><tr><td>'; |
|
206 | - print '<strong> <a href="edit.php?menu_handler='.$menu_handler_to_search.'&action=edit&menuId='.$menu['rowid'].'">'; |
|
207 | - print $tab[$x]['title']; |
|
208 | - print '</a></strong>'; |
|
209 | - print ' (mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' - fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')'; |
|
210 | - print '</td><td align="right">'; |
|
211 | - print $tab[$x]['buttons']; |
|
212 | - print '</td></tr></table>'; |
|
213 | - } |
|
214 | - else |
|
215 | - { |
|
216 | - print $tab[$x]['entry']; |
|
217 | - } |
|
218 | - //print ' -> B '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n"; |
|
219 | - $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1); |
|
220 | - // And now we search all its sons of lower level |
|
221 | - //print 'Call tree_recur for x='.$x.' rowid='.$tab[$x]['rowid']." fk_mainmenu pere = ".$tab[$x]['fk_mainmenu']." fk_leftmenu pere = ".$tab[$x]['fk_leftmenu']."<br>\n"; |
|
222 | - tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk); |
|
223 | - print '</li>'; |
|
224 | - } |
|
225 | - } |
|
226 | - if (! empty($ulprinted) && ! empty($pere['rowid'])) { print '</ul>'."\n"; } |
|
198 | + } |
|
199 | + |
|
200 | + print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++; |
|
201 | + } |
|
202 | + print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>'; |
|
203 | + if ($showfk) |
|
204 | + { |
|
205 | + print '<table class="nobordernopadding centpercent"><tr><td>'; |
|
206 | + print '<strong> <a href="edit.php?menu_handler='.$menu_handler_to_search.'&action=edit&menuId='.$menu['rowid'].'">'; |
|
207 | + print $tab[$x]['title']; |
|
208 | + print '</a></strong>'; |
|
209 | + print ' (mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' - fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')'; |
|
210 | + print '</td><td align="right">'; |
|
211 | + print $tab[$x]['buttons']; |
|
212 | + print '</td></tr></table>'; |
|
213 | + } |
|
214 | + else |
|
215 | + { |
|
216 | + print $tab[$x]['entry']; |
|
217 | + } |
|
218 | + //print ' -> B '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n"; |
|
219 | + $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1); |
|
220 | + // And now we search all its sons of lower level |
|
221 | + //print 'Call tree_recur for x='.$x.' rowid='.$tab[$x]['rowid']." fk_mainmenu pere = ".$tab[$x]['fk_mainmenu']." fk_leftmenu pere = ".$tab[$x]['fk_leftmenu']."<br>\n"; |
|
222 | + tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk); |
|
223 | + print '</li>'; |
|
224 | + } |
|
225 | + } |
|
226 | + if (! empty($ulprinted) && ! empty($pere['rowid'])) { print '</ul>'."\n"; } |
|
227 | 227 | |
228 | 228 | if ($rang == 0) print '</ul>'; |
229 | 229 | } |
@@ -33,21 +33,21 @@ discard block |
||
33 | 33 | * @param int $silent Do not output indent and picto, returns only value |
34 | 34 | * @return integer[] array(0 or 1 if at least one of this level after, 0 or 1 if at least one of higher level after, nbofdirinsub, nbofdocinsub) |
35 | 35 | */ |
36 | -function tree_showpad(&$fulltree,$key,$silent=0) |
|
36 | +function tree_showpad(&$fulltree, $key, $silent = 0) |
|
37 | 37 | { |
38 | - $pos=1; |
|
38 | + $pos = 1; |
|
39 | 39 | |
40 | 40 | // Loop on each pos, because we will output an img for each pos |
41 | 41 | while ($pos <= $fulltree[$key]['level'] && $fulltree[$key]['level'] > 0) |
42 | 42 | { |
43 | 43 | // Process for column $pos |
44 | 44 | |
45 | - $atleastoneofthislevelafter=0; |
|
46 | - $nbofdirinsub=0; |
|
47 | - $nbofdocinsub=0; |
|
48 | - $found=0; |
|
45 | + $atleastoneofthislevelafter = 0; |
|
46 | + $nbofdirinsub = 0; |
|
47 | + $nbofdocinsub = 0; |
|
48 | + $found = 0; |
|
49 | 49 | //print 'x'.$key; |
50 | - foreach($fulltree as $key2 => $val2) |
|
50 | + foreach ($fulltree as $key2 => $val2) |
|
51 | 51 | { |
52 | 52 | //print "x".$pos." ".$key2." ".$found." ".$fulltree[$key2]['level']; |
53 | 53 | if ($found == 1) // We are after the entry to show |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | if ($fulltree[$key2]['level'] > $pos) |
56 | 56 | { |
57 | 57 | $nbofdirinsub++; |
58 | - if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) $nbofdocinsub+=$fulltree[$key2]['cachenbofdoc']; |
|
58 | + if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) $nbofdocinsub += $fulltree[$key2]['cachenbofdoc']; |
|
59 | 59 | } |
60 | 60 | if ($fulltree[$key2]['level'] == $pos) |
61 | 61 | { |
62 | - $atleastoneofthislevelafter=1; |
|
62 | + $atleastoneofthislevelafter = 1; |
|
63 | 63 | } |
64 | 64 | if ($fulltree[$key2]['level'] <= $pos) |
65 | 65 | { |
@@ -68,28 +68,28 @@ discard block |
||
68 | 68 | } |
69 | 69 | if ($key2 == $key) // We found ourself, so now every lower level will be counted |
70 | 70 | { |
71 | - $found=1; |
|
71 | + $found = 1; |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | //print $atleastoneofthislevelafter; |
75 | 75 | |
76 | - if (! $silent) |
|
76 | + if (!$silent) |
|
77 | 77 | { |
78 | 78 | if ($atleastoneofthislevelafter) |
79 | 79 | { |
80 | - if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branch.gif'); |
|
81 | - else print img_picto_common('','treemenu/line.gif'); |
|
80 | + if ($fulltree[$key]['level'] == $pos) print img_picto_common('', 'treemenu/branch.gif'); |
|
81 | + else print img_picto_common('', 'treemenu/line.gif'); |
|
82 | 82 | } |
83 | 83 | else |
84 | 84 | { |
85 | - if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branchbottom.gif'); |
|
86 | - else print img_picto_common('','treemenu/linebottom.gif'); |
|
85 | + if ($fulltree[$key]['level'] == $pos) print img_picto_common('', 'treemenu/branchbottom.gif'); |
|
86 | + else print img_picto_common('', 'treemenu/linebottom.gif'); |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | $pos++; |
90 | 90 | } |
91 | 91 | |
92 | - return array($atleastoneofthislevelafter,$nbofdirinsub,$nbofdocinsub); |
|
92 | + return array($atleastoneofthislevelafter, $nbofdirinsub, $nbofdocinsub); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | * @param int $showfk 1=show fk_links to parent into label (used by menu editor only) |
114 | 114 | * @return void |
115 | 115 | */ |
116 | -function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetalreadyloaded=0, $showfk=0) |
|
116 | +function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoresetalreadyloaded = 0, $showfk = 0) |
|
117 | 117 | { |
118 | 118 | global $tree_recur_alreadyadded; |
119 | 119 | |
120 | - if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded=array(); |
|
120 | + if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded = array(); |
|
121 | 121 | |
122 | 122 | if ($rang == 0) |
123 | 123 | { |
@@ -141,30 +141,30 @@ discard block |
||
141 | 141 | |
142 | 142 | if ($rang > 50) |
143 | 143 | { |
144 | - return; // Protect against infinite loop. Max 50 depth |
|
144 | + return; // Protect against infinite loop. Max 50 depth |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | //ballayage du tableau |
148 | - $sizeoftab=count($tab); |
|
149 | - $ulprinted=0; |
|
150 | - for ($x=0; $x < $sizeoftab; $x++) |
|
148 | + $sizeoftab = count($tab); |
|
149 | + $ulprinted = 0; |
|
150 | + for ($x = 0; $x < $sizeoftab; $x++) |
|
151 | 151 | { |
152 | 152 | //var_dump($tab[$x]);exit; |
153 | 153 | // If an element has $pere for parent |
154 | 154 | if ($tab[$x]['fk_menu'] != -1 && $tab[$x]['fk_menu'] == $pere['rowid']) |
155 | 155 | { |
156 | 156 | //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n"; |
157 | - if (empty($ulprinted) && ! empty($pere['rowid'])) |
|
157 | + if (empty($ulprinted) && !empty($pere['rowid'])) |
|
158 | 158 | { |
159 | - if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) |
|
159 | + if (!empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) |
|
160 | 160 | { |
161 | 161 | dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING); |
162 | 162 | continue; |
163 | 163 | } |
164 | 164 | |
165 | - print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++; |
|
165 | + print '<ul'.(empty($pere['rowid']) ? ' id="treeData"' : '').'>'; $ulprinted++; |
|
166 | 166 | } |
167 | - print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>'; |
|
167 | + print "\n".'<li '.($tab[$x]['statut'] ? ' class="liuseractive"' : 'class="liuserdisabled"').'>'; |
|
168 | 168 | if ($showfk) |
169 | 169 | { |
170 | 170 | print '<table class="nobordernopadding centpercent"><tr><td>'; |
@@ -180,26 +180,26 @@ discard block |
||
180 | 180 | print $tab[$x]['entry']; |
181 | 181 | } |
182 | 182 | //print ' -> A '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n"; |
183 | - $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1); |
|
183 | + $tree_recur_alreadyadded[$tab[$x]['rowid']] = ($rang + 1); |
|
184 | 184 | // And now we search all its sons of lower level |
185 | - tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk); |
|
185 | + tree_recur($tab, $tab[$x], $rang + 1, 'iddivjstree', 0, $showfk); |
|
186 | 186 | print '</li>'; |
187 | 187 | } |
188 | - elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu']) |
|
188 | + elseif (!empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu']) |
|
189 | 189 | { |
190 | 190 | //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n"; |
191 | - if (empty($ulprinted) && ! empty($pere['rowid'])) |
|
191 | + if (empty($ulprinted) && !empty($pere['rowid'])) |
|
192 | 192 | { |
193 | - if (! empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) |
|
193 | + if (!empty($tree_recur_alreadyadded[$tab[$x]['rowid']])) |
|
194 | 194 | { |
195 | 195 | dol_syslog('Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.', LOG_WARNING); |
196 | 196 | //print 'Error, record with id '.$tab[$x]['rowid'].' seems to be a child of record with id '.$pere['rowid'].' but it was already output. Complete field "leftmenu" and "mainmenu" on ALL records to avoid ambiguity.'; |
197 | 197 | continue; |
198 | 198 | } |
199 | 199 | |
200 | - print '<ul'.(empty($pere['rowid'])?' id="treeData"':'').'>'; $ulprinted++; |
|
200 | + print '<ul'.(empty($pere['rowid']) ? ' id="treeData"' : '').'>'; $ulprinted++; |
|
201 | 201 | } |
202 | - print "\n".'<li '.($tab[$x]['statut']?' class="liuseractive"':'class="liuserdisabled"').'>'; |
|
202 | + print "\n".'<li '.($tab[$x]['statut'] ? ' class="liuseractive"' : 'class="liuserdisabled"').'>'; |
|
203 | 203 | if ($showfk) |
204 | 204 | { |
205 | 205 | print '<table class="nobordernopadding centpercent"><tr><td>'; |
@@ -216,14 +216,14 @@ discard block |
||
216 | 216 | print $tab[$x]['entry']; |
217 | 217 | } |
218 | 218 | //print ' -> B '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'<br>'."\n"; |
219 | - $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1); |
|
219 | + $tree_recur_alreadyadded[$tab[$x]['rowid']] = ($rang + 1); |
|
220 | 220 | // And now we search all its sons of lower level |
221 | 221 | //print 'Call tree_recur for x='.$x.' rowid='.$tab[$x]['rowid']." fk_mainmenu pere = ".$tab[$x]['fk_mainmenu']." fk_leftmenu pere = ".$tab[$x]['fk_leftmenu']."<br>\n"; |
222 | - tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk); |
|
222 | + tree_recur($tab, $tab[$x], $rang + 1, 'iddivjstree', 0, $showfk); |
|
223 | 223 | print '</li>'; |
224 | 224 | } |
225 | 225 | } |
226 | - if (! empty($ulprinted) && ! empty($pere['rowid'])) { print '</ul>'."\n"; } |
|
226 | + if (!empty($ulprinted) && !empty($pere['rowid'])) { print '</ul>'."\n"; } |
|
227 | 227 | |
228 | 228 | if ($rang == 0) print '</ul>'; |
229 | 229 | } |
@@ -50,12 +50,16 @@ discard block |
||
50 | 50 | foreach($fulltree as $key2 => $val2) |
51 | 51 | { |
52 | 52 | //print "x".$pos." ".$key2." ".$found." ".$fulltree[$key2]['level']; |
53 | - if ($found == 1) // We are after the entry to show |
|
53 | + if ($found == 1) { |
|
54 | + // We are after the entry to show |
|
54 | 55 | { |
55 | 56 | if ($fulltree[$key2]['level'] > $pos) |
56 | 57 | { |
57 | 58 | $nbofdirinsub++; |
58 | - if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) $nbofdocinsub+=$fulltree[$key2]['cachenbofdoc']; |
|
59 | + } |
|
60 | + if (isset($fulltree[$key2]['cachenbofdoc']) && $fulltree[$key2]['cachenbofdoc'] > 0) { |
|
61 | + $nbofdocinsub+=$fulltree[$key2]['cachenbofdoc']; |
|
62 | + } |
|
59 | 63 | } |
60 | 64 | if ($fulltree[$key2]['level'] == $pos) |
61 | 65 | { |
@@ -66,10 +70,12 @@ discard block |
||
66 | 70 | break; |
67 | 71 | } |
68 | 72 | } |
69 | - if ($key2 == $key) // We found ourself, so now every lower level will be counted |
|
73 | + if ($key2 == $key) { |
|
74 | + // We found ourself, so now every lower level will be counted |
|
70 | 75 | { |
71 | 76 | $found=1; |
72 | 77 | } |
78 | + } |
|
73 | 79 | } |
74 | 80 | //print $atleastoneofthislevelafter; |
75 | 81 | |
@@ -77,13 +83,18 @@ discard block |
||
77 | 83 | { |
78 | 84 | if ($atleastoneofthislevelafter) |
79 | 85 | { |
80 | - if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branch.gif'); |
|
81 | - else print img_picto_common('','treemenu/line.gif'); |
|
82 | - } |
|
83 | - else |
|
86 | + if ($fulltree[$key]['level'] == $pos) { |
|
87 | + print img_picto_common('','treemenu/branch.gif'); |
|
88 | + } else { |
|
89 | + print img_picto_common('','treemenu/line.gif'); |
|
90 | + } |
|
91 | + } else |
|
84 | 92 | { |
85 | - if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branchbottom.gif'); |
|
86 | - else print img_picto_common('','treemenu/linebottom.gif'); |
|
93 | + if ($fulltree[$key]['level'] == $pos) { |
|
94 | + print img_picto_common('','treemenu/branchbottom.gif'); |
|
95 | + } else { |
|
96 | + print img_picto_common('','treemenu/linebottom.gif'); |
|
97 | + } |
|
87 | 98 | } |
88 | 99 | } |
89 | 100 | $pos++; |
@@ -117,7 +128,9 @@ discard block |
||
117 | 128 | { |
118 | 129 | global $tree_recur_alreadyadded; |
119 | 130 | |
120 | - if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded=array(); |
|
131 | + if ($rang == 0 && empty($donoresetalreadyloaded)) { |
|
132 | + $tree_recur_alreadyadded=array(); |
|
133 | + } |
|
121 | 134 | |
122 | 135 | if ($rang == 0) |
123 | 136 | { |
@@ -174,8 +187,7 @@ discard block |
||
174 | 187 | print '</td><td align="right">'; |
175 | 188 | print $tab[$x]['buttons']; |
176 | 189 | print '</td></tr></table>'; |
177 | - } |
|
178 | - else |
|
190 | + } else |
|
179 | 191 | { |
180 | 192 | print $tab[$x]['entry']; |
181 | 193 | } |
@@ -184,8 +196,7 @@ discard block |
||
184 | 196 | // And now we search all its sons of lower level |
185 | 197 | tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk); |
186 | 198 | print '</li>'; |
187 | - } |
|
188 | - elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu']) |
|
199 | + } elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu']) |
|
189 | 200 | { |
190 | 201 | //print 'rang='.$rang.'-x='.$x." rowid=".$tab[$x]['rowid']." tab[x]['fk_leftmenu'] = ".$tab[$x]['fk_leftmenu']." leftmenu pere = ".$pere['leftmenu']."<br>\n"; |
191 | 202 | if (empty($ulprinted) && ! empty($pere['rowid'])) |
@@ -210,8 +221,7 @@ discard block |
||
210 | 221 | print '</td><td align="right">'; |
211 | 222 | print $tab[$x]['buttons']; |
212 | 223 | print '</td></tr></table>'; |
213 | - } |
|
214 | - else |
|
224 | + } else |
|
215 | 225 | { |
216 | 226 | print $tab[$x]['entry']; |
217 | 227 | } |
@@ -225,6 +235,8 @@ discard block |
||
225 | 235 | } |
226 | 236 | if (! empty($ulprinted) && ! empty($pere['rowid'])) { print '</ul>'."\n"; } |
227 | 237 | |
228 | - if ($rang == 0) print '</ul>'; |
|
229 | -} |
|
238 | + if ($rang == 0) { |
|
239 | + print '</ul>'; |
|
240 | + } |
|
241 | + } |
|
230 | 242 |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | global $shmkeys,$shmoffset; |
25 | 25 | |
26 | 26 | $shmkeys=array('main'=>1,'admin'=>2,'dict'=>3,'companies'=>4,'suppliers'=>5,'products'=>6, |
27 | - 'commercial'=>7,'compta'=>8,'projects'=>9,'cashdesk'=>10,'agenda'=>11,'bills'=>12, |
|
28 | - 'propal'=>13,'boxes'=>14,'banks'=>15,'other'=>16,'errors'=>17,'members'=>18,'ecm'=>19, |
|
29 | - 'orders'=>20,'users'=>21,'help'=>22,'stocks'=>23,'interventions'=>24, |
|
30 | - 'donations'=>25,'contracts'=>26); |
|
27 | + 'commercial'=>7,'compta'=>8,'projects'=>9,'cashdesk'=>10,'agenda'=>11,'bills'=>12, |
|
28 | + 'propal'=>13,'boxes'=>14,'banks'=>15,'other'=>16,'errors'=>17,'members'=>18,'ecm'=>19, |
|
29 | + 'orders'=>20,'users'=>21,'help'=>22,'stocks'=>23,'interventions'=>24, |
|
30 | + 'donations'=>25,'contracts'=>26); |
|
31 | 31 | $shmoffset=1000; // Max number of entries found into a language file. If too low, some entries will be overwritten. |
32 | 32 | |
33 | 33 | |
@@ -41,64 +41,64 @@ discard block |
||
41 | 41 | */ |
42 | 42 | function dol_setcache($memoryid,$data) |
43 | 43 | { |
44 | - global $conf; |
|
45 | - $result=0; |
|
44 | + global $conf; |
|
45 | + $result=0; |
|
46 | 46 | |
47 | - // Using a memcached server |
|
48 | - if (! empty($conf->memcached->enabled) && class_exists('Memcached')) |
|
49 | - { |
|
50 | - global $dolmemcache; |
|
51 | - if (empty($dolmemcache) || ! is_object($dolmemcache)) |
|
52 | - { |
|
53 | - $dolmemcache=new Memcached(); |
|
54 | - $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); |
|
55 | - $result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); |
|
56 | - if (! $result) return -1; |
|
57 | - } |
|
47 | + // Using a memcached server |
|
48 | + if (! empty($conf->memcached->enabled) && class_exists('Memcached')) |
|
49 | + { |
|
50 | + global $dolmemcache; |
|
51 | + if (empty($dolmemcache) || ! is_object($dolmemcache)) |
|
52 | + { |
|
53 | + $dolmemcache=new Memcached(); |
|
54 | + $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); |
|
55 | + $result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); |
|
56 | + if (! $result) return -1; |
|
57 | + } |
|
58 | 58 | |
59 | - $memoryid=session_name().'_'.$memoryid; |
|
60 | - //$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false); |
|
61 | - $dolmemcache->add($memoryid,$data); // This fails if key already exists |
|
62 | - $rescode=$dolmemcache->getResultCode(); |
|
63 | - if ($rescode == 0) |
|
64 | - { |
|
65 | - return count($data); |
|
66 | - } |
|
67 | - else |
|
68 | - { |
|
69 | - return -$rescode; |
|
70 | - } |
|
71 | - } |
|
72 | - else if (! empty($conf->memcached->enabled) && class_exists('Memcache')) |
|
73 | - { |
|
74 | - global $dolmemcache; |
|
75 | - if (empty($dolmemcache) || ! is_object($dolmemcache)) |
|
76 | - { |
|
77 | - $dolmemcache=new Memcache(); |
|
78 | - $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); |
|
79 | - $result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); |
|
80 | - if (! $result) return -1; |
|
81 | - } |
|
59 | + $memoryid=session_name().'_'.$memoryid; |
|
60 | + //$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false); |
|
61 | + $dolmemcache->add($memoryid,$data); // This fails if key already exists |
|
62 | + $rescode=$dolmemcache->getResultCode(); |
|
63 | + if ($rescode == 0) |
|
64 | + { |
|
65 | + return count($data); |
|
66 | + } |
|
67 | + else |
|
68 | + { |
|
69 | + return -$rescode; |
|
70 | + } |
|
71 | + } |
|
72 | + else if (! empty($conf->memcached->enabled) && class_exists('Memcache')) |
|
73 | + { |
|
74 | + global $dolmemcache; |
|
75 | + if (empty($dolmemcache) || ! is_object($dolmemcache)) |
|
76 | + { |
|
77 | + $dolmemcache=new Memcache(); |
|
78 | + $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); |
|
79 | + $result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); |
|
80 | + if (! $result) return -1; |
|
81 | + } |
|
82 | 82 | |
83 | - $memoryid=session_name().'_'.$memoryid; |
|
84 | - //$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false); |
|
85 | - $result=$dolmemcache->add($memoryid,$data); // This fails if key already exists |
|
86 | - if ($result) |
|
87 | - { |
|
88 | - return count($data); |
|
89 | - } |
|
90 | - else |
|
91 | - { |
|
92 | - return -1; |
|
93 | - } |
|
94 | - } |
|
95 | - // Using shmop |
|
96 | - else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) |
|
97 | - { |
|
98 | - $result=dol_setshmop($memoryid,$data); |
|
99 | - } |
|
83 | + $memoryid=session_name().'_'.$memoryid; |
|
84 | + //$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false); |
|
85 | + $result=$dolmemcache->add($memoryid,$data); // This fails if key already exists |
|
86 | + if ($result) |
|
87 | + { |
|
88 | + return count($data); |
|
89 | + } |
|
90 | + else |
|
91 | + { |
|
92 | + return -1; |
|
93 | + } |
|
94 | + } |
|
95 | + // Using shmop |
|
96 | + else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) |
|
97 | + { |
|
98 | + $result=dol_setshmop($memoryid,$data); |
|
99 | + } |
|
100 | 100 | |
101 | - return $result; |
|
101 | + return $result; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -109,69 +109,69 @@ discard block |
||
109 | 109 | */ |
110 | 110 | function dol_getcache($memoryid) |
111 | 111 | { |
112 | - global $conf; |
|
112 | + global $conf; |
|
113 | 113 | |
114 | - // Using a memcached server |
|
115 | - if (! empty($conf->memcached->enabled) && class_exists('Memcached')) |
|
116 | - { |
|
117 | - global $m; |
|
118 | - if (empty($m) || ! is_object($m)) |
|
119 | - { |
|
114 | + // Using a memcached server |
|
115 | + if (! empty($conf->memcached->enabled) && class_exists('Memcached')) |
|
116 | + { |
|
117 | + global $m; |
|
118 | + if (empty($m) || ! is_object($m)) |
|
119 | + { |
|
120 | 120 | $m=new Memcached(); |
121 | - $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); |
|
122 | - $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); |
|
123 | - if (! $result) return -1; |
|
124 | - } |
|
121 | + $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); |
|
122 | + $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); |
|
123 | + if (! $result) return -1; |
|
124 | + } |
|
125 | 125 | |
126 | - $memoryid=session_name().'_'.$memoryid; |
|
127 | - //$m->setOption(Memcached::OPT_COMPRESSION, false); |
|
128 | - //print "Get memoryid=".$memoryid; |
|
129 | - $data=$m->get($memoryid); |
|
130 | - $rescode=$m->getResultCode(); |
|
131 | - //print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n<br>"; |
|
132 | - //var_dump($data); |
|
133 | - if ($rescode == 0) |
|
134 | - { |
|
135 | - return $data; |
|
136 | - } |
|
137 | - else |
|
138 | - { |
|
139 | - return -$rescode; |
|
140 | - } |
|
141 | - } |
|
142 | - else if (! empty($conf->memcached->enabled) && class_exists('Memcache')) |
|
143 | - { |
|
144 | - global $m; |
|
145 | - if (empty($m) || ! is_object($m)) |
|
146 | - { |
|
147 | - $m=new Memcache(); |
|
148 | - $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); |
|
149 | - $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); |
|
150 | - if (! $result) return -1; |
|
151 | - } |
|
126 | + $memoryid=session_name().'_'.$memoryid; |
|
127 | + //$m->setOption(Memcached::OPT_COMPRESSION, false); |
|
128 | + //print "Get memoryid=".$memoryid; |
|
129 | + $data=$m->get($memoryid); |
|
130 | + $rescode=$m->getResultCode(); |
|
131 | + //print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n<br>"; |
|
132 | + //var_dump($data); |
|
133 | + if ($rescode == 0) |
|
134 | + { |
|
135 | + return $data; |
|
136 | + } |
|
137 | + else |
|
138 | + { |
|
139 | + return -$rescode; |
|
140 | + } |
|
141 | + } |
|
142 | + else if (! empty($conf->memcached->enabled) && class_exists('Memcache')) |
|
143 | + { |
|
144 | + global $m; |
|
145 | + if (empty($m) || ! is_object($m)) |
|
146 | + { |
|
147 | + $m=new Memcache(); |
|
148 | + $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); |
|
149 | + $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); |
|
150 | + if (! $result) return -1; |
|
151 | + } |
|
152 | 152 | |
153 | - $memoryid=session_name().'_'.$memoryid; |
|
154 | - //$m->setOption(Memcached::OPT_COMPRESSION, false); |
|
155 | - $data=$m->get($memoryid); |
|
156 | - //print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n<br>"; |
|
157 | - //var_dump($data); |
|
158 | - if ($data) |
|
159 | - { |
|
160 | - return $data; |
|
161 | - } |
|
162 | - else |
|
163 | - { |
|
164 | - return -1; |
|
165 | - } |
|
166 | - } |
|
167 | - // Using shmop |
|
168 | - else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) |
|
169 | - { |
|
170 | - $data=dol_getshmop($memoryid); |
|
171 | - return $data; |
|
172 | - } |
|
153 | + $memoryid=session_name().'_'.$memoryid; |
|
154 | + //$m->setOption(Memcached::OPT_COMPRESSION, false); |
|
155 | + $data=$m->get($memoryid); |
|
156 | + //print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n<br>"; |
|
157 | + //var_dump($data); |
|
158 | + if ($data) |
|
159 | + { |
|
160 | + return $data; |
|
161 | + } |
|
162 | + else |
|
163 | + { |
|
164 | + return -1; |
|
165 | + } |
|
166 | + } |
|
167 | + // Using shmop |
|
168 | + else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) |
|
169 | + { |
|
170 | + $data=dol_getshmop($memoryid); |
|
171 | + return $data; |
|
172 | + } |
|
173 | 173 | |
174 | - return 0; |
|
174 | + return 0; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -184,9 +184,9 @@ discard block |
||
184 | 184 | */ |
185 | 185 | function dol_getshmopaddress($memoryid) |
186 | 186 | { |
187 | - global $shmkeys,$shmoffset; |
|
188 | - if (empty($shmkeys[$memoryid])) return 0; |
|
189 | - return $shmkeys[$memoryid]+$shmoffset; |
|
187 | + global $shmkeys,$shmoffset; |
|
188 | + if (empty($shmkeys[$memoryid])) return 0; |
|
189 | + return $shmkeys[$memoryid]+$shmoffset; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -196,15 +196,15 @@ discard block |
||
196 | 196 | */ |
197 | 197 | function dol_listshmop() |
198 | 198 | { |
199 | - global $shmkeys,$shmoffset; |
|
199 | + global $shmkeys,$shmoffset; |
|
200 | 200 | |
201 | - $resarray=array(); |
|
202 | - foreach($shmkeys as $key => $val) |
|
203 | - { |
|
204 | - $result=dol_getshmop($key); |
|
205 | - if (! is_numeric($result) || $result > 0) $resarray[$key]=$result; |
|
206 | - } |
|
207 | - return $resarray; |
|
201 | + $resarray=array(); |
|
202 | + foreach($shmkeys as $key => $val) |
|
203 | + { |
|
204 | + $result=dol_getshmop($key); |
|
205 | + if (! is_numeric($result) || $result > 0) $resarray[$key]=$result; |
|
206 | + } |
|
207 | + return $resarray; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -216,31 +216,31 @@ discard block |
||
216 | 216 | */ |
217 | 217 | function dol_setshmop($memoryid,$data) |
218 | 218 | { |
219 | - global $shmkeys,$shmoffset; |
|
219 | + global $shmkeys,$shmoffset; |
|
220 | 220 | |
221 | - //print 'dol_setshmop memoryid='.$memoryid."<br>\n"; |
|
222 | - if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_write")) return 0; |
|
223 | - $shmkey=dol_getshmopaddress($memoryid); |
|
224 | - $newdata=serialize($data); |
|
225 | - $size=strlen($newdata); |
|
226 | - //print 'dol_setshmop memoryid='.$memoryid." shmkey=".$shmkey." newdata=".$size."bytes<br>\n"; |
|
227 | - $handle=shmop_open($shmkey,'c',0644,6+$size); |
|
228 | - if ($handle) |
|
229 | - { |
|
230 | - $shm_bytes_written1=shmop_write($handle,str_pad($size,6),0); |
|
231 | - $shm_bytes_written2=shmop_write($handle,$newdata,6); |
|
232 | - if (($shm_bytes_written1 + $shm_bytes_written2) != (6+dol_strlen($newdata))) |
|
233 | - { |
|
234 | - print "Couldn't write the entire length of data\n"; |
|
235 | - } |
|
236 | - shmop_close($handle); |
|
237 | - return ($shm_bytes_written1+$shm_bytes_written2); |
|
238 | - } |
|
239 | - else |
|
240 | - { |
|
241 | - print 'Error in shmop_open for memoryid='.$memoryid.' shmkey='.$shmkey.' 6+size=6+'.$size; |
|
242 | - return -1; |
|
243 | - } |
|
221 | + //print 'dol_setshmop memoryid='.$memoryid."<br>\n"; |
|
222 | + if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_write")) return 0; |
|
223 | + $shmkey=dol_getshmopaddress($memoryid); |
|
224 | + $newdata=serialize($data); |
|
225 | + $size=strlen($newdata); |
|
226 | + //print 'dol_setshmop memoryid='.$memoryid." shmkey=".$shmkey." newdata=".$size."bytes<br>\n"; |
|
227 | + $handle=shmop_open($shmkey,'c',0644,6+$size); |
|
228 | + if ($handle) |
|
229 | + { |
|
230 | + $shm_bytes_written1=shmop_write($handle,str_pad($size,6),0); |
|
231 | + $shm_bytes_written2=shmop_write($handle,$newdata,6); |
|
232 | + if (($shm_bytes_written1 + $shm_bytes_written2) != (6+dol_strlen($newdata))) |
|
233 | + { |
|
234 | + print "Couldn't write the entire length of data\n"; |
|
235 | + } |
|
236 | + shmop_close($handle); |
|
237 | + return ($shm_bytes_written1+$shm_bytes_written2); |
|
238 | + } |
|
239 | + else |
|
240 | + { |
|
241 | + print 'Error in shmop_open for memoryid='.$memoryid.' shmkey='.$shmkey.' 6+size=6+'.$size; |
|
242 | + return -1; |
|
243 | + } |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -251,23 +251,23 @@ discard block |
||
251 | 251 | */ |
252 | 252 | function dol_getshmop($memoryid) |
253 | 253 | { |
254 | - global $shmkeys,$shmoffset; |
|
254 | + global $shmkeys,$shmoffset; |
|
255 | 255 | |
256 | - if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_open")) return 0; |
|
257 | - $shmkey=dol_getshmopaddress($memoryid); |
|
258 | - //print 'dol_getshmop memoryid='.$memoryid." shmkey=".$shmkey."<br>\n"; |
|
259 | - $handle=@shmop_open($shmkey,'a',0,0); |
|
260 | - if ($handle) |
|
261 | - { |
|
262 | - $size=trim(shmop_read($handle,0,6)); |
|
263 | - if ($size) $data=unserialize(shmop_read($handle,6,$size)); |
|
264 | - else return -1; |
|
265 | - shmop_close($handle); |
|
266 | - } |
|
267 | - else |
|
268 | - { |
|
269 | - return -2; |
|
270 | - } |
|
271 | - return $data; |
|
256 | + if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_open")) return 0; |
|
257 | + $shmkey=dol_getshmopaddress($memoryid); |
|
258 | + //print 'dol_getshmop memoryid='.$memoryid." shmkey=".$shmkey."<br>\n"; |
|
259 | + $handle=@shmop_open($shmkey,'a',0,0); |
|
260 | + if ($handle) |
|
261 | + { |
|
262 | + $size=trim(shmop_read($handle,0,6)); |
|
263 | + if ($size) $data=unserialize(shmop_read($handle,6,$size)); |
|
264 | + else return -1; |
|
265 | + shmop_close($handle); |
|
266 | + } |
|
267 | + else |
|
268 | + { |
|
269 | + return -2; |
|
270 | + } |
|
271 | + return $data; |
|
272 | 272 | } |
273 | 273 |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * \brief Set of function for memory/cache management |
22 | 22 | */ |
23 | 23 | |
24 | -global $shmkeys,$shmoffset; |
|
24 | +global $shmkeys, $shmoffset; |
|
25 | 25 | |
26 | -$shmkeys=array('main'=>1,'admin'=>2,'dict'=>3,'companies'=>4,'suppliers'=>5,'products'=>6, |
|
27 | - 'commercial'=>7,'compta'=>8,'projects'=>9,'cashdesk'=>10,'agenda'=>11,'bills'=>12, |
|
28 | - 'propal'=>13,'boxes'=>14,'banks'=>15,'other'=>16,'errors'=>17,'members'=>18,'ecm'=>19, |
|
29 | - 'orders'=>20,'users'=>21,'help'=>22,'stocks'=>23,'interventions'=>24, |
|
30 | - 'donations'=>25,'contracts'=>26); |
|
31 | -$shmoffset=1000; // Max number of entries found into a language file. If too low, some entries will be overwritten. |
|
26 | +$shmkeys = array('main'=>1, 'admin'=>2, 'dict'=>3, 'companies'=>4, 'suppliers'=>5, 'products'=>6, |
|
27 | + 'commercial'=>7, 'compta'=>8, 'projects'=>9, 'cashdesk'=>10, 'agenda'=>11, 'bills'=>12, |
|
28 | + 'propal'=>13, 'boxes'=>14, 'banks'=>15, 'other'=>16, 'errors'=>17, 'members'=>18, 'ecm'=>19, |
|
29 | + 'orders'=>20, 'users'=>21, 'help'=>22, 'stocks'=>23, 'interventions'=>24, |
|
30 | + 'donations'=>25, 'contracts'=>26); |
|
31 | +$shmoffset = 1000; // Max number of entries found into a language file. If too low, some entries will be overwritten. |
|
32 | 32 | |
33 | 33 | |
34 | 34 | |
@@ -39,27 +39,27 @@ discard block |
||
39 | 39 | * @param string $data Data to save |
40 | 40 | * @return int <0 if KO, Nb of bytes written if OK |
41 | 41 | */ |
42 | -function dol_setcache($memoryid,$data) |
|
42 | +function dol_setcache($memoryid, $data) |
|
43 | 43 | { |
44 | 44 | global $conf; |
45 | - $result=0; |
|
45 | + $result = 0; |
|
46 | 46 | |
47 | 47 | // Using a memcached server |
48 | - if (! empty($conf->memcached->enabled) && class_exists('Memcached')) |
|
48 | + if (!empty($conf->memcached->enabled) && class_exists('Memcached')) |
|
49 | 49 | { |
50 | 50 | global $dolmemcache; |
51 | - if (empty($dolmemcache) || ! is_object($dolmemcache)) |
|
51 | + if (empty($dolmemcache) || !is_object($dolmemcache)) |
|
52 | 52 | { |
53 | - $dolmemcache=new Memcached(); |
|
54 | - $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); |
|
55 | - $result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); |
|
56 | - if (! $result) return -1; |
|
53 | + $dolmemcache = new Memcached(); |
|
54 | + $tmparray = explode(':', $conf->global->MEMCACHED_SERVER); |
|
55 | + $result = $dolmemcache->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211); |
|
56 | + if (!$result) return -1; |
|
57 | 57 | } |
58 | 58 | |
59 | - $memoryid=session_name().'_'.$memoryid; |
|
59 | + $memoryid = session_name().'_'.$memoryid; |
|
60 | 60 | //$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false); |
61 | - $dolmemcache->add($memoryid,$data); // This fails if key already exists |
|
62 | - $rescode=$dolmemcache->getResultCode(); |
|
61 | + $dolmemcache->add($memoryid, $data); // This fails if key already exists |
|
62 | + $rescode = $dolmemcache->getResultCode(); |
|
63 | 63 | if ($rescode == 0) |
64 | 64 | { |
65 | 65 | return count($data); |
@@ -69,20 +69,20 @@ discard block |
||
69 | 69 | return -$rescode; |
70 | 70 | } |
71 | 71 | } |
72 | - else if (! empty($conf->memcached->enabled) && class_exists('Memcache')) |
|
72 | + else if (!empty($conf->memcached->enabled) && class_exists('Memcache')) |
|
73 | 73 | { |
74 | 74 | global $dolmemcache; |
75 | - if (empty($dolmemcache) || ! is_object($dolmemcache)) |
|
75 | + if (empty($dolmemcache) || !is_object($dolmemcache)) |
|
76 | 76 | { |
77 | - $dolmemcache=new Memcache(); |
|
78 | - $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); |
|
79 | - $result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); |
|
80 | - if (! $result) return -1; |
|
77 | + $dolmemcache = new Memcache(); |
|
78 | + $tmparray = explode(':', $conf->global->MEMCACHED_SERVER); |
|
79 | + $result = $dolmemcache->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211); |
|
80 | + if (!$result) return -1; |
|
81 | 81 | } |
82 | 82 | |
83 | - $memoryid=session_name().'_'.$memoryid; |
|
83 | + $memoryid = session_name().'_'.$memoryid; |
|
84 | 84 | //$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false); |
85 | - $result=$dolmemcache->add($memoryid,$data); // This fails if key already exists |
|
85 | + $result = $dolmemcache->add($memoryid, $data); // This fails if key already exists |
|
86 | 86 | if ($result) |
87 | 87 | { |
88 | 88 | return count($data); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | // Using shmop |
96 | 96 | else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) |
97 | 97 | { |
98 | - $result=dol_setshmop($memoryid,$data); |
|
98 | + $result = dol_setshmop($memoryid, $data); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | return $result; |
@@ -112,22 +112,22 @@ discard block |
||
112 | 112 | global $conf; |
113 | 113 | |
114 | 114 | // Using a memcached server |
115 | - if (! empty($conf->memcached->enabled) && class_exists('Memcached')) |
|
115 | + if (!empty($conf->memcached->enabled) && class_exists('Memcached')) |
|
116 | 116 | { |
117 | 117 | global $m; |
118 | - if (empty($m) || ! is_object($m)) |
|
118 | + if (empty($m) || !is_object($m)) |
|
119 | 119 | { |
120 | - $m=new Memcached(); |
|
121 | - $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); |
|
122 | - $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); |
|
123 | - if (! $result) return -1; |
|
120 | + $m = new Memcached(); |
|
121 | + $tmparray = explode(':', $conf->global->MEMCACHED_SERVER); |
|
122 | + $result = $m->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211); |
|
123 | + if (!$result) return -1; |
|
124 | 124 | } |
125 | 125 | |
126 | - $memoryid=session_name().'_'.$memoryid; |
|
126 | + $memoryid = session_name().'_'.$memoryid; |
|
127 | 127 | //$m->setOption(Memcached::OPT_COMPRESSION, false); |
128 | 128 | //print "Get memoryid=".$memoryid; |
129 | - $data=$m->get($memoryid); |
|
130 | - $rescode=$m->getResultCode(); |
|
129 | + $data = $m->get($memoryid); |
|
130 | + $rescode = $m->getResultCode(); |
|
131 | 131 | //print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n<br>"; |
132 | 132 | //var_dump($data); |
133 | 133 | if ($rescode == 0) |
@@ -139,20 +139,20 @@ discard block |
||
139 | 139 | return -$rescode; |
140 | 140 | } |
141 | 141 | } |
142 | - else if (! empty($conf->memcached->enabled) && class_exists('Memcache')) |
|
142 | + else if (!empty($conf->memcached->enabled) && class_exists('Memcache')) |
|
143 | 143 | { |
144 | 144 | global $m; |
145 | - if (empty($m) || ! is_object($m)) |
|
145 | + if (empty($m) || !is_object($m)) |
|
146 | 146 | { |
147 | - $m=new Memcache(); |
|
148 | - $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); |
|
149 | - $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); |
|
150 | - if (! $result) return -1; |
|
147 | + $m = new Memcache(); |
|
148 | + $tmparray = explode(':', $conf->global->MEMCACHED_SERVER); |
|
149 | + $result = $m->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211); |
|
150 | + if (!$result) return -1; |
|
151 | 151 | } |
152 | 152 | |
153 | - $memoryid=session_name().'_'.$memoryid; |
|
153 | + $memoryid = session_name().'_'.$memoryid; |
|
154 | 154 | //$m->setOption(Memcached::OPT_COMPRESSION, false); |
155 | - $data=$m->get($memoryid); |
|
155 | + $data = $m->get($memoryid); |
|
156 | 156 | //print "memoryid=".$memoryid." - rescode=".$rescode." - data=".count($data)."\n<br>"; |
157 | 157 | //var_dump($data); |
158 | 158 | if ($data) |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | // Using shmop |
168 | 168 | else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) |
169 | 169 | { |
170 | - $data=dol_getshmop($memoryid); |
|
170 | + $data = dol_getshmop($memoryid); |
|
171 | 171 | return $data; |
172 | 172 | } |
173 | 173 | |
@@ -184,9 +184,9 @@ discard block |
||
184 | 184 | */ |
185 | 185 | function dol_getshmopaddress($memoryid) |
186 | 186 | { |
187 | - global $shmkeys,$shmoffset; |
|
187 | + global $shmkeys, $shmoffset; |
|
188 | 188 | if (empty($shmkeys[$memoryid])) return 0; |
189 | - return $shmkeys[$memoryid]+$shmoffset; |
|
189 | + return $shmkeys[$memoryid] + $shmoffset; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -196,13 +196,13 @@ discard block |
||
196 | 196 | */ |
197 | 197 | function dol_listshmop() |
198 | 198 | { |
199 | - global $shmkeys,$shmoffset; |
|
199 | + global $shmkeys, $shmoffset; |
|
200 | 200 | |
201 | - $resarray=array(); |
|
202 | - foreach($shmkeys as $key => $val) |
|
201 | + $resarray = array(); |
|
202 | + foreach ($shmkeys as $key => $val) |
|
203 | 203 | { |
204 | - $result=dol_getshmop($key); |
|
205 | - if (! is_numeric($result) || $result > 0) $resarray[$key]=$result; |
|
204 | + $result = dol_getshmop($key); |
|
205 | + if (!is_numeric($result) || $result > 0) $resarray[$key] = $result; |
|
206 | 206 | } |
207 | 207 | return $resarray; |
208 | 208 | } |
@@ -214,27 +214,27 @@ discard block |
||
214 | 214 | * @param string $data Data to save |
215 | 215 | * @return int <0 if KO, Nb of bytes written if OK |
216 | 216 | */ |
217 | -function dol_setshmop($memoryid,$data) |
|
217 | +function dol_setshmop($memoryid, $data) |
|
218 | 218 | { |
219 | - global $shmkeys,$shmoffset; |
|
219 | + global $shmkeys, $shmoffset; |
|
220 | 220 | |
221 | 221 | //print 'dol_setshmop memoryid='.$memoryid."<br>\n"; |
222 | - if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_write")) return 0; |
|
223 | - $shmkey=dol_getshmopaddress($memoryid); |
|
224 | - $newdata=serialize($data); |
|
225 | - $size=strlen($newdata); |
|
222 | + if (empty($shmkeys[$memoryid]) || !function_exists("shmop_write")) return 0; |
|
223 | + $shmkey = dol_getshmopaddress($memoryid); |
|
224 | + $newdata = serialize($data); |
|
225 | + $size = strlen($newdata); |
|
226 | 226 | //print 'dol_setshmop memoryid='.$memoryid." shmkey=".$shmkey." newdata=".$size."bytes<br>\n"; |
227 | - $handle=shmop_open($shmkey,'c',0644,6+$size); |
|
227 | + $handle = shmop_open($shmkey, 'c', 0644, 6 + $size); |
|
228 | 228 | if ($handle) |
229 | 229 | { |
230 | - $shm_bytes_written1=shmop_write($handle,str_pad($size,6),0); |
|
231 | - $shm_bytes_written2=shmop_write($handle,$newdata,6); |
|
232 | - if (($shm_bytes_written1 + $shm_bytes_written2) != (6+dol_strlen($newdata))) |
|
230 | + $shm_bytes_written1 = shmop_write($handle, str_pad($size, 6), 0); |
|
231 | + $shm_bytes_written2 = shmop_write($handle, $newdata, 6); |
|
232 | + if (($shm_bytes_written1 + $shm_bytes_written2) != (6 + dol_strlen($newdata))) |
|
233 | 233 | { |
234 | 234 | print "Couldn't write the entire length of data\n"; |
235 | 235 | } |
236 | 236 | shmop_close($handle); |
237 | - return ($shm_bytes_written1+$shm_bytes_written2); |
|
237 | + return ($shm_bytes_written1 + $shm_bytes_written2); |
|
238 | 238 | } |
239 | 239 | else |
240 | 240 | { |
@@ -251,16 +251,16 @@ discard block |
||
251 | 251 | */ |
252 | 252 | function dol_getshmop($memoryid) |
253 | 253 | { |
254 | - global $shmkeys,$shmoffset; |
|
254 | + global $shmkeys, $shmoffset; |
|
255 | 255 | |
256 | - if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_open")) return 0; |
|
257 | - $shmkey=dol_getshmopaddress($memoryid); |
|
256 | + if (empty($shmkeys[$memoryid]) || !function_exists("shmop_open")) return 0; |
|
257 | + $shmkey = dol_getshmopaddress($memoryid); |
|
258 | 258 | //print 'dol_getshmop memoryid='.$memoryid." shmkey=".$shmkey."<br>\n"; |
259 | - $handle=@shmop_open($shmkey,'a',0,0); |
|
259 | + $handle = @shmop_open($shmkey, 'a', 0, 0); |
|
260 | 260 | if ($handle) |
261 | 261 | { |
262 | - $size=trim(shmop_read($handle,0,6)); |
|
263 | - if ($size) $data=unserialize(shmop_read($handle,6,$size)); |
|
262 | + $size = trim(shmop_read($handle, 0, 6)); |
|
263 | + if ($size) $data = unserialize(shmop_read($handle, 6, $size)); |
|
264 | 264 | else return -1; |
265 | 265 | shmop_close($handle); |
266 | 266 | } |
@@ -53,7 +53,9 @@ discard block |
||
53 | 53 | $dolmemcache=new Memcached(); |
54 | 54 | $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); |
55 | 55 | $result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); |
56 | - if (! $result) return -1; |
|
56 | + if (! $result) { |
|
57 | + return -1; |
|
58 | + } |
|
57 | 59 | } |
58 | 60 | |
59 | 61 | $memoryid=session_name().'_'.$memoryid; |
@@ -63,13 +65,11 @@ discard block |
||
63 | 65 | if ($rescode == 0) |
64 | 66 | { |
65 | 67 | return count($data); |
66 | - } |
|
67 | - else |
|
68 | + } else |
|
68 | 69 | { |
69 | 70 | return -$rescode; |
70 | 71 | } |
71 | - } |
|
72 | - else if (! empty($conf->memcached->enabled) && class_exists('Memcache')) |
|
72 | + } else if (! empty($conf->memcached->enabled) && class_exists('Memcache')) |
|
73 | 73 | { |
74 | 74 | global $dolmemcache; |
75 | 75 | if (empty($dolmemcache) || ! is_object($dolmemcache)) |
@@ -77,7 +77,9 @@ discard block |
||
77 | 77 | $dolmemcache=new Memcache(); |
78 | 78 | $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); |
79 | 79 | $result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); |
80 | - if (! $result) return -1; |
|
80 | + if (! $result) { |
|
81 | + return -1; |
|
82 | + } |
|
81 | 83 | } |
82 | 84 | |
83 | 85 | $memoryid=session_name().'_'.$memoryid; |
@@ -86,8 +88,7 @@ discard block |
||
86 | 88 | if ($result) |
87 | 89 | { |
88 | 90 | return count($data); |
89 | - } |
|
90 | - else |
|
91 | + } else |
|
91 | 92 | { |
92 | 93 | return -1; |
93 | 94 | } |
@@ -120,7 +121,9 @@ discard block |
||
120 | 121 | $m=new Memcached(); |
121 | 122 | $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); |
122 | 123 | $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); |
123 | - if (! $result) return -1; |
|
124 | + if (! $result) { |
|
125 | + return -1; |
|
126 | + } |
|
124 | 127 | } |
125 | 128 | |
126 | 129 | $memoryid=session_name().'_'.$memoryid; |
@@ -133,13 +136,11 @@ discard block |
||
133 | 136 | if ($rescode == 0) |
134 | 137 | { |
135 | 138 | return $data; |
136 | - } |
|
137 | - else |
|
139 | + } else |
|
138 | 140 | { |
139 | 141 | return -$rescode; |
140 | 142 | } |
141 | - } |
|
142 | - else if (! empty($conf->memcached->enabled) && class_exists('Memcache')) |
|
143 | + } else if (! empty($conf->memcached->enabled) && class_exists('Memcache')) |
|
143 | 144 | { |
144 | 145 | global $m; |
145 | 146 | if (empty($m) || ! is_object($m)) |
@@ -147,7 +148,9 @@ discard block |
||
147 | 148 | $m=new Memcache(); |
148 | 149 | $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); |
149 | 150 | $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); |
150 | - if (! $result) return -1; |
|
151 | + if (! $result) { |
|
152 | + return -1; |
|
153 | + } |
|
151 | 154 | } |
152 | 155 | |
153 | 156 | $memoryid=session_name().'_'.$memoryid; |
@@ -158,8 +161,7 @@ discard block |
||
158 | 161 | if ($data) |
159 | 162 | { |
160 | 163 | return $data; |
161 | - } |
|
162 | - else |
|
164 | + } else |
|
163 | 165 | { |
164 | 166 | return -1; |
165 | 167 | } |
@@ -185,7 +187,9 @@ discard block |
||
185 | 187 | function dol_getshmopaddress($memoryid) |
186 | 188 | { |
187 | 189 | global $shmkeys,$shmoffset; |
188 | - if (empty($shmkeys[$memoryid])) return 0; |
|
190 | + if (empty($shmkeys[$memoryid])) { |
|
191 | + return 0; |
|
192 | + } |
|
189 | 193 | return $shmkeys[$memoryid]+$shmoffset; |
190 | 194 | } |
191 | 195 | |
@@ -202,7 +206,9 @@ discard block |
||
202 | 206 | foreach($shmkeys as $key => $val) |
203 | 207 | { |
204 | 208 | $result=dol_getshmop($key); |
205 | - if (! is_numeric($result) || $result > 0) $resarray[$key]=$result; |
|
209 | + if (! is_numeric($result) || $result > 0) { |
|
210 | + $resarray[$key]=$result; |
|
211 | + } |
|
206 | 212 | } |
207 | 213 | return $resarray; |
208 | 214 | } |
@@ -219,7 +225,9 @@ discard block |
||
219 | 225 | global $shmkeys,$shmoffset; |
220 | 226 | |
221 | 227 | //print 'dol_setshmop memoryid='.$memoryid."<br>\n"; |
222 | - if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_write")) return 0; |
|
228 | + if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_write")) { |
|
229 | + return 0; |
|
230 | + } |
|
223 | 231 | $shmkey=dol_getshmopaddress($memoryid); |
224 | 232 | $newdata=serialize($data); |
225 | 233 | $size=strlen($newdata); |
@@ -235,8 +243,7 @@ discard block |
||
235 | 243 | } |
236 | 244 | shmop_close($handle); |
237 | 245 | return ($shm_bytes_written1+$shm_bytes_written2); |
238 | - } |
|
239 | - else |
|
246 | + } else |
|
240 | 247 | { |
241 | 248 | print 'Error in shmop_open for memoryid='.$memoryid.' shmkey='.$shmkey.' 6+size=6+'.$size; |
242 | 249 | return -1; |
@@ -253,18 +260,22 @@ discard block |
||
253 | 260 | { |
254 | 261 | global $shmkeys,$shmoffset; |
255 | 262 | |
256 | - if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_open")) return 0; |
|
263 | + if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_open")) { |
|
264 | + return 0; |
|
265 | + } |
|
257 | 266 | $shmkey=dol_getshmopaddress($memoryid); |
258 | 267 | //print 'dol_getshmop memoryid='.$memoryid." shmkey=".$shmkey."<br>\n"; |
259 | 268 | $handle=@shmop_open($shmkey,'a',0,0); |
260 | 269 | if ($handle) |
261 | 270 | { |
262 | 271 | $size=trim(shmop_read($handle,0,6)); |
263 | - if ($size) $data=unserialize(shmop_read($handle,6,$size)); |
|
264 | - else return -1; |
|
272 | + if ($size) { |
|
273 | + $data=unserialize(shmop_read($handle,6,$size)); |
|
274 | + } else { |
|
275 | + return -1; |
|
276 | + } |
|
265 | 277 | shmop_close($handle); |
266 | - } |
|
267 | - else |
|
278 | + } else |
|
268 | 279 | { |
269 | 280 | return -2; |
270 | 281 | } |
@@ -34,78 +34,78 @@ discard block |
||
34 | 34 | */ |
35 | 35 | function build_calfile($format,$title,$desc,$events_array,$outputfile) |
36 | 36 | { |
37 | - global $conf,$langs; |
|
37 | + global $conf,$langs; |
|
38 | 38 | |
39 | - dol_syslog("xcal.lib.php::build_calfile Build cal file ".$outputfile." to format ".$format); |
|
39 | + dol_syslog("xcal.lib.php::build_calfile Build cal file ".$outputfile." to format ".$format); |
|
40 | 40 | |
41 | - if (empty($outputfile)) return -1; |
|
41 | + if (empty($outputfile)) return -1; |
|
42 | 42 | |
43 | 43 | // Note: A cal file is an UTF8 encoded file |
44 | - $calfileh=fopen($outputfile,'w'); |
|
45 | - if ($calfileh) |
|
46 | - { |
|
47 | - include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
|
48 | - $now=dol_now(); |
|
49 | - |
|
50 | - $encoding=''; |
|
51 | - if ($format == 'vcal') $encoding='ENCODING=QUOTED-PRINTABLE:'; |
|
52 | - |
|
53 | - // Print header |
|
54 | - fwrite($calfileh,"BEGIN:VCALENDAR\n"); |
|
55 | - fwrite($calfileh,"VERSION:2.0\n"); |
|
56 | - fwrite($calfileh,"METHOD:PUBLISH\n"); |
|
57 | - //fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."//EN\n"); |
|
58 | - fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."\n"); |
|
59 | - fwrite($calfileh,"CALSCALE:GREGORIAN\n"); |
|
60 | - fwrite($calfileh,"X-WR-CALNAME:".$encoding.format_cal($format,$title)."\n"); |
|
44 | + $calfileh=fopen($outputfile,'w'); |
|
45 | + if ($calfileh) |
|
46 | + { |
|
47 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
|
48 | + $now=dol_now(); |
|
49 | + |
|
50 | + $encoding=''; |
|
51 | + if ($format == 'vcal') $encoding='ENCODING=QUOTED-PRINTABLE:'; |
|
52 | + |
|
53 | + // Print header |
|
54 | + fwrite($calfileh,"BEGIN:VCALENDAR\n"); |
|
55 | + fwrite($calfileh,"VERSION:2.0\n"); |
|
56 | + fwrite($calfileh,"METHOD:PUBLISH\n"); |
|
57 | + //fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."//EN\n"); |
|
58 | + fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."\n"); |
|
59 | + fwrite($calfileh,"CALSCALE:GREGORIAN\n"); |
|
60 | + fwrite($calfileh,"X-WR-CALNAME:".$encoding.format_cal($format,$title)."\n"); |
|
61 | 61 | fwrite($calfileh,"X-WR-CALDESC:".$encoding.format_cal($format,$desc)."\n"); |
62 | 62 | //fwrite($calfileh,"X-WR-TIMEZONE:Europe/Paris\n"); |
63 | 63 | if (! empty($conf->global->MAIN_AGENDA_EXPORT_CACHE) |
64 | 64 | && $conf->global->MAIN_AGENDA_EXPORT_CACHE > 60){ |
65 | - $hh=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'hour'); |
|
66 | - $mm=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'min'); |
|
67 | - $ss=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'sec'); |
|
68 | - fwrite($calfileh,"X-PUBLISHED-TTL: P".$hh."H".$mm."M".$ss."S\n"); |
|
65 | + $hh=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'hour'); |
|
66 | + $mm=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'min'); |
|
67 | + $ss=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'sec'); |
|
68 | + fwrite($calfileh,"X-PUBLISHED-TTL: P".$hh."H".$mm."M".$ss."S\n"); |
|
69 | 69 | } |
70 | 70 | |
71 | - foreach ($events_array as $key => $event) |
|
72 | - { |
|
73 | - $eventqualified=true; |
|
74 | - if ($eventqualified) |
|
75 | - { |
|
76 | - // See http://fr.wikipedia.org/wiki/ICalendar for format |
|
77 | - // See http://www.ietf.org/rfc/rfc2445.txt for RFC |
|
78 | - $uid = $event['uid']; |
|
79 | - $type = $event['type']; |
|
71 | + foreach ($events_array as $key => $event) |
|
72 | + { |
|
73 | + $eventqualified=true; |
|
74 | + if ($eventqualified) |
|
75 | + { |
|
76 | + // See http://fr.wikipedia.org/wiki/ICalendar for format |
|
77 | + // See http://www.ietf.org/rfc/rfc2445.txt for RFC |
|
78 | + $uid = $event['uid']; |
|
79 | + $type = $event['type']; |
|
80 | 80 | $startdate = $event['startdate']; |
81 | - $duration = $event['duration']; |
|
82 | - $enddate = $event['enddate']; |
|
83 | - $summary = $event['summary']; |
|
84 | - $category = $event['category']; |
|
81 | + $duration = $event['duration']; |
|
82 | + $enddate = $event['enddate']; |
|
83 | + $summary = $event['summary']; |
|
84 | + $category = $event['category']; |
|
85 | 85 | $priority = $event['priority']; |
86 | 86 | $fulldayevent = $event['fulldayevent']; |
87 | - $location = $event['location']; |
|
88 | - $email = $event['email']; |
|
89 | - $url = $event['url']; |
|
90 | - $transparency = $event['transparency']; // OPAQUE (busy) or TRANSPARENT (not busy) |
|
91 | - $description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']); |
|
92 | - $description=dol_string_nohtmltag($description,0); // Remove html tags |
|
87 | + $location = $event['location']; |
|
88 | + $email = $event['email']; |
|
89 | + $url = $event['url']; |
|
90 | + $transparency = $event['transparency']; // OPAQUE (busy) or TRANSPARENT (not busy) |
|
91 | + $description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']); |
|
92 | + $description=dol_string_nohtmltag($description,0); // Remove html tags |
|
93 | 93 | $created = $event['created']; |
94 | - $modified = $event['modified']; |
|
94 | + $modified = $event['modified']; |
|
95 | 95 | |
96 | - // Uncomment for tests |
|
97 | - //$summary="Resume"; |
|
98 | - //$description="Description"; |
|
99 | - //$description="MemberValidatedInDolibarr gd gdf gd gdff\nNom: tgdf g dfgdf gfd r ter\nType: gdfgfdf dfg fd gfd gd gdf gdf gfd gdfg dfg ddf\nAuteur: AD01fg dgdgdfg df gdf gd"; |
|
96 | + // Uncomment for tests |
|
97 | + //$summary="Resume"; |
|
98 | + //$description="Description"; |
|
99 | + //$description="MemberValidatedInDolibarr gd gdf gd gdff\nNom: tgdf g dfgdf gfd r ter\nType: gdfgfdf dfg fd gfd gd gdf gdf gfd gdfg dfg ddf\nAuteur: AD01fg dgdgdfg df gdf gd"; |
|
100 | 100 | |
101 | - // Format |
|
102 | - $summary=format_cal($format,$summary); |
|
103 | - $description=format_cal($format,$description); |
|
104 | - $category=format_cal($format,$category); |
|
105 | - $location=format_cal($format,$location); |
|
101 | + // Format |
|
102 | + $summary=format_cal($format,$summary); |
|
103 | + $description=format_cal($format,$description); |
|
104 | + $category=format_cal($format,$category); |
|
105 | + $location=format_cal($format,$location); |
|
106 | 106 | |
107 | - // Output the vCard/iCal VEVENT object |
|
108 | - /* |
|
107 | + // Output the vCard/iCal VEVENT object |
|
108 | + /* |
|
109 | 109 | Example from Google ical export for a 1 hour event: |
110 | 110 | BEGIN:VEVENT |
111 | 111 | DTSTART:20101103T120000Z |
@@ -138,26 +138,26 @@ discard block |
||
138 | 138 | TRANSP:TRANSPARENT |
139 | 139 | END:VEVENT |
140 | 140 | */ |
141 | - if ($type == 'event') |
|
142 | - { |
|
143 | - fwrite($calfileh,"BEGIN:VEVENT\n"); |
|
144 | - fwrite($calfileh,"UID:".$uid."\n"); |
|
145 | - if (! empty($email)) |
|
146 | - { |
|
147 | - fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n"); |
|
148 | - fwrite($calfileh,"CONTACT:MAILTO:".$email."\n"); |
|
149 | - } |
|
150 | - if (! empty($url)) |
|
151 | - { |
|
152 | - fwrite($calfileh,"URL:".$url."\n"); |
|
153 | - }; |
|
141 | + if ($type == 'event') |
|
142 | + { |
|
143 | + fwrite($calfileh,"BEGIN:VEVENT\n"); |
|
144 | + fwrite($calfileh,"UID:".$uid."\n"); |
|
145 | + if (! empty($email)) |
|
146 | + { |
|
147 | + fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n"); |
|
148 | + fwrite($calfileh,"CONTACT:MAILTO:".$email."\n"); |
|
149 | + } |
|
150 | + if (! empty($url)) |
|
151 | + { |
|
152 | + fwrite($calfileh,"URL:".$url."\n"); |
|
153 | + }; |
|
154 | 154 | |
155 | 155 | if ($created) fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n"); |
156 | 156 | if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n"); |
157 | 157 | fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n"); |
158 | - fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n"); |
|
158 | + fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n"); |
|
159 | 159 | |
160 | - /* Other keys: |
|
160 | + /* Other keys: |
|
161 | 161 | // Status values for a "VEVENT" |
162 | 162 | statvalue = "TENTATIVE" ;Indicates event is |
163 | 163 | ;tentative. |
@@ -174,86 +174,86 @@ discard block |
||
174 | 174 | / "FINAL" ;Indicates journal is final. |
175 | 175 | / "CANCELLED" ;Indicates journal is removed. |
176 | 176 | */ |
177 | - //fwrite($calfileh,"CLASS:PUBLIC\n"); // PUBLIC, PRIVATE, CONFIDENTIAL |
|
177 | + //fwrite($calfileh,"CLASS:PUBLIC\n"); // PUBLIC, PRIVATE, CONFIDENTIAL |
|
178 | 178 | //fwrite($calfileh,"X-MICROSOFT-CDO-BUSYSTATUS:1\n"); |
179 | 179 | //ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;CN=Laurent Destailleur;X-NUM-GUESTS=0:mailto:[email protected] |
180 | 180 | |
181 | 181 | if (! empty($location)) fwrite($calfileh,"LOCATION:".$encoding.$location."\n"); |
182 | - if ($fulldayevent) fwrite($calfileh,"X-FUNAMBOL-ALLDAY:1\n"); |
|
182 | + if ($fulldayevent) fwrite($calfileh,"X-FUNAMBOL-ALLDAY:1\n"); |
|
183 | 183 | if ($fulldayevent) fwrite($calfileh,"X-MICROSOFT-CDO-ALLDAYEVENT:1\n"); |
184 | 184 | |
185 | - // Date must be GMT dates |
|
186 | - // Current date |
|
187 | - fwrite($calfileh,"DTSTAMP:".dol_print_date($now,'dayhourxcard',true)."\n"); |
|
188 | - // Start date |
|
185 | + // Date must be GMT dates |
|
186 | + // Current date |
|
187 | + fwrite($calfileh,"DTSTAMP:".dol_print_date($now,'dayhourxcard',true)."\n"); |
|
188 | + // Start date |
|
189 | 189 | $prefix=''; |
190 | 190 | $startdatef = dol_print_date($startdate,'dayhourxcard',true); |
191 | 191 | if ($fulldayevent) |
192 | - { |
|
192 | + { |
|
193 | 193 | $prefix=';VALUE=DATE'; |
194 | - $startdatef = dol_print_date($startdate,'dayxcard',false); // Local time |
|
195 | - } |
|
196 | - fwrite($calfileh,"DTSTART".$prefix.":".$startdatef."\n"); |
|
194 | + $startdatef = dol_print_date($startdate,'dayxcard',false); // Local time |
|
195 | + } |
|
196 | + fwrite($calfileh,"DTSTART".$prefix.":".$startdatef."\n"); |
|
197 | 197 | // End date |
198 | - if ($fulldayevent) |
|
199 | - { |
|
200 | - if (empty($enddate)) $enddate=dol_time_plus_duree($startdate,1,'d'); |
|
201 | - } |
|
202 | - else |
|
203 | - { |
|
198 | + if ($fulldayevent) |
|
199 | + { |
|
200 | + if (empty($enddate)) $enddate=dol_time_plus_duree($startdate,1,'d'); |
|
201 | + } |
|
202 | + else |
|
203 | + { |
|
204 | 204 | if (empty($enddate)) $enddate=$startdate+$duration; |
205 | - } |
|
205 | + } |
|
206 | 206 | $prefix=''; |
207 | - $enddatef = dol_print_date($enddate,'dayhourxcard',true); |
|
208 | - if ($fulldayevent) |
|
209 | - { |
|
207 | + $enddatef = dol_print_date($enddate,'dayhourxcard',true); |
|
208 | + if ($fulldayevent) |
|
209 | + { |
|
210 | 210 | $prefix=';VALUE=DATE'; |
211 | - $enddatef = dol_print_date($enddate+1,'dayxcard',false); |
|
212 | - //$enddatef .= dol_print_date($enddate+1,'dayhourxcard',false); // Local time |
|
213 | - } |
|
211 | + $enddatef = dol_print_date($enddate+1,'dayxcard',false); |
|
212 | + //$enddatef .= dol_print_date($enddate+1,'dayhourxcard',false); // Local time |
|
213 | + } |
|
214 | 214 | fwrite($calfileh,"DTEND".$prefix.":".$enddatef."\n"); |
215 | - fwrite($calfileh,'STATUS:CONFIRMED'."\n"); |
|
216 | - if (! empty($transparency)) fwrite($calfileh,"TRANSP:".$transparency."\n"); |
|
217 | - if (! empty($category)) fwrite($calfileh,"CATEGORIES:".$encoding.$category."\n"); |
|
218 | - fwrite($calfileh,"END:VEVENT\n"); |
|
219 | - } |
|
220 | - |
|
221 | - // Output the vCard/iCal VTODO object |
|
222 | - // ... |
|
223 | - //PERCENT-COMPLETE:39 |
|
224 | - |
|
225 | - // Output the vCard/iCal VJOURNAL object |
|
226 | - if ($type == 'journal') |
|
227 | - { |
|
228 | - fwrite($calfileh,"BEGIN:VJOURNAL\n"); |
|
229 | - fwrite($calfileh,"UID:".$uid."\n"); |
|
230 | - if (! empty($email)) |
|
231 | - { |
|
232 | - fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n"); |
|
233 | - fwrite($calfileh,"CONTACT:MAILTO:".$email."\n"); |
|
234 | - } |
|
235 | - if (! empty($url)) |
|
236 | - { |
|
237 | - fwrite($calfileh,"URL:".$url."\n"); |
|
238 | - }; |
|
215 | + fwrite($calfileh,'STATUS:CONFIRMED'."\n"); |
|
216 | + if (! empty($transparency)) fwrite($calfileh,"TRANSP:".$transparency."\n"); |
|
217 | + if (! empty($category)) fwrite($calfileh,"CATEGORIES:".$encoding.$category."\n"); |
|
218 | + fwrite($calfileh,"END:VEVENT\n"); |
|
219 | + } |
|
220 | + |
|
221 | + // Output the vCard/iCal VTODO object |
|
222 | + // ... |
|
223 | + //PERCENT-COMPLETE:39 |
|
224 | + |
|
225 | + // Output the vCard/iCal VJOURNAL object |
|
226 | + if ($type == 'journal') |
|
227 | + { |
|
228 | + fwrite($calfileh,"BEGIN:VJOURNAL\n"); |
|
229 | + fwrite($calfileh,"UID:".$uid."\n"); |
|
230 | + if (! empty($email)) |
|
231 | + { |
|
232 | + fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n"); |
|
233 | + fwrite($calfileh,"CONTACT:MAILTO:".$email."\n"); |
|
234 | + } |
|
235 | + if (! empty($url)) |
|
236 | + { |
|
237 | + fwrite($calfileh,"URL:".$url."\n"); |
|
238 | + }; |
|
239 | 239 | |
240 | 240 | if ($created) fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n"); |
241 | 241 | if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n"); |
242 | - fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n"); |
|
243 | - fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n"); |
|
244 | - fwrite($calfileh,'STATUS:CONFIRMED'."\n"); |
|
245 | - fwrite($calfileh,"CATEGORIES:".$category."\n"); |
|
246 | - fwrite($calfileh,"LOCATION:".$location."\n"); |
|
247 | - fwrite($calfileh,"TRANSP:OPAQUE\n"); |
|
248 | - fwrite($calfileh,"CLASS:CONFIDENTIAL\n"); |
|
249 | - fwrite($calfileh,"DTSTAMP:".dol_print_date($startdatef,'dayhourxcard',true)."\n"); |
|
242 | + fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n"); |
|
243 | + fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n"); |
|
244 | + fwrite($calfileh,'STATUS:CONFIRMED'."\n"); |
|
245 | + fwrite($calfileh,"CATEGORIES:".$category."\n"); |
|
246 | + fwrite($calfileh,"LOCATION:".$location."\n"); |
|
247 | + fwrite($calfileh,"TRANSP:OPAQUE\n"); |
|
248 | + fwrite($calfileh,"CLASS:CONFIDENTIAL\n"); |
|
249 | + fwrite($calfileh,"DTSTAMP:".dol_print_date($startdatef,'dayhourxcard',true)."\n"); |
|
250 | 250 | |
251 | - fwrite($calfileh,"END:VJOURNAL\n"); |
|
252 | - } |
|
251 | + fwrite($calfileh,"END:VJOURNAL\n"); |
|
252 | + } |
|
253 | 253 | |
254 | 254 | |
255 | - // Put other info in comment |
|
256 | - /* |
|
255 | + // Put other info in comment |
|
256 | + /* |
|
257 | 257 | $comment=array(); |
258 | 258 | $comment ['eid'] = $eid; |
259 | 259 | $comment ['url'] = $linktoevent; |
@@ -263,21 +263,21 @@ discard block |
||
263 | 263 | $comment ['enddate'] = $enddate; |
264 | 264 | fwrite($calfileh,"COMMENT:" . serialize ($comment) . "\n"); |
265 | 265 | */ |
266 | - } |
|
267 | - } |
|
268 | - |
|
269 | - // Footer |
|
270 | - fwrite($calfileh,"END:VCALENDAR"); |
|
271 | - |
|
272 | - fclose($calfileh); |
|
273 | - if (! empty($conf->global->MAIN_UMASK)) |
|
274 | - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
275 | - } |
|
276 | - else |
|
277 | - { |
|
278 | - dol_syslog("xcal.lib.php::build_calfile Failed to open file ".$outputfile." for writing"); |
|
279 | - return -2; |
|
280 | - } |
|
266 | + } |
|
267 | + } |
|
268 | + |
|
269 | + // Footer |
|
270 | + fwrite($calfileh,"END:VCALENDAR"); |
|
271 | + |
|
272 | + fclose($calfileh); |
|
273 | + if (! empty($conf->global->MAIN_UMASK)) |
|
274 | + @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
275 | + } |
|
276 | + else |
|
277 | + { |
|
278 | + dol_syslog("xcal.lib.php::build_calfile Failed to open file ".$outputfile." for writing"); |
|
279 | + return -2; |
|
280 | + } |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
@@ -294,97 +294,97 @@ discard block |
||
294 | 294 | */ |
295 | 295 | function build_rssfile($format,$title,$desc,$events_array,$outputfile,$filter='') |
296 | 296 | { |
297 | - global $user,$conf,$langs; |
|
298 | - global $dolibarr_main_url_root; |
|
297 | + global $user,$conf,$langs; |
|
298 | + global $dolibarr_main_url_root; |
|
299 | 299 | |
300 | - dol_syslog("xcal.lib.php::build_rssfile Build rss file ".$outputfile." to format ".$format); |
|
300 | + dol_syslog("xcal.lib.php::build_rssfile Build rss file ".$outputfile." to format ".$format); |
|
301 | 301 | |
302 | - if (empty($outputfile)) return -1; |
|
302 | + if (empty($outputfile)) return -1; |
|
303 | 303 | |
304 | - $fichier=fopen($outputfile,'w'); |
|
305 | - if ($fichier) |
|
306 | - { |
|
307 | - $date=date("r"); |
|
304 | + $fichier=fopen($outputfile,'w'); |
|
305 | + if ($fichier) |
|
306 | + { |
|
307 | + $date=date("r"); |
|
308 | 308 | |
309 | - // Print header |
|
310 | - $form='<?xml version="1.0" encoding="'.$langs->charset_output.'"?>'; |
|
311 | - fwrite($fichier, $form); |
|
312 | - fwrite($fichier, "\n"); |
|
313 | - $form='<rss version="2.0">'; |
|
314 | - fwrite($fichier, $form); |
|
315 | - fwrite($fichier, "\n"); |
|
309 | + // Print header |
|
310 | + $form='<?xml version="1.0" encoding="'.$langs->charset_output.'"?>'; |
|
311 | + fwrite($fichier, $form); |
|
312 | + fwrite($fichier, "\n"); |
|
313 | + $form='<rss version="2.0">'; |
|
314 | + fwrite($fichier, $form); |
|
315 | + fwrite($fichier, "\n"); |
|
316 | 316 | |
317 | - $form="<channel>\n<title>".$title."</title>\n"; |
|
318 | - fwrite($fichier, $form); |
|
317 | + $form="<channel>\n<title>".$title."</title>\n"; |
|
318 | + fwrite($fichier, $form); |
|
319 | 319 | |
320 | - $form='<description><![CDATA['.$desc.'.]]></description>'."\n". |
|
320 | + $form='<description><![CDATA['.$desc.'.]]></description>'."\n". |
|
321 | 321 | // '<language>fr</language>'."\n". |
322 | - '<copyright>Dolibarr</copyright>'."\n". |
|
323 | - '<lastBuildDate>'.$date.'</lastBuildDate>'."\n". |
|
324 | - '<generator>Dolibarr</generator>'."\n"; |
|
325 | - |
|
326 | - // Define $urlwithroot |
|
327 | - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); |
|
328 | - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
329 | - //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current |
|
330 | - $url=$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY); |
|
331 | - $form.='<link><![CDATA['.$url.']]></link>'."\n"; |
|
332 | - |
|
333 | - //print $form; |
|
334 | - fwrite($fichier, $form); |
|
335 | - |
|
336 | - |
|
337 | - foreach ($events_array as $key => $event) |
|
338 | - { |
|
339 | - $eventqualified=true; |
|
340 | - if ($filter) |
|
341 | - { |
|
342 | - // TODO Add a filter |
|
343 | - |
|
344 | - $eventqualified=false; |
|
345 | - } |
|
346 | - |
|
347 | - if ($eventqualified) |
|
348 | - { |
|
349 | - $uid = $event['uid']; |
|
350 | - $startdate = $event['startdate']; |
|
351 | - $summary = $event['summary']; |
|
352 | - $url = $event['url']; |
|
353 | - $author = $event['author']; |
|
354 | - $category = $event['category']; |
|
355 | - /* No place inside a RSS |
|
322 | + '<copyright>Dolibarr</copyright>'."\n". |
|
323 | + '<lastBuildDate>'.$date.'</lastBuildDate>'."\n". |
|
324 | + '<generator>Dolibarr</generator>'."\n"; |
|
325 | + |
|
326 | + // Define $urlwithroot |
|
327 | + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); |
|
328 | + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
329 | + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current |
|
330 | + $url=$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY); |
|
331 | + $form.='<link><![CDATA['.$url.']]></link>'."\n"; |
|
332 | + |
|
333 | + //print $form; |
|
334 | + fwrite($fichier, $form); |
|
335 | + |
|
336 | + |
|
337 | + foreach ($events_array as $key => $event) |
|
338 | + { |
|
339 | + $eventqualified=true; |
|
340 | + if ($filter) |
|
341 | + { |
|
342 | + // TODO Add a filter |
|
343 | + |
|
344 | + $eventqualified=false; |
|
345 | + } |
|
346 | + |
|
347 | + if ($eventqualified) |
|
348 | + { |
|
349 | + $uid = $event['uid']; |
|
350 | + $startdate = $event['startdate']; |
|
351 | + $summary = $event['summary']; |
|
352 | + $url = $event['url']; |
|
353 | + $author = $event['author']; |
|
354 | + $category = $event['category']; |
|
355 | + /* No place inside a RSS |
|
356 | 356 | $priority = $event['priority']; |
357 | 357 | $fulldayevent = $event['fulldayevent']; |
358 | 358 | $location = $event['location']; |
359 | 359 | $email = $event['email']; |
360 | 360 | */ |
361 | - $description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']); |
|
362 | - $description=dol_string_nohtmltag($description,0); // Remove html tags |
|
363 | - |
|
364 | - fwrite($fichier, "<item>\n"); |
|
365 | - fwrite($fichier, "<title><![CDATA[".$summary."]]></title>\n"); |
|
366 | - fwrite($fichier, "<link><![CDATA[".$url."]]></link>\n"); |
|
367 | - fwrite($fichier, "<author><![CDATA[".$author."]]></author>\n"); |
|
368 | - fwrite($fichier, "<category><![CDATA[".$category."]]></category>\n"); |
|
369 | - fwrite($fichier, "<description><![CDATA["); |
|
370 | - if ($description) fwrite($fichier, $description); |
|
371 | - //else fwrite($fichier, 'NoDesc'); |
|
372 | - fwrite($fichier, "]]></description>\n"); |
|
373 | - fwrite($fichier, "<pubDate>".date("r", $startdate)."</pubDate>\n"); |
|
374 | - fwrite($fichier, "<guid isPermaLink=\"true\"><![CDATA[".$uid."]]></guid>\n"); |
|
375 | - fwrite($fichier, "<source><![CDATA[Dolibarr]]></source>\n"); |
|
376 | - fwrite($fichier, "</item>\n"); |
|
377 | - } |
|
378 | - } |
|
379 | - |
|
380 | - fwrite($fichier, '</channel>'); |
|
381 | - fwrite($fichier, "\n"); |
|
382 | - fwrite($fichier, '</rss>'); |
|
383 | - |
|
384 | - fclose($fichier); |
|
385 | - if (! empty($conf->global->MAIN_UMASK)) |
|
386 | - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
387 | - } |
|
361 | + $description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']); |
|
362 | + $description=dol_string_nohtmltag($description,0); // Remove html tags |
|
363 | + |
|
364 | + fwrite($fichier, "<item>\n"); |
|
365 | + fwrite($fichier, "<title><![CDATA[".$summary."]]></title>\n"); |
|
366 | + fwrite($fichier, "<link><![CDATA[".$url."]]></link>\n"); |
|
367 | + fwrite($fichier, "<author><![CDATA[".$author."]]></author>\n"); |
|
368 | + fwrite($fichier, "<category><![CDATA[".$category."]]></category>\n"); |
|
369 | + fwrite($fichier, "<description><![CDATA["); |
|
370 | + if ($description) fwrite($fichier, $description); |
|
371 | + //else fwrite($fichier, 'NoDesc'); |
|
372 | + fwrite($fichier, "]]></description>\n"); |
|
373 | + fwrite($fichier, "<pubDate>".date("r", $startdate)."</pubDate>\n"); |
|
374 | + fwrite($fichier, "<guid isPermaLink=\"true\"><![CDATA[".$uid."]]></guid>\n"); |
|
375 | + fwrite($fichier, "<source><![CDATA[Dolibarr]]></source>\n"); |
|
376 | + fwrite($fichier, "</item>\n"); |
|
377 | + } |
|
378 | + } |
|
379 | + |
|
380 | + fwrite($fichier, '</channel>'); |
|
381 | + fwrite($fichier, "\n"); |
|
382 | + fwrite($fichier, '</rss>'); |
|
383 | + |
|
384 | + fclose($fichier); |
|
385 | + if (! empty($conf->global->MAIN_UMASK)) |
|
386 | + @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
387 | + } |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
@@ -397,25 +397,25 @@ discard block |
||
397 | 397 | */ |
398 | 398 | function format_cal($format,$string) |
399 | 399 | { |
400 | - global $conf; |
|
401 | - |
|
402 | - $newstring=$string; |
|
403 | - |
|
404 | - if ($format == 'vcal') |
|
405 | - { |
|
406 | - $newstring=quotedPrintEncode($newstring); |
|
407 | - } |
|
408 | - if ($format == 'ical') |
|
409 | - { |
|
410 | - // Replace new lines chars by '\n' |
|
411 | - $newstring=preg_replace('/'."\r\n".'/i',"\n",$newstring); |
|
412 | - $newstring=preg_replace('/'."\n\r".'/i',"\n",$newstring); |
|
413 | - $newstring=preg_replace('/'."\n".'/i','\n',$newstring); |
|
414 | - // Must not exceed 75 char. Cut with "\r\n"+Space |
|
415 | - $newstring=calEncode($newstring); |
|
416 | - } |
|
417 | - |
|
418 | - return $newstring; |
|
400 | + global $conf; |
|
401 | + |
|
402 | + $newstring=$string; |
|
403 | + |
|
404 | + if ($format == 'vcal') |
|
405 | + { |
|
406 | + $newstring=quotedPrintEncode($newstring); |
|
407 | + } |
|
408 | + if ($format == 'ical') |
|
409 | + { |
|
410 | + // Replace new lines chars by '\n' |
|
411 | + $newstring=preg_replace('/'."\r\n".'/i',"\n",$newstring); |
|
412 | + $newstring=preg_replace('/'."\n\r".'/i',"\n",$newstring); |
|
413 | + $newstring=preg_replace('/'."\n".'/i','\n',$newstring); |
|
414 | + // Must not exceed 75 char. Cut with "\r\n"+Space |
|
415 | + $newstring=calEncode($newstring); |
|
416 | + } |
|
417 | + |
|
418 | + return $newstring; |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | /** |
@@ -427,45 +427,45 @@ discard block |
||
427 | 427 | */ |
428 | 428 | function calEncode($line) |
429 | 429 | { |
430 | - $out = ''; |
|
431 | - |
|
432 | - $newpara = ''; |
|
433 | - |
|
434 | - // If mb_ functions exists, it's better to use them |
|
435 | - if (function_exists('mb_strlen')) |
|
436 | - { |
|
437 | - $strlength=mb_strlen($line, 'UTF-8'); |
|
438 | - for ($j = 0; $j <= ($strlength - 1); $j++) |
|
439 | - { |
|
440 | - $char = mb_substr($line, $j, 1, 'UTF-8'); // Take char at position $j |
|
441 | - |
|
442 | - if ((mb_strlen($newpara, 'UTF-8') + mb_strlen($char, 'UTF-8')) >= 75) |
|
443 | - { |
|
444 | - $out .= $newpara . "\r\n "; // CRLF + Space for cal |
|
445 | - $newpara = ''; |
|
446 | - } |
|
447 | - $newpara .= $char; |
|
448 | - } |
|
449 | - $out .= $newpara; |
|
450 | - } |
|
451 | - else |
|
452 | - { |
|
453 | - $strlength=dol_strlen($line); |
|
454 | - for ($j = 0; $j <= ($strlength - 1); $j++) |
|
455 | - { |
|
456 | - $char = substr($line, $j, 1); // Take char at position $j |
|
457 | - |
|
458 | - if ((dol_strlen($newpara) + dol_strlen($char)) >= 75 ) |
|
459 | - { |
|
460 | - $out .= $newpara . "\r\n "; // CRLF + Space for cal |
|
461 | - $newpara = ''; |
|
462 | - } |
|
463 | - $newpara .= $char; |
|
464 | - } |
|
465 | - $out .= $newpara; |
|
466 | - } |
|
467 | - |
|
468 | - return trim($out); |
|
430 | + $out = ''; |
|
431 | + |
|
432 | + $newpara = ''; |
|
433 | + |
|
434 | + // If mb_ functions exists, it's better to use them |
|
435 | + if (function_exists('mb_strlen')) |
|
436 | + { |
|
437 | + $strlength=mb_strlen($line, 'UTF-8'); |
|
438 | + for ($j = 0; $j <= ($strlength - 1); $j++) |
|
439 | + { |
|
440 | + $char = mb_substr($line, $j, 1, 'UTF-8'); // Take char at position $j |
|
441 | + |
|
442 | + if ((mb_strlen($newpara, 'UTF-8') + mb_strlen($char, 'UTF-8')) >= 75) |
|
443 | + { |
|
444 | + $out .= $newpara . "\r\n "; // CRLF + Space for cal |
|
445 | + $newpara = ''; |
|
446 | + } |
|
447 | + $newpara .= $char; |
|
448 | + } |
|
449 | + $out .= $newpara; |
|
450 | + } |
|
451 | + else |
|
452 | + { |
|
453 | + $strlength=dol_strlen($line); |
|
454 | + for ($j = 0; $j <= ($strlength - 1); $j++) |
|
455 | + { |
|
456 | + $char = substr($line, $j, 1); // Take char at position $j |
|
457 | + |
|
458 | + if ((dol_strlen($newpara) + dol_strlen($char)) >= 75 ) |
|
459 | + { |
|
460 | + $out .= $newpara . "\r\n "; // CRLF + Space for cal |
|
461 | + $newpara = ''; |
|
462 | + } |
|
463 | + $newpara .= $char; |
|
464 | + } |
|
465 | + $out .= $newpara; |
|
466 | + } |
|
467 | + |
|
468 | + return trim($out); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | |
@@ -478,33 +478,33 @@ discard block |
||
478 | 478 | */ |
479 | 479 | function quotedPrintEncode($str,$forcal=0) |
480 | 480 | { |
481 | - $lines = preg_split("/\r\n/", $str); |
|
482 | - $out = ''; |
|
483 | - |
|
484 | - foreach ($lines as $line) |
|
485 | - { |
|
486 | - $newpara = ''; |
|
487 | - |
|
488 | - $strlength=strlen($line); // Do not use dol_strlen here, we need number of bytes |
|
489 | - for ($j = 0; $j <= ($strlength - 1); $j++) |
|
490 | - { |
|
491 | - $char = substr($line, $j, 1); |
|
492 | - $ascii = ord($char); |
|
493 | - |
|
494 | - if ( $ascii < 32 || $ascii == 61 || $ascii > 126 ) |
|
495 | - $char = '=' . strtoupper(sprintf("%02X", $ascii)); |
|
496 | - |
|
497 | - if ((strlen($newpara) + strlen($char)) >= 76 ) // Do not use dol_strlen here, we need number of bytes |
|
498 | - { |
|
499 | - $out .= $newpara . '=' . "\r\n"; // CRLF |
|
500 | - if ($forcal) $out .= " "; // + Space for cal |
|
501 | - $newpara = ''; |
|
502 | - } |
|
503 | - $newpara .= $char; |
|
504 | - } |
|
505 | - $out .= $newpara; |
|
506 | - } |
|
507 | - return trim($out); |
|
481 | + $lines = preg_split("/\r\n/", $str); |
|
482 | + $out = ''; |
|
483 | + |
|
484 | + foreach ($lines as $line) |
|
485 | + { |
|
486 | + $newpara = ''; |
|
487 | + |
|
488 | + $strlength=strlen($line); // Do not use dol_strlen here, we need number of bytes |
|
489 | + for ($j = 0; $j <= ($strlength - 1); $j++) |
|
490 | + { |
|
491 | + $char = substr($line, $j, 1); |
|
492 | + $ascii = ord($char); |
|
493 | + |
|
494 | + if ( $ascii < 32 || $ascii == 61 || $ascii > 126 ) |
|
495 | + $char = '=' . strtoupper(sprintf("%02X", $ascii)); |
|
496 | + |
|
497 | + if ((strlen($newpara) + strlen($char)) >= 76 ) // Do not use dol_strlen here, we need number of bytes |
|
498 | + { |
|
499 | + $out .= $newpara . '=' . "\r\n"; // CRLF |
|
500 | + if ($forcal) $out .= " "; // + Space for cal |
|
501 | + $newpara = ''; |
|
502 | + } |
|
503 | + $newpara .= $char; |
|
504 | + } |
|
505 | + $out .= $newpara; |
|
506 | + } |
|
507 | + return trim($out); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | /** |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | */ |
516 | 516 | function quotedPrintDecode($str) |
517 | 517 | { |
518 | - $out = preg_replace('/=\r?\n/', '', $str); |
|
519 | - $out = quoted_printable_decode($out); // Available with PHP 4+ |
|
520 | - return trim($out); |
|
518 | + $out = preg_replace('/=\r?\n/', '', $str); |
|
519 | + $out = quoted_printable_decode($out); // Available with PHP 4+ |
|
520 | + return trim($out); |
|
521 | 521 | } |
@@ -32,66 +32,66 @@ discard block |
||
32 | 32 | * @param string $outputfile Output file |
33 | 33 | * @return int <0 if ko, Nb of events in file if ok |
34 | 34 | */ |
35 | -function build_calfile($format,$title,$desc,$events_array,$outputfile) |
|
35 | +function build_calfile($format, $title, $desc, $events_array, $outputfile) |
|
36 | 36 | { |
37 | - global $conf,$langs; |
|
37 | + global $conf, $langs; |
|
38 | 38 | |
39 | 39 | dol_syslog("xcal.lib.php::build_calfile Build cal file ".$outputfile." to format ".$format); |
40 | 40 | |
41 | 41 | if (empty($outputfile)) return -1; |
42 | 42 | |
43 | 43 | // Note: A cal file is an UTF8 encoded file |
44 | - $calfileh=fopen($outputfile,'w'); |
|
44 | + $calfileh = fopen($outputfile, 'w'); |
|
45 | 45 | if ($calfileh) |
46 | 46 | { |
47 | 47 | include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
48 | - $now=dol_now(); |
|
48 | + $now = dol_now(); |
|
49 | 49 | |
50 | - $encoding=''; |
|
51 | - if ($format == 'vcal') $encoding='ENCODING=QUOTED-PRINTABLE:'; |
|
50 | + $encoding = ''; |
|
51 | + if ($format == 'vcal') $encoding = 'ENCODING=QUOTED-PRINTABLE:'; |
|
52 | 52 | |
53 | 53 | // Print header |
54 | - fwrite($calfileh,"BEGIN:VCALENDAR\n"); |
|
55 | - fwrite($calfileh,"VERSION:2.0\n"); |
|
56 | - fwrite($calfileh,"METHOD:PUBLISH\n"); |
|
54 | + fwrite($calfileh, "BEGIN:VCALENDAR\n"); |
|
55 | + fwrite($calfileh, "VERSION:2.0\n"); |
|
56 | + fwrite($calfileh, "METHOD:PUBLISH\n"); |
|
57 | 57 | //fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."//EN\n"); |
58 | - fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."\n"); |
|
59 | - fwrite($calfileh,"CALSCALE:GREGORIAN\n"); |
|
60 | - fwrite($calfileh,"X-WR-CALNAME:".$encoding.format_cal($format,$title)."\n"); |
|
61 | - fwrite($calfileh,"X-WR-CALDESC:".$encoding.format_cal($format,$desc)."\n"); |
|
58 | + fwrite($calfileh, "PRODID:-//DOLIBARR ".DOL_VERSION."\n"); |
|
59 | + fwrite($calfileh, "CALSCALE:GREGORIAN\n"); |
|
60 | + fwrite($calfileh, "X-WR-CALNAME:".$encoding.format_cal($format, $title)."\n"); |
|
61 | + fwrite($calfileh, "X-WR-CALDESC:".$encoding.format_cal($format, $desc)."\n"); |
|
62 | 62 | //fwrite($calfileh,"X-WR-TIMEZONE:Europe/Paris\n"); |
63 | - if (! empty($conf->global->MAIN_AGENDA_EXPORT_CACHE) |
|
64 | - && $conf->global->MAIN_AGENDA_EXPORT_CACHE > 60){ |
|
65 | - $hh=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'hour'); |
|
66 | - $mm=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'min'); |
|
67 | - $ss=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'sec'); |
|
68 | - fwrite($calfileh,"X-PUBLISHED-TTL: P".$hh."H".$mm."M".$ss."S\n"); |
|
63 | + if (!empty($conf->global->MAIN_AGENDA_EXPORT_CACHE) |
|
64 | + && $conf->global->MAIN_AGENDA_EXPORT_CACHE > 60) { |
|
65 | + $hh = convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE, 'hour'); |
|
66 | + $mm = convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE, 'min'); |
|
67 | + $ss = convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE, 'sec'); |
|
68 | + fwrite($calfileh, "X-PUBLISHED-TTL: P".$hh."H".$mm."M".$ss."S\n"); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | foreach ($events_array as $key => $event) |
72 | 72 | { |
73 | - $eventqualified=true; |
|
73 | + $eventqualified = true; |
|
74 | 74 | if ($eventqualified) |
75 | 75 | { |
76 | 76 | // See http://fr.wikipedia.org/wiki/ICalendar for format |
77 | 77 | // See http://www.ietf.org/rfc/rfc2445.txt for RFC |
78 | - $uid = $event['uid']; |
|
79 | - $type = $event['type']; |
|
80 | - $startdate = $event['startdate']; |
|
78 | + $uid = $event['uid']; |
|
79 | + $type = $event['type']; |
|
80 | + $startdate = $event['startdate']; |
|
81 | 81 | $duration = $event['duration']; |
82 | - $enddate = $event['enddate']; |
|
83 | - $summary = $event['summary']; |
|
82 | + $enddate = $event['enddate']; |
|
83 | + $summary = $event['summary']; |
|
84 | 84 | $category = $event['category']; |
85 | 85 | $priority = $event['priority']; |
86 | 86 | $fulldayevent = $event['fulldayevent']; |
87 | 87 | $location = $event['location']; |
88 | - $email = $event['email']; |
|
89 | - $url = $event['url']; |
|
90 | - $transparency = $event['transparency']; // OPAQUE (busy) or TRANSPARENT (not busy) |
|
91 | - $description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']); |
|
92 | - $description=dol_string_nohtmltag($description,0); // Remove html tags |
|
93 | - $created = $event['created']; |
|
94 | - $modified = $event['modified']; |
|
88 | + $email = $event['email']; |
|
89 | + $url = $event['url']; |
|
90 | + $transparency = $event['transparency']; // OPAQUE (busy) or TRANSPARENT (not busy) |
|
91 | + $description = preg_replace('/<br[\s\/]?>/i', "\n", $event['desc']); |
|
92 | + $description = dol_string_nohtmltag($description, 0); // Remove html tags |
|
93 | + $created = $event['created']; |
|
94 | + $modified = $event['modified']; |
|
95 | 95 | |
96 | 96 | // Uncomment for tests |
97 | 97 | //$summary="Resume"; |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | //$description="MemberValidatedInDolibarr gd gdf gd gdff\nNom: tgdf g dfgdf gfd r ter\nType: gdfgfdf dfg fd gfd gd gdf gdf gfd gdfg dfg ddf\nAuteur: AD01fg dgdgdfg df gdf gd"; |
100 | 100 | |
101 | 101 | // Format |
102 | - $summary=format_cal($format,$summary); |
|
103 | - $description=format_cal($format,$description); |
|
104 | - $category=format_cal($format,$category); |
|
105 | - $location=format_cal($format,$location); |
|
102 | + $summary = format_cal($format, $summary); |
|
103 | + $description = format_cal($format, $description); |
|
104 | + $category = format_cal($format, $category); |
|
105 | + $location = format_cal($format, $location); |
|
106 | 106 | |
107 | 107 | // Output the vCard/iCal VEVENT object |
108 | 108 | /* |
@@ -140,22 +140,22 @@ discard block |
||
140 | 140 | */ |
141 | 141 | if ($type == 'event') |
142 | 142 | { |
143 | - fwrite($calfileh,"BEGIN:VEVENT\n"); |
|
144 | - fwrite($calfileh,"UID:".$uid."\n"); |
|
145 | - if (! empty($email)) |
|
143 | + fwrite($calfileh, "BEGIN:VEVENT\n"); |
|
144 | + fwrite($calfileh, "UID:".$uid."\n"); |
|
145 | + if (!empty($email)) |
|
146 | 146 | { |
147 | - fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n"); |
|
148 | - fwrite($calfileh,"CONTACT:MAILTO:".$email."\n"); |
|
147 | + fwrite($calfileh, "ORGANIZER:MAILTO:".$email."\n"); |
|
148 | + fwrite($calfileh, "CONTACT:MAILTO:".$email."\n"); |
|
149 | 149 | } |
150 | - if (! empty($url)) |
|
150 | + if (!empty($url)) |
|
151 | 151 | { |
152 | - fwrite($calfileh,"URL:".$url."\n"); |
|
152 | + fwrite($calfileh, "URL:".$url."\n"); |
|
153 | 153 | }; |
154 | 154 | |
155 | - if ($created) fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n"); |
|
156 | - if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n"); |
|
157 | - fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n"); |
|
158 | - fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n"); |
|
155 | + if ($created) fwrite($calfileh, "CREATED:".dol_print_date($created, 'dayhourxcard', true)."\n"); |
|
156 | + if ($modified) fwrite($calfileh, "LAST-MODIFIED:".dol_print_date($modified, 'dayhourxcard', true)."\n"); |
|
157 | + fwrite($calfileh, "SUMMARY:".$encoding.$summary."\n"); |
|
158 | + fwrite($calfileh, "DESCRIPTION:".$encoding.$description."\n"); |
|
159 | 159 | |
160 | 160 | /* Other keys: |
161 | 161 | // Status values for a "VEVENT" |
@@ -178,44 +178,44 @@ discard block |
||
178 | 178 | //fwrite($calfileh,"X-MICROSOFT-CDO-BUSYSTATUS:1\n"); |
179 | 179 | //ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;CN=Laurent Destailleur;X-NUM-GUESTS=0:mailto:[email protected] |
180 | 180 | |
181 | - if (! empty($location)) fwrite($calfileh,"LOCATION:".$encoding.$location."\n"); |
|
182 | - if ($fulldayevent) fwrite($calfileh,"X-FUNAMBOL-ALLDAY:1\n"); |
|
183 | - if ($fulldayevent) fwrite($calfileh,"X-MICROSOFT-CDO-ALLDAYEVENT:1\n"); |
|
181 | + if (!empty($location)) fwrite($calfileh, "LOCATION:".$encoding.$location."\n"); |
|
182 | + if ($fulldayevent) fwrite($calfileh, "X-FUNAMBOL-ALLDAY:1\n"); |
|
183 | + if ($fulldayevent) fwrite($calfileh, "X-MICROSOFT-CDO-ALLDAYEVENT:1\n"); |
|
184 | 184 | |
185 | 185 | // Date must be GMT dates |
186 | 186 | // Current date |
187 | - fwrite($calfileh,"DTSTAMP:".dol_print_date($now,'dayhourxcard',true)."\n"); |
|
187 | + fwrite($calfileh, "DTSTAMP:".dol_print_date($now, 'dayhourxcard', true)."\n"); |
|
188 | 188 | // Start date |
189 | - $prefix=''; |
|
190 | - $startdatef = dol_print_date($startdate,'dayhourxcard',true); |
|
189 | + $prefix = ''; |
|
190 | + $startdatef = dol_print_date($startdate, 'dayhourxcard', true); |
|
191 | 191 | if ($fulldayevent) |
192 | 192 | { |
193 | - $prefix=';VALUE=DATE'; |
|
194 | - $startdatef = dol_print_date($startdate,'dayxcard',false); // Local time |
|
193 | + $prefix = ';VALUE=DATE'; |
|
194 | + $startdatef = dol_print_date($startdate, 'dayxcard', false); // Local time |
|
195 | 195 | } |
196 | - fwrite($calfileh,"DTSTART".$prefix.":".$startdatef."\n"); |
|
196 | + fwrite($calfileh, "DTSTART".$prefix.":".$startdatef."\n"); |
|
197 | 197 | // End date |
198 | 198 | if ($fulldayevent) |
199 | 199 | { |
200 | - if (empty($enddate)) $enddate=dol_time_plus_duree($startdate,1,'d'); |
|
200 | + if (empty($enddate)) $enddate = dol_time_plus_duree($startdate, 1, 'd'); |
|
201 | 201 | } |
202 | 202 | else |
203 | 203 | { |
204 | - if (empty($enddate)) $enddate=$startdate+$duration; |
|
204 | + if (empty($enddate)) $enddate = $startdate + $duration; |
|
205 | 205 | } |
206 | - $prefix=''; |
|
207 | - $enddatef = dol_print_date($enddate,'dayhourxcard',true); |
|
206 | + $prefix = ''; |
|
207 | + $enddatef = dol_print_date($enddate, 'dayhourxcard', true); |
|
208 | 208 | if ($fulldayevent) |
209 | 209 | { |
210 | - $prefix=';VALUE=DATE'; |
|
211 | - $enddatef = dol_print_date($enddate+1,'dayxcard',false); |
|
210 | + $prefix = ';VALUE=DATE'; |
|
211 | + $enddatef = dol_print_date($enddate + 1, 'dayxcard', false); |
|
212 | 212 | //$enddatef .= dol_print_date($enddate+1,'dayhourxcard',false); // Local time |
213 | 213 | } |
214 | - fwrite($calfileh,"DTEND".$prefix.":".$enddatef."\n"); |
|
215 | - fwrite($calfileh,'STATUS:CONFIRMED'."\n"); |
|
216 | - if (! empty($transparency)) fwrite($calfileh,"TRANSP:".$transparency."\n"); |
|
217 | - if (! empty($category)) fwrite($calfileh,"CATEGORIES:".$encoding.$category."\n"); |
|
218 | - fwrite($calfileh,"END:VEVENT\n"); |
|
214 | + fwrite($calfileh, "DTEND".$prefix.":".$enddatef."\n"); |
|
215 | + fwrite($calfileh, 'STATUS:CONFIRMED'."\n"); |
|
216 | + if (!empty($transparency)) fwrite($calfileh, "TRANSP:".$transparency."\n"); |
|
217 | + if (!empty($category)) fwrite($calfileh, "CATEGORIES:".$encoding.$category."\n"); |
|
218 | + fwrite($calfileh, "END:VEVENT\n"); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | // Output the vCard/iCal VTODO object |
@@ -225,30 +225,30 @@ discard block |
||
225 | 225 | // Output the vCard/iCal VJOURNAL object |
226 | 226 | if ($type == 'journal') |
227 | 227 | { |
228 | - fwrite($calfileh,"BEGIN:VJOURNAL\n"); |
|
229 | - fwrite($calfileh,"UID:".$uid."\n"); |
|
230 | - if (! empty($email)) |
|
228 | + fwrite($calfileh, "BEGIN:VJOURNAL\n"); |
|
229 | + fwrite($calfileh, "UID:".$uid."\n"); |
|
230 | + if (!empty($email)) |
|
231 | 231 | { |
232 | - fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n"); |
|
233 | - fwrite($calfileh,"CONTACT:MAILTO:".$email."\n"); |
|
232 | + fwrite($calfileh, "ORGANIZER:MAILTO:".$email."\n"); |
|
233 | + fwrite($calfileh, "CONTACT:MAILTO:".$email."\n"); |
|
234 | 234 | } |
235 | - if (! empty($url)) |
|
235 | + if (!empty($url)) |
|
236 | 236 | { |
237 | - fwrite($calfileh,"URL:".$url."\n"); |
|
237 | + fwrite($calfileh, "URL:".$url."\n"); |
|
238 | 238 | }; |
239 | 239 | |
240 | - if ($created) fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n"); |
|
241 | - if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n"); |
|
242 | - fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n"); |
|
243 | - fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n"); |
|
244 | - fwrite($calfileh,'STATUS:CONFIRMED'."\n"); |
|
245 | - fwrite($calfileh,"CATEGORIES:".$category."\n"); |
|
246 | - fwrite($calfileh,"LOCATION:".$location."\n"); |
|
247 | - fwrite($calfileh,"TRANSP:OPAQUE\n"); |
|
248 | - fwrite($calfileh,"CLASS:CONFIDENTIAL\n"); |
|
249 | - fwrite($calfileh,"DTSTAMP:".dol_print_date($startdatef,'dayhourxcard',true)."\n"); |
|
250 | - |
|
251 | - fwrite($calfileh,"END:VJOURNAL\n"); |
|
240 | + if ($created) fwrite($calfileh, "CREATED:".dol_print_date($created, 'dayhourxcard', true)."\n"); |
|
241 | + if ($modified) fwrite($calfileh, "LAST-MODIFIED:".dol_print_date($modified, 'dayhourxcard', true)."\n"); |
|
242 | + fwrite($calfileh, "SUMMARY:".$encoding.$summary."\n"); |
|
243 | + fwrite($calfileh, "DESCRIPTION:".$encoding.$description."\n"); |
|
244 | + fwrite($calfileh, 'STATUS:CONFIRMED'."\n"); |
|
245 | + fwrite($calfileh, "CATEGORIES:".$category."\n"); |
|
246 | + fwrite($calfileh, "LOCATION:".$location."\n"); |
|
247 | + fwrite($calfileh, "TRANSP:OPAQUE\n"); |
|
248 | + fwrite($calfileh, "CLASS:CONFIDENTIAL\n"); |
|
249 | + fwrite($calfileh, "DTSTAMP:".dol_print_date($startdatef, 'dayhourxcard', true)."\n"); |
|
250 | + |
|
251 | + fwrite($calfileh, "END:VJOURNAL\n"); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | |
@@ -267,10 +267,10 @@ discard block |
||
267 | 267 | } |
268 | 268 | |
269 | 269 | // Footer |
270 | - fwrite($calfileh,"END:VCALENDAR"); |
|
270 | + fwrite($calfileh, "END:VCALENDAR"); |
|
271 | 271 | |
272 | 272 | fclose($calfileh); |
273 | - if (! empty($conf->global->MAIN_UMASK)) |
|
273 | + if (!empty($conf->global->MAIN_UMASK)) |
|
274 | 274 | @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
275 | 275 | } |
276 | 276 | else |
@@ -292,43 +292,43 @@ discard block |
||
292 | 292 | * @param string $filter Filter |
293 | 293 | * @return int <0 if ko, Nb of events in file if ok |
294 | 294 | */ |
295 | -function build_rssfile($format,$title,$desc,$events_array,$outputfile,$filter='') |
|
295 | +function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter = '') |
|
296 | 296 | { |
297 | - global $user,$conf,$langs; |
|
297 | + global $user, $conf, $langs; |
|
298 | 298 | global $dolibarr_main_url_root; |
299 | 299 | |
300 | 300 | dol_syslog("xcal.lib.php::build_rssfile Build rss file ".$outputfile." to format ".$format); |
301 | 301 | |
302 | 302 | if (empty($outputfile)) return -1; |
303 | 303 | |
304 | - $fichier=fopen($outputfile,'w'); |
|
304 | + $fichier = fopen($outputfile, 'w'); |
|
305 | 305 | if ($fichier) |
306 | 306 | { |
307 | - $date=date("r"); |
|
307 | + $date = date("r"); |
|
308 | 308 | |
309 | 309 | // Print header |
310 | - $form='<?xml version="1.0" encoding="'.$langs->charset_output.'"?>'; |
|
310 | + $form = '<?xml version="1.0" encoding="'.$langs->charset_output.'"?>'; |
|
311 | 311 | fwrite($fichier, $form); |
312 | 312 | fwrite($fichier, "\n"); |
313 | - $form='<rss version="2.0">'; |
|
313 | + $form = '<rss version="2.0">'; |
|
314 | 314 | fwrite($fichier, $form); |
315 | 315 | fwrite($fichier, "\n"); |
316 | 316 | |
317 | - $form="<channel>\n<title>".$title."</title>\n"; |
|
317 | + $form = "<channel>\n<title>".$title."</title>\n"; |
|
318 | 318 | fwrite($fichier, $form); |
319 | 319 | |
320 | - $form='<description><![CDATA['.$desc.'.]]></description>'."\n". |
|
320 | + $form = '<description><![CDATA['.$desc.'.]]></description>'."\n". |
|
321 | 321 | // '<language>fr</language>'."\n". |
322 | 322 | '<copyright>Dolibarr</copyright>'."\n". |
323 | 323 | '<lastBuildDate>'.$date.'</lastBuildDate>'."\n". |
324 | 324 | '<generator>Dolibarr</generator>'."\n"; |
325 | 325 | |
326 | 326 | // Define $urlwithroot |
327 | - $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); |
|
328 | - $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
327 | + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); |
|
328 | + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file |
|
329 | 329 | //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current |
330 | - $url=$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY); |
|
331 | - $form.='<link><![CDATA['.$url.']]></link>'."\n"; |
|
330 | + $url = $urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY); |
|
331 | + $form .= '<link><![CDATA['.$url.']]></link>'."\n"; |
|
332 | 332 | |
333 | 333 | //print $form; |
334 | 334 | fwrite($fichier, $form); |
@@ -336,12 +336,12 @@ discard block |
||
336 | 336 | |
337 | 337 | foreach ($events_array as $key => $event) |
338 | 338 | { |
339 | - $eventqualified=true; |
|
339 | + $eventqualified = true; |
|
340 | 340 | if ($filter) |
341 | 341 | { |
342 | 342 | // TODO Add a filter |
343 | 343 | |
344 | - $eventqualified=false; |
|
344 | + $eventqualified = false; |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | if ($eventqualified) |
@@ -350,16 +350,16 @@ discard block |
||
350 | 350 | $startdate = $event['startdate']; |
351 | 351 | $summary = $event['summary']; |
352 | 352 | $url = $event['url']; |
353 | - $author = $event['author']; |
|
354 | - $category = $event['category']; |
|
353 | + $author = $event['author']; |
|
354 | + $category = $event['category']; |
|
355 | 355 | /* No place inside a RSS |
356 | 356 | $priority = $event['priority']; |
357 | 357 | $fulldayevent = $event['fulldayevent']; |
358 | 358 | $location = $event['location']; |
359 | 359 | $email = $event['email']; |
360 | 360 | */ |
361 | - $description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']); |
|
362 | - $description=dol_string_nohtmltag($description,0); // Remove html tags |
|
361 | + $description = preg_replace('/<br[\s\/]?>/i', "\n", $event['desc']); |
|
362 | + $description = dol_string_nohtmltag($description, 0); // Remove html tags |
|
363 | 363 | |
364 | 364 | fwrite($fichier, "<item>\n"); |
365 | 365 | fwrite($fichier, "<title><![CDATA[".$summary."]]></title>\n"); |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | fwrite($fichier, '</rss>'); |
383 | 383 | |
384 | 384 | fclose($fichier); |
385 | - if (! empty($conf->global->MAIN_UMASK)) |
|
385 | + if (!empty($conf->global->MAIN_UMASK)) |
|
386 | 386 | @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
387 | 387 | } |
388 | 388 | } |
@@ -395,24 +395,24 @@ discard block |
||
395 | 395 | * @param string $string string to encode |
396 | 396 | * @return string string encoded |
397 | 397 | */ |
398 | -function format_cal($format,$string) |
|
398 | +function format_cal($format, $string) |
|
399 | 399 | { |
400 | 400 | global $conf; |
401 | 401 | |
402 | - $newstring=$string; |
|
402 | + $newstring = $string; |
|
403 | 403 | |
404 | 404 | if ($format == 'vcal') |
405 | 405 | { |
406 | - $newstring=quotedPrintEncode($newstring); |
|
406 | + $newstring = quotedPrintEncode($newstring); |
|
407 | 407 | } |
408 | 408 | if ($format == 'ical') |
409 | 409 | { |
410 | 410 | // Replace new lines chars by '\n' |
411 | - $newstring=preg_replace('/'."\r\n".'/i',"\n",$newstring); |
|
412 | - $newstring=preg_replace('/'."\n\r".'/i',"\n",$newstring); |
|
413 | - $newstring=preg_replace('/'."\n".'/i','\n',$newstring); |
|
411 | + $newstring = preg_replace('/'."\r\n".'/i', "\n", $newstring); |
|
412 | + $newstring = preg_replace('/'."\n\r".'/i', "\n", $newstring); |
|
413 | + $newstring = preg_replace('/'."\n".'/i', '\n', $newstring); |
|
414 | 414 | // Must not exceed 75 char. Cut with "\r\n"+Space |
415 | - $newstring=calEncode($newstring); |
|
415 | + $newstring = calEncode($newstring); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | return $newstring; |
@@ -434,14 +434,14 @@ discard block |
||
434 | 434 | // If mb_ functions exists, it's better to use them |
435 | 435 | if (function_exists('mb_strlen')) |
436 | 436 | { |
437 | - $strlength=mb_strlen($line, 'UTF-8'); |
|
437 | + $strlength = mb_strlen($line, 'UTF-8'); |
|
438 | 438 | for ($j = 0; $j <= ($strlength - 1); $j++) |
439 | 439 | { |
440 | - $char = mb_substr($line, $j, 1, 'UTF-8'); // Take char at position $j |
|
440 | + $char = mb_substr($line, $j, 1, 'UTF-8'); // Take char at position $j |
|
441 | 441 | |
442 | 442 | if ((mb_strlen($newpara, 'UTF-8') + mb_strlen($char, 'UTF-8')) >= 75) |
443 | 443 | { |
444 | - $out .= $newpara . "\r\n "; // CRLF + Space for cal |
|
444 | + $out .= $newpara."\r\n "; // CRLF + Space for cal |
|
445 | 445 | $newpara = ''; |
446 | 446 | } |
447 | 447 | $newpara .= $char; |
@@ -450,14 +450,14 @@ discard block |
||
450 | 450 | } |
451 | 451 | else |
452 | 452 | { |
453 | - $strlength=dol_strlen($line); |
|
453 | + $strlength = dol_strlen($line); |
|
454 | 454 | for ($j = 0; $j <= ($strlength - 1); $j++) |
455 | 455 | { |
456 | - $char = substr($line, $j, 1); // Take char at position $j |
|
456 | + $char = substr($line, $j, 1); // Take char at position $j |
|
457 | 457 | |
458 | - if ((dol_strlen($newpara) + dol_strlen($char)) >= 75 ) |
|
458 | + if ((dol_strlen($newpara) + dol_strlen($char)) >= 75) |
|
459 | 459 | { |
460 | - $out .= $newpara . "\r\n "; // CRLF + Space for cal |
|
460 | + $out .= $newpara."\r\n "; // CRLF + Space for cal |
|
461 | 461 | $newpara = ''; |
462 | 462 | } |
463 | 463 | $newpara .= $char; |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | * @param int $forcal 1=For cal |
477 | 477 | * @return string String converted |
478 | 478 | */ |
479 | -function quotedPrintEncode($str,$forcal=0) |
|
479 | +function quotedPrintEncode($str, $forcal = 0) |
|
480 | 480 | { |
481 | 481 | $lines = preg_split("/\r\n/", $str); |
482 | 482 | $out = ''; |
@@ -485,19 +485,19 @@ discard block |
||
485 | 485 | { |
486 | 486 | $newpara = ''; |
487 | 487 | |
488 | - $strlength=strlen($line); // Do not use dol_strlen here, we need number of bytes |
|
488 | + $strlength = strlen($line); // Do not use dol_strlen here, we need number of bytes |
|
489 | 489 | for ($j = 0; $j <= ($strlength - 1); $j++) |
490 | 490 | { |
491 | 491 | $char = substr($line, $j, 1); |
492 | 492 | $ascii = ord($char); |
493 | 493 | |
494 | - if ( $ascii < 32 || $ascii == 61 || $ascii > 126 ) |
|
495 | - $char = '=' . strtoupper(sprintf("%02X", $ascii)); |
|
494 | + if ($ascii < 32 || $ascii == 61 || $ascii > 126) |
|
495 | + $char = '='.strtoupper(sprintf("%02X", $ascii)); |
|
496 | 496 | |
497 | - if ((strlen($newpara) + strlen($char)) >= 76 ) // Do not use dol_strlen here, we need number of bytes |
|
497 | + if ((strlen($newpara) + strlen($char)) >= 76) // Do not use dol_strlen here, we need number of bytes |
|
498 | 498 | { |
499 | - $out .= $newpara . '=' . "\r\n"; // CRLF |
|
500 | - if ($forcal) $out .= " "; // + Space for cal |
|
499 | + $out .= $newpara.'='."\r\n"; // CRLF |
|
500 | + if ($forcal) $out .= " "; // + Space for cal |
|
501 | 501 | $newpara = ''; |
502 | 502 | } |
503 | 503 | $newpara .= $char; |
@@ -516,6 +516,6 @@ discard block |
||
516 | 516 | function quotedPrintDecode($str) |
517 | 517 | { |
518 | 518 | $out = preg_replace('/=\r?\n/', '', $str); |
519 | - $out = quoted_printable_decode($out); // Available with PHP 4+ |
|
519 | + $out = quoted_printable_decode($out); // Available with PHP 4+ |
|
520 | 520 | return trim($out); |
521 | 521 | } |
@@ -38,7 +38,9 @@ discard block |
||
38 | 38 | |
39 | 39 | dol_syslog("xcal.lib.php::build_calfile Build cal file ".$outputfile." to format ".$format); |
40 | 40 | |
41 | - if (empty($outputfile)) return -1; |
|
41 | + if (empty($outputfile)) { |
|
42 | + return -1; |
|
43 | + } |
|
42 | 44 | |
43 | 45 | // Note: A cal file is an UTF8 encoded file |
44 | 46 | $calfileh=fopen($outputfile,'w'); |
@@ -48,7 +50,9 @@ discard block |
||
48 | 50 | $now=dol_now(); |
49 | 51 | |
50 | 52 | $encoding=''; |
51 | - if ($format == 'vcal') $encoding='ENCODING=QUOTED-PRINTABLE:'; |
|
53 | + if ($format == 'vcal') { |
|
54 | + $encoding='ENCODING=QUOTED-PRINTABLE:'; |
|
55 | + } |
|
52 | 56 | |
53 | 57 | // Print header |
54 | 58 | fwrite($calfileh,"BEGIN:VCALENDAR\n"); |
@@ -152,8 +156,12 @@ discard block |
||
152 | 156 | fwrite($calfileh,"URL:".$url."\n"); |
153 | 157 | }; |
154 | 158 | |
155 | - if ($created) fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n"); |
|
156 | - if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n"); |
|
159 | + if ($created) { |
|
160 | + fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n"); |
|
161 | + } |
|
162 | + if ($modified) { |
|
163 | + fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n"); |
|
164 | + } |
|
157 | 165 | fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n"); |
158 | 166 | fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n"); |
159 | 167 | |
@@ -178,9 +186,15 @@ discard block |
||
178 | 186 | //fwrite($calfileh,"X-MICROSOFT-CDO-BUSYSTATUS:1\n"); |
179 | 187 | //ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;CN=Laurent Destailleur;X-NUM-GUESTS=0:mailto:[email protected] |
180 | 188 | |
181 | - if (! empty($location)) fwrite($calfileh,"LOCATION:".$encoding.$location."\n"); |
|
182 | - if ($fulldayevent) fwrite($calfileh,"X-FUNAMBOL-ALLDAY:1\n"); |
|
183 | - if ($fulldayevent) fwrite($calfileh,"X-MICROSOFT-CDO-ALLDAYEVENT:1\n"); |
|
189 | + if (! empty($location)) { |
|
190 | + fwrite($calfileh,"LOCATION:".$encoding.$location."\n"); |
|
191 | + } |
|
192 | + if ($fulldayevent) { |
|
193 | + fwrite($calfileh,"X-FUNAMBOL-ALLDAY:1\n"); |
|
194 | + } |
|
195 | + if ($fulldayevent) { |
|
196 | + fwrite($calfileh,"X-MICROSOFT-CDO-ALLDAYEVENT:1\n"); |
|
197 | + } |
|
184 | 198 | |
185 | 199 | // Date must be GMT dates |
186 | 200 | // Current date |
@@ -197,11 +211,14 @@ discard block |
||
197 | 211 | // End date |
198 | 212 | if ($fulldayevent) |
199 | 213 | { |
200 | - if (empty($enddate)) $enddate=dol_time_plus_duree($startdate,1,'d'); |
|
201 | - } |
|
202 | - else |
|
214 | + if (empty($enddate)) { |
|
215 | + $enddate=dol_time_plus_duree($startdate,1,'d'); |
|
216 | + } |
|
217 | + } else |
|
203 | 218 | { |
204 | - if (empty($enddate)) $enddate=$startdate+$duration; |
|
219 | + if (empty($enddate)) { |
|
220 | + $enddate=$startdate+$duration; |
|
221 | + } |
|
205 | 222 | } |
206 | 223 | $prefix=''; |
207 | 224 | $enddatef = dol_print_date($enddate,'dayhourxcard',true); |
@@ -213,8 +230,12 @@ discard block |
||
213 | 230 | } |
214 | 231 | fwrite($calfileh,"DTEND".$prefix.":".$enddatef."\n"); |
215 | 232 | fwrite($calfileh,'STATUS:CONFIRMED'."\n"); |
216 | - if (! empty($transparency)) fwrite($calfileh,"TRANSP:".$transparency."\n"); |
|
217 | - if (! empty($category)) fwrite($calfileh,"CATEGORIES:".$encoding.$category."\n"); |
|
233 | + if (! empty($transparency)) { |
|
234 | + fwrite($calfileh,"TRANSP:".$transparency."\n"); |
|
235 | + } |
|
236 | + if (! empty($category)) { |
|
237 | + fwrite($calfileh,"CATEGORIES:".$encoding.$category."\n"); |
|
238 | + } |
|
218 | 239 | fwrite($calfileh,"END:VEVENT\n"); |
219 | 240 | } |
220 | 241 | |
@@ -237,8 +258,12 @@ discard block |
||
237 | 258 | fwrite($calfileh,"URL:".$url."\n"); |
238 | 259 | }; |
239 | 260 | |
240 | - if ($created) fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n"); |
|
241 | - if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n"); |
|
261 | + if ($created) { |
|
262 | + fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n"); |
|
263 | + } |
|
264 | + if ($modified) { |
|
265 | + fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n"); |
|
266 | + } |
|
242 | 267 | fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n"); |
243 | 268 | fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n"); |
244 | 269 | fwrite($calfileh,'STATUS:CONFIRMED'."\n"); |
@@ -270,10 +295,10 @@ discard block |
||
270 | 295 | fwrite($calfileh,"END:VCALENDAR"); |
271 | 296 | |
272 | 297 | fclose($calfileh); |
273 | - if (! empty($conf->global->MAIN_UMASK)) |
|
274 | - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
275 | - } |
|
276 | - else |
|
298 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
299 | + @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
300 | + } |
|
301 | + } else |
|
277 | 302 | { |
278 | 303 | dol_syslog("xcal.lib.php::build_calfile Failed to open file ".$outputfile." for writing"); |
279 | 304 | return -2; |
@@ -299,7 +324,9 @@ discard block |
||
299 | 324 | |
300 | 325 | dol_syslog("xcal.lib.php::build_rssfile Build rss file ".$outputfile." to format ".$format); |
301 | 326 | |
302 | - if (empty($outputfile)) return -1; |
|
327 | + if (empty($outputfile)) { |
|
328 | + return -1; |
|
329 | + } |
|
303 | 330 | |
304 | 331 | $fichier=fopen($outputfile,'w'); |
305 | 332 | if ($fichier) |
@@ -367,7 +394,9 @@ discard block |
||
367 | 394 | fwrite($fichier, "<author><![CDATA[".$author."]]></author>\n"); |
368 | 395 | fwrite($fichier, "<category><![CDATA[".$category."]]></category>\n"); |
369 | 396 | fwrite($fichier, "<description><![CDATA["); |
370 | - if ($description) fwrite($fichier, $description); |
|
397 | + if ($description) { |
|
398 | + fwrite($fichier, $description); |
|
399 | + } |
|
371 | 400 | //else fwrite($fichier, 'NoDesc'); |
372 | 401 | fwrite($fichier, "]]></description>\n"); |
373 | 402 | fwrite($fichier, "<pubDate>".date("r", $startdate)."</pubDate>\n"); |
@@ -382,8 +411,9 @@ discard block |
||
382 | 411 | fwrite($fichier, '</rss>'); |
383 | 412 | |
384 | 413 | fclose($fichier); |
385 | - if (! empty($conf->global->MAIN_UMASK)) |
|
386 | - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
414 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
415 | + @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
416 | + } |
|
387 | 417 | } |
388 | 418 | } |
389 | 419 | |
@@ -447,8 +477,7 @@ discard block |
||
447 | 477 | $newpara .= $char; |
448 | 478 | } |
449 | 479 | $out .= $newpara; |
450 | - } |
|
451 | - else |
|
480 | + } else |
|
452 | 481 | { |
453 | 482 | $strlength=dol_strlen($line); |
454 | 483 | for ($j = 0; $j <= ($strlength - 1); $j++) |
@@ -491,13 +520,20 @@ discard block |
||
491 | 520 | $char = substr($line, $j, 1); |
492 | 521 | $ascii = ord($char); |
493 | 522 | |
494 | - if ( $ascii < 32 || $ascii == 61 || $ascii > 126 ) |
|
495 | - $char = '=' . strtoupper(sprintf("%02X", $ascii)); |
|
523 | + if ( $ascii < 32 || $ascii == 61 || $ascii > 126 ) { |
|
524 | + $char = '=' . strtoupper(sprintf("%02X", $ascii)); |
|
525 | + } |
|
496 | 526 | |
497 | - if ((strlen($newpara) + strlen($char)) >= 76 ) // Do not use dol_strlen here, we need number of bytes |
|
527 | + if ((strlen($newpara) + strlen($char)) >= 76 ) { |
|
528 | + // Do not use dol_strlen here, we need number of bytes |
|
498 | 529 | { |
499 | - $out .= $newpara . '=' . "\r\n"; // CRLF |
|
500 | - if ($forcal) $out .= " "; // + Space for cal |
|
530 | + $out .= $newpara . '=' . "\r\n"; |
|
531 | + } |
|
532 | + // CRLF |
|
533 | + if ($forcal) { |
|
534 | + $out .= " "; |
|
535 | + } |
|
536 | + // + Space for cal |
|
501 | 537 | $newpara = ''; |
502 | 538 | } |
503 | 539 | $newpara .= $char; |
@@ -81,7 +81,9 @@ |
||
81 | 81 | $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
82 | 82 | $head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id; |
83 | 83 | $head[$h][1] = $langs->trans('ContactsAddresses'); |
84 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
84 | + if ($nbContact > 0) { |
|
85 | + $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
86 | + } |
|
85 | 87 | $head[$h][2] = 'contact'; |
86 | 88 | $h++; |
87 | 89 | } |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | |
79 | 79 | if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && empty($user->socid)) |
80 | 80 | { |
81 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
82 | - $head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id; |
|
83 | - $head[$h][1] = $langs->trans('ContactsAddresses'); |
|
84 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
85 | - $head[$h][2] = 'contact'; |
|
86 | - $h++; |
|
81 | + $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
82 | + $head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id; |
|
83 | + $head[$h][1] = $langs->trans('ContactsAddresses'); |
|
84 | + if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
85 | + $head[$h][2] = 'contact'; |
|
86 | + $h++; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket'); |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | $head[$h][1] = $langs->trans('Events'); |
108 | 108 | if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) |
109 | 109 | { |
110 | - $head[$h][1].= '/'; |
|
111 | - $head[$h][1].= $langs->trans("Agenda"); |
|
110 | + $head[$h][1].= '/'; |
|
111 | + $head[$h][1].= $langs->trans("Agenda"); |
|
112 | 112 | } |
113 | 113 | $head[$h][2] = 'tabTicketLogs'; |
114 | 114 | $h++; |
@@ -156,21 +156,21 @@ discard block |
||
156 | 156 | print '<body id="mainbody" class="publicnewticketform" style="margin-top: 10px;">'; |
157 | 157 | |
158 | 158 | if (! empty($conf->global->TICKET_SHOW_COMPANY_LOGO)) { |
159 | - // Print logo |
|
160 | - $urllogo = DOL_BASE_URI . '/theme/login_logo.png'; |
|
159 | + // Print logo |
|
160 | + $urllogo = DOL_BASE_URI . '/theme/login_logo.png'; |
|
161 | 161 | |
162 | 162 | if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) { |
163 | - $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/thumbs/'.$mysoc->logo_small); |
|
164 | - } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) { |
|
165 | - $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/'.$mysoc->logo); |
|
166 | - $width = 128; |
|
167 | - } elseif (is_readable(DOL_BASE_URI . '/theme/dolibarr_logo.png')) { |
|
163 | + $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/thumbs/'.$mysoc->logo_small); |
|
164 | + } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) { |
|
165 | + $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/'.$mysoc->logo); |
|
166 | + $width = 128; |
|
167 | + } elseif (is_readable(DOL_BASE_URI . '/theme/dolibarr_logo.png')) { |
|
168 | 168 | $urllogo = DOL_BASE_URI . '/theme/dolibarr_logo.png'; |
169 | 169 | } |
170 | - print '<center>'; |
|
171 | - print '<a href="' . ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE : dol_buildpath('/public/ticket/index.php', 1)) . '"><img alt="Logo" id="logosubscribe" title="" src="' . $urllogo . '" style="max-width: 440px" /></a><br>'; |
|
172 | - print '<strong>' . ($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . '</strong>'; |
|
173 | - print '</center><br>'; |
|
170 | + print '<center>'; |
|
171 | + print '<a href="' . ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE : dol_buildpath('/public/ticket/index.php', 1)) . '"><img alt="Logo" id="logosubscribe" title="" src="' . $urllogo . '" style="max-width: 440px" /></a><br>'; |
|
172 | + print '<strong>' . ($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . '</strong>'; |
|
173 | + print '</center><br>'; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | print '<div style="margin-left: 50px; margin-right: 50px;">'; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | $h = 0; |
72 | 72 | $head = array(); |
73 | - $head[$h][0] = DOL_URL_ROOT.'/ticket/card.php?action=view&track_id=' . $object->track_id; |
|
73 | + $head[$h][0] = DOL_URL_ROOT.'/ticket/card.php?action=view&track_id='.$object->track_id; |
|
74 | 74 | $head[$h][1] = $langs->trans("Card"); |
75 | 75 | $head[$h][2] = 'tabTicket'; |
76 | 76 | $h++; |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | |
79 | 79 | if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && empty($user->socid)) |
80 | 80 | { |
81 | - $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
|
81 | + $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); |
|
82 | 82 | $head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id; |
83 | 83 | $head[$h][1] = $langs->trans('ContactsAddresses'); |
84 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
84 | + if ($nbContact > 0) $head[$h][1] .= ' <span class="badge">'.$nbContact.'</span>'; |
|
85 | 85 | $head[$h][2] = 'contact'; |
86 | 86 | $h++; |
87 | 87 | } |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket'); |
90 | 90 | |
91 | 91 | // Attached files |
92 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
93 | - $upload_dir = $conf->ticket->dir_output . "/" . $object->track_id; |
|
92 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
93 | + $upload_dir = $conf->ticket->dir_output."/".$object->track_id; |
|
94 | 94 | $nbFiles = count(dol_dir_list($upload_dir, 'files')); |
95 | - $head[$h][0] = dol_buildpath('/ticket/document.php', 1) . '?track_id=' . $object->track_id; |
|
95 | + $head[$h][0] = dol_buildpath('/ticket/document.php', 1).'?track_id='.$object->track_id; |
|
96 | 96 | $head[$h][1] = $langs->trans("Documents"); |
97 | 97 | if ($nbFiles > 0) { |
98 | - $head[$h][1] .= ' <span class="badge">' . $nbFiles . '</span>'; |
|
98 | + $head[$h][1] .= ' <span class="badge">'.$nbFiles.'</span>'; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | $head[$h][2] = 'tabTicketDocument'; |
@@ -103,18 +103,18 @@ discard block |
||
103 | 103 | |
104 | 104 | |
105 | 105 | // History |
106 | - $head[$h][0] = DOL_URL_ROOT.'/ticket/agenda.php?track_id=' . $object->track_id; |
|
106 | + $head[$h][0] = DOL_URL_ROOT.'/ticket/agenda.php?track_id='.$object->track_id; |
|
107 | 107 | $head[$h][1] = $langs->trans('Events'); |
108 | - if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) |
|
108 | + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) |
|
109 | 109 | { |
110 | - $head[$h][1].= '/'; |
|
111 | - $head[$h][1].= $langs->trans("Agenda"); |
|
110 | + $head[$h][1] .= '/'; |
|
111 | + $head[$h][1] .= $langs->trans("Agenda"); |
|
112 | 112 | } |
113 | 113 | $head[$h][2] = 'tabTicketLogs'; |
114 | 114 | $h++; |
115 | 115 | |
116 | 116 | |
117 | - complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket','remove'); |
|
117 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket', 'remove'); |
|
118 | 118 | |
119 | 119 | |
120 | 120 | return $head; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param string $car Char to generate key |
127 | 127 | * @return void |
128 | 128 | */ |
129 | -function generate_random_id($car=16) |
|
129 | +function generate_random_id($car = 16) |
|
130 | 130 | { |
131 | 131 | $string = ""; |
132 | 132 | $chaine = "abcdefghijklmnopqrstuvwxyz123456789"; |
@@ -155,21 +155,21 @@ discard block |
||
155 | 155 | top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers |
156 | 156 | print '<body id="mainbody" class="publicnewticketform" style="margin-top: 10px;">'; |
157 | 157 | |
158 | - if (! empty($conf->global->TICKET_SHOW_COMPANY_LOGO)) { |
|
158 | + if (!empty($conf->global->TICKET_SHOW_COMPANY_LOGO)) { |
|
159 | 159 | // Print logo |
160 | - $urllogo = DOL_BASE_URI . '/theme/login_logo.png'; |
|
160 | + $urllogo = DOL_BASE_URI.'/theme/login_logo.png'; |
|
161 | 161 | |
162 | - if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) { |
|
163 | - $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/thumbs/'.$mysoc->logo_small); |
|
164 | - } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) { |
|
165 | - $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/'.$mysoc->logo); |
|
162 | + if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { |
|
163 | + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$mysoc->logo_small); |
|
164 | + } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) { |
|
165 | + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$mysoc->logo); |
|
166 | 166 | $width = 128; |
167 | - } elseif (is_readable(DOL_BASE_URI . '/theme/dolibarr_logo.png')) { |
|
168 | - $urllogo = DOL_BASE_URI . '/theme/dolibarr_logo.png'; |
|
167 | + } elseif (is_readable(DOL_BASE_URI.'/theme/dolibarr_logo.png')) { |
|
168 | + $urllogo = DOL_BASE_URI.'/theme/dolibarr_logo.png'; |
|
169 | 169 | } |
170 | 170 | print '<center>'; |
171 | - print '<a href="' . ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE : dol_buildpath('/public/ticket/index.php', 1)) . '"><img alt="Logo" id="logosubscribe" title="" src="' . $urllogo . '" style="max-width: 440px" /></a><br>'; |
|
172 | - print '<strong>' . ($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . '</strong>'; |
|
171 | + print '<a href="'.($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE : dol_buildpath('/public/ticket/index.php', 1)).'"><img alt="Logo" id="logosubscribe" title="" src="'.$urllogo.'" style="max-width: 440px" /></a><br>'; |
|
172 | + print '<strong>'.($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")).'</strong>'; |
|
173 | 173 | print '</center><br>'; |
174 | 174 | } |
175 | 175 |