@@ -84,8 +84,7 @@ |
||
84 | 84 | $head[$h][1] = $langs->trans("Card"); |
85 | 85 | $head[$h][2] = 'card'; |
86 | 86 | $h++; |
87 | - } |
|
88 | - else |
|
87 | + } else |
|
89 | 88 | { |
90 | 89 | $head[$h][0] = DOL_URL_ROOT.'/ecm/dir_card.php?section='.$section.'&module='.$module; |
91 | 90 | $head[$h][1] = $langs->trans("Card"); |
@@ -127,9 +127,13 @@ discard block |
||
127 | 127 | |
128 | 128 | // If we need to write cents call again this function for cents |
129 | 129 | if(!empty($TNum[1])) { |
130 | - if(!empty($currency)) $concatWords .= ' '.$langs->transnoentities('and'); |
|
130 | + if(!empty($currency)) { |
|
131 | + $concatWords .= ' '.$langs->transnoentities('and'); |
|
132 | + } |
|
131 | 133 | $concatWords .= ' '.dol_convertToWord($TNum[1], $langs, $currency, true); |
132 | - if(!empty($currency)) $concatWords .= ' '.$langs->transnoentities('centimes'); |
|
134 | + if(!empty($currency)) { |
|
135 | + $concatWords .= ' '.$langs->transnoentities('centimes'); |
|
136 | + } |
|
133 | 137 | } |
134 | 138 | return $concatWords; |
135 | 139 | } |
@@ -147,9 +151,12 @@ discard block |
||
147 | 151 | function dolNumberToWord($numero, $langs, $numorcurrency='number') |
148 | 152 | { |
149 | 153 | // If the number is negative convert to positive and return -1 if is too long |
150 | - if ($numero < 0) $numero *= -1; |
|
151 | - if ($numero >= 1000000000001) |
|
152 | - return -1; |
|
154 | + if ($numero < 0) { |
|
155 | + $numero *= -1; |
|
156 | + } |
|
157 | + if ($numero >= 1000000000001) { |
|
158 | + return -1; |
|
159 | + } |
|
153 | 160 | // Get 2 decimals to cents, another functions round or truncate |
154 | 161 | $strnumber = number_format ($numero,10); |
155 | 162 | $len=strlen($strnumber); |
@@ -167,17 +174,13 @@ discard block |
||
167 | 174 | { |
168 | 175 | if ($numero>=1 && $numero<2) { |
169 | 176 | return ("UN PESO ".$parte_decimal." / 100 M.N."); |
170 | - } |
|
171 | - elseif ($numero>=0 && $numero<1){ |
|
177 | + } elseif ($numero>=0 && $numero<1){ |
|
172 | 178 | return ("CERO PESOS ".$parte_decimal." / 100 M.N."); |
173 | - } |
|
174 | - elseif ($numero>=1000000 && $numero<1000001){ |
|
179 | + } elseif ($numero>=1000000 && $numero<1000001){ |
|
175 | 180 | return ("UN MILLÓN DE PESOS ".$parte_decimal." / 100 M.N."); |
176 | - } |
|
177 | - elseif ($numero>=1000000000000 && $numero<1000000000001){ |
|
181 | + } elseif ($numero>=1000000000000 && $numero<1000000000001){ |
|
178 | 182 | return ("UN BILLÓN DE PESOS ".$parte_decimal." / 100 M.N."); |
179 | - } |
|
180 | - else { |
|
183 | + } else { |
|
181 | 184 | $entexto =""; |
182 | 185 | $number = $numero; |
183 | 186 | if ($number >= 1000000000){ |
@@ -198,10 +201,11 @@ discard block |
||
198 | 201 | $udMILLON = (int) ($numero / 1000000); |
199 | 202 | $numero = $numero - $udMILLON * 1000000; |
200 | 203 | $entexto .= hundreds2text ($CdMILLON, $DdMILLON, $udMILLON); |
201 | - if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON==1) |
|
202 | - $entexto .= " MILLÓN "; |
|
203 | - else |
|
204 | - $entexto .= " MILLONES "; |
|
204 | + if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON==1) { |
|
205 | + $entexto .= " MILLÓN "; |
|
206 | + } else { |
|
207 | + $entexto .= " MILLONES "; |
|
208 | + } |
|
205 | 209 | } |
206 | 210 | if ($number >= 1000) { |
207 | 211 | $cdm = (int) ($numero / 100000); |
@@ -211,16 +215,18 @@ discard block |
||
211 | 215 | $udm = (int) ($numero / 1000); |
212 | 216 | $numero = $numero - $udm * 1000; |
213 | 217 | $entexto .= hundreds2text ($cdm, $ddm, $udm); |
214 | - if ($cdm || $ddm || $udm) |
|
215 | - $entexto .= " MIL "; |
|
218 | + if ($cdm || $ddm || $udm) { |
|
219 | + $entexto .= " MIL "; |
|
220 | + } |
|
216 | 221 | } |
217 | 222 | $c = (int) ($numero / 100); |
218 | 223 | $numero = $numero - $c * 100; |
219 | 224 | $d = (int) ($numero / 10); |
220 | 225 | $u = (int) $numero - $d * 10; |
221 | 226 | $entexto .= hundreds2text ($c, $d, $u); |
222 | - if (!$cdm && !$ddm && !$udm && !$c && !$d && !$u && $number>1000000) |
|
223 | - $entexto .= " DE"; |
|
227 | + if (!$cdm && !$ddm && !$udm && !$c && !$d && !$u && $number>1000000) { |
|
228 | + $entexto .= " DE"; |
|
229 | + } |
|
224 | 230 | $entexto .= " PESOS ".$parte_decimal." / 100 M.N."; |
225 | 231 | } |
226 | 232 | return $entexto; |
@@ -250,26 +256,32 @@ discard block |
||
250 | 256 | $entexto .= $centenas[$hundreds-1]; |
251 | 257 | } |
252 | 258 | if ($tens>2){ |
253 | - if ($hundreds!=0) $entexto .= " "; |
|
259 | + if ($hundreds!=0) { |
|
260 | + $entexto .= " "; |
|
261 | + } |
|
254 | 262 | $entexto .= $decenas[$tens-1]; |
255 | 263 | if ($units!=0){ |
256 | 264 | $entexto .= " Y "; |
257 | 265 | $entexto .= $unidades[$units-1]; |
258 | 266 | } |
259 | 267 | return $entexto; |
260 | - } |
|
261 | - elseif ($tens==2){ |
|
262 | - if ($hundreds!=0) $entexto .= " "; |
|
268 | + } elseif ($tens==2){ |
|
269 | + if ($hundreds!=0) { |
|
270 | + $entexto .= " "; |
|
271 | + } |
|
263 | 272 | $entexto .= " ".$veintis[$units]; |
264 | 273 | return $entexto; |
265 | - } |
|
266 | - elseif ($tens==1){ |
|
267 | - if ($hundreds!=0) $entexto .= " "; |
|
274 | + } elseif ($tens==1){ |
|
275 | + if ($hundreds!=0) { |
|
276 | + $entexto .= " "; |
|
277 | + } |
|
268 | 278 | $entexto .= $diecis[$units]; |
269 | 279 | return $entexto; |
270 | 280 | } |
271 | 281 | if ($units!=0) { |
272 | - if ($hundreds!=0 || $tens!=0) $entexto .= " "; |
|
282 | + if ($hundreds!=0 || $tens!=0) { |
|
283 | + $entexto .= " "; |
|
284 | + } |
|
273 | 285 | $entexto .= $unidades[$units-1]; |
274 | 286 | } |
275 | 287 | return $entexto; |
@@ -98,16 +98,21 @@ discard block |
||
98 | 98 | // $hookmanager->resArray may contain array stacked by other modules |
99 | 99 | if (empty($reshook)) |
100 | 100 | { |
101 | - if (! is_dir($newpath)) return array(); |
|
101 | + if (! is_dir($newpath)) { |
|
102 | + return array(); |
|
103 | + } |
|
102 | 104 | |
103 | 105 | if ($dir = opendir($newpath)) |
104 | 106 | { |
105 | 107 | $filedate=''; |
106 | 108 | $filesize=''; |
107 | 109 | |
108 | - while (false !== ($file = readdir($dir))) // $file is always a basename (into directory $newpath) |
|
110 | + while (false !== ($file = readdir($dir))) { |
|
111 | + // $file is always a basename (into directory $newpath) |
|
109 | 112 | { |
110 | - if (! utf8_check($file)) $file=utf8_encode($file); // To be sure data is stored in utf8 in memory |
|
113 | + if (! utf8_check($file)) $file=utf8_encode($file); |
|
114 | + } |
|
115 | + // To be sure data is stored in utf8 in memory |
|
111 | 116 | $fullpathfile=($newpath?$newpath.'/':'').$file; |
112 | 117 | |
113 | 118 | $qualified=1; |
@@ -117,8 +122,9 @@ discard block |
||
117 | 122 | if (is_array($excludefilter)) |
118 | 123 | { |
119 | 124 | $excludefilterarray=array_merge($excludefilterarray,$excludefilter); |
125 | + } else if ($excludefilter) { |
|
126 | + $excludefilterarray[]=$excludefilter; |
|
120 | 127 | } |
121 | - else if ($excludefilter) $excludefilterarray[]=$excludefilter; |
|
122 | 128 | // Check if file is qualified |
123 | 129 | foreach($excludefilterarray as $filt) |
124 | 130 | { |
@@ -137,12 +143,18 @@ discard block |
||
137 | 143 | // Add entry into file_list array |
138 | 144 | if (($types=="directories") || ($types=="all")) |
139 | 145 | { |
140 | - if ($loaddate || $sortcriteria == 'date') $filedate=dol_filemtime($path."/".$file); |
|
141 | - if ($loadsize || $sortcriteria == 'size') $filesize=dol_filesize($path."/".$file); |
|
146 | + if ($loaddate || $sortcriteria == 'date') { |
|
147 | + $filedate=dol_filemtime($path."/".$file); |
|
148 | + } |
|
149 | + if ($loadsize || $sortcriteria == 'size') { |
|
150 | + $filesize=dol_filesize($path."/".$file); |
|
151 | + } |
|
142 | 152 | |
143 | - if (! $filter || preg_match('/'.$filter.'/i',$file)) // We do not search key $filter into all $path, only into $file part |
|
153 | + if (! $filter || preg_match('/'.$filter.'/i',$file)) { |
|
154 | + // We do not search key $filter into all $path, only into $file part |
|
144 | 155 | { |
145 | 156 | preg_match('/([^\/]+)\/[^\/]+$/',$path.'/'.$file,$reg); |
157 | + } |
|
146 | 158 | $level1name=(isset($reg[1])?$reg[1]:''); |
147 | 159 | $file_list[] = array( |
148 | 160 | "name" => $file, |
@@ -166,16 +178,21 @@ discard block |
||
166 | 178 | $file_list = array_merge($file_list, dol_dir_list($path."/".$file, $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder, $mode, $nohook, ($relativename!=''?$relativename.'/':'').$file, $donotfollowsymlinks)); |
167 | 179 | } |
168 | 180 | } |
169 | - } |
|
170 | - else if (! $isdir && (($types == "files") || ($types == "all"))) |
|
181 | + } else if (! $isdir && (($types == "files") || ($types == "all"))) |
|
171 | 182 | { |
172 | 183 | // Add file into file_list array |
173 | - if ($loaddate || $sortcriteria == 'date') $filedate=dol_filemtime($path."/".$file); |
|
174 | - if ($loadsize || $sortcriteria == 'size') $filesize=dol_filesize($path."/".$file); |
|
184 | + if ($loaddate || $sortcriteria == 'date') { |
|
185 | + $filedate=dol_filemtime($path."/".$file); |
|
186 | + } |
|
187 | + if ($loadsize || $sortcriteria == 'size') { |
|
188 | + $filesize=dol_filesize($path."/".$file); |
|
189 | + } |
|
175 | 190 | |
176 | - if (! $filter || preg_match('/'.$filter.'/i',$file)) // We do not search key $filter into $path, only into $file |
|
191 | + if (! $filter || preg_match('/'.$filter.'/i',$file)) { |
|
192 | + // We do not search key $filter into $path, only into $file |
|
177 | 193 | { |
178 | 194 | preg_match('/([^\/]+)\/[^\/]+$/',$path.'/'.$file,$reg); |
195 | + } |
|
179 | 196 | $level1name=(isset($reg[1])?$reg[1]:''); |
180 | 197 | $file_list[] = array( |
181 | 198 | "name" => $file, |
@@ -202,12 +219,16 @@ discard block |
||
202 | 219 | $myarray[$key] = (isset($row[$sortcriteria])?$row[$sortcriteria]:''); |
203 | 220 | } |
204 | 221 | // Sort the data |
205 | - if ($sortorder) array_multisort($myarray, $sortorder, $file_list); |
|
222 | + if ($sortorder) { |
|
223 | + array_multisort($myarray, $sortorder, $file_list); |
|
224 | + } |
|
206 | 225 | } |
207 | 226 | } |
208 | 227 | } |
209 | 228 | |
210 | - if (is_object($hookmanager) && is_array($hookmanager->resArray)) $file_list = array_merge($file_list, $hookmanager->resArray); |
|
229 | + if (is_object($hookmanager) && is_array($hookmanager->resArray)) { |
|
230 | + $file_list = array_merge($file_list, $hookmanager->resArray); |
|
231 | + } |
|
211 | 232 | |
212 | 233 | return $file_list; |
213 | 234 | } |
@@ -232,7 +253,9 @@ discard block |
||
232 | 253 | |
233 | 254 | $sql =" SELECT rowid, label, entity, filename, filepath, fullpath_orig, keywords, cover, gen_or_uploaded, extraparams, date_c, date_m, fk_user_c, fk_user_m,"; |
234 | 255 | $sql.=" acl, position, share"; |
235 | - if ($mode) $sql.=", description"; |
|
256 | + if ($mode) { |
|
257 | + $sql.=", description"; |
|
258 | + } |
|
236 | 259 | $sql.=" FROM ".MAIN_DB_PREFIX."ecm_files"; |
237 | 260 | $sql.=" WHERE filepath = '".$db->escape($path)."'"; |
238 | 261 | $sql.=" AND entity = ".$conf->entity; |
@@ -280,12 +303,13 @@ discard block |
||
280 | 303 | $myarray[$key] = (isset($row[$sortcriteria])?$row[$sortcriteria]:''); |
281 | 304 | } |
282 | 305 | // Sort the data |
283 | - if ($sortorder) array_multisort($myarray, $sortorder, $file_list); |
|
306 | + if ($sortorder) { |
|
307 | + array_multisort($myarray, $sortorder, $file_list); |
|
308 | + } |
|
284 | 309 | } |
285 | 310 | |
286 | 311 | return $file_list; |
287 | - } |
|
288 | - else |
|
312 | + } else |
|
289 | 313 | { |
290 | 314 | dol_print_error($db); |
291 | 315 | return array(); |
@@ -313,8 +337,11 @@ discard block |
||
313 | 337 | global $object; |
314 | 338 | if (! empty($object->id)) |
315 | 339 | { |
316 | - if (! empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; |
|
317 | - else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; |
|
340 | + if (! empty($conf->product->enabled)) { |
|
341 | + $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; |
|
342 | + } else { |
|
343 | + $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; |
|
344 | + } |
|
318 | 345 | |
319 | 346 | $relativedirold = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dirold); |
320 | 347 | $relativedirold = preg_replace('/^[\\/]/','',$relativedirold); |
@@ -347,16 +374,21 @@ discard block |
||
347 | 374 | } |
348 | 375 | } |
349 | 376 | |
350 | - if (! $found) // This happen in transition toward version 6, or if files were added manually into os dir. |
|
377 | + if (! $found) { |
|
378 | + // This happen in transition toward version 6, or if files were added manually into os dir. |
|
351 | 379 | { |
352 | - $filearray[$key]['position']='999999'; // File not indexed are at end. So if we add a file, it will not replace an existing position |
|
380 | + $filearray[$key]['position']='999999'; |
|
381 | + } |
|
382 | + // File not indexed are at end. So if we add a file, it will not replace an existing position |
|
353 | 383 | $filearray[$key]['cover']=0; |
354 | 384 | $filearray[$key]['acl']=''; |
355 | 385 | |
356 | 386 | $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $filearray[$key]['fullname']); |
357 | - if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter)) // If not a tmp file |
|
387 | + if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter)) { |
|
388 | + // If not a tmp file |
|
358 | 389 | { |
359 | 390 | dol_syslog("list_of_documents We found a file called '".$filearray[$key]['name']."' not indexed into database. We add it"); |
391 | + } |
|
360 | 392 | include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
361 | 393 | $ecmfile=new EcmFiles($db); |
362 | 394 | |
@@ -377,13 +409,11 @@ discard block |
||
377 | 409 | if ($result < 0) |
378 | 410 | { |
379 | 411 | setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); |
380 | - } |
|
381 | - else |
|
412 | + } else |
|
382 | 413 | { |
383 | 414 | $filearray[$key]['rowid']=$result; |
384 | 415 | } |
385 | - } |
|
386 | - else |
|
416 | + } else |
|
387 | 417 | { |
388 | 418 | $filearray[$key]['rowid']=0; // Should not happened |
389 | 419 | } |
@@ -408,22 +438,27 @@ discard block |
||
408 | 438 | |
409 | 439 | $sortorder=strtoupper($sortorder); |
410 | 440 | |
411 | - if ($sortorder == 'ASC') { $retup=-1; $retdown=1; } |
|
412 | - else { $retup=1; $retdown=-1; } |
|
441 | + if ($sortorder == 'ASC') { $retup=-1; $retdown=1; } else { $retup=1; $retdown=-1; } |
|
413 | 442 | |
414 | 443 | if ($sortfield == 'name') |
415 | 444 | { |
416 | - if ($a->name == $b->name) return 0; |
|
445 | + if ($a->name == $b->name) { |
|
446 | + return 0; |
|
447 | + } |
|
417 | 448 | return ($a->name < $b->name) ? $retup : $retdown; |
418 | 449 | } |
419 | 450 | if ($sortfield == 'date') |
420 | 451 | { |
421 | - if ($a->date == $b->date) return 0; |
|
452 | + if ($a->date == $b->date) { |
|
453 | + return 0; |
|
454 | + } |
|
422 | 455 | return ($a->date < $b->date) ? $retup : $retdown; |
423 | 456 | } |
424 | 457 | if ($sortfield == 'size') |
425 | 458 | { |
426 | - if ($a->size == $b->size) return 0; |
|
459 | + if ($a->size == $b->size) { |
|
460 | + return 0; |
|
461 | + } |
|
427 | 462 | return ($a->size < $b->size) ? $retup : $retdown; |
428 | 463 | } |
429 | 464 | } |
@@ -438,9 +473,12 @@ discard block |
||
438 | 473 | function dol_is_dir($folder) |
439 | 474 | { |
440 | 475 | $newfolder=dol_osencode($folder); |
441 | - if (is_dir($newfolder)) return true; |
|
442 | - else return false; |
|
443 | -} |
|
476 | + if (is_dir($newfolder)) { |
|
477 | + return true; |
|
478 | + } else { |
|
479 | + return false; |
|
480 | + } |
|
481 | + } |
|
444 | 482 | |
445 | 483 | /** |
446 | 484 | * Return if path is a file |
@@ -477,7 +515,9 @@ discard block |
||
477 | 515 | $tmpprot=array('file','http','https','ftp','zlib','data','ssh','ssh2','ogg','expect'); |
478 | 516 | foreach($tmpprot as $prot) |
479 | 517 | { |
480 | - if (preg_match('/^'.$prot.':/i',$url)) return true; |
|
518 | + if (preg_match('/^'.$prot.':/i',$url)) { |
|
519 | + return true; |
|
520 | + } |
|
481 | 521 | } |
482 | 522 | return false; |
483 | 523 | } |
@@ -499,15 +539,21 @@ discard block |
||
499 | 539 | { |
500 | 540 | $name_array[] = $name; |
501 | 541 | } |
502 | - foreach($name_array as $temp) $folder_content .= $temp; |
|
542 | + foreach($name_array as $temp) { |
|
543 | + $folder_content .= $temp; |
|
544 | + } |
|
503 | 545 | |
504 | 546 | closedir($handle); |
505 | 547 | |
506 | - if ($folder_content == "...") return true; |
|
507 | - else return false; |
|
548 | + if ($folder_content == "...") { |
|
549 | + return true; |
|
550 | + } else { |
|
551 | + return false; |
|
552 | + } |
|
553 | + } else { |
|
554 | + return true; |
|
508 | 555 | } |
509 | - else |
|
510 | - return true; // Dir does not exists |
|
556 | + // Dir does not exists |
|
511 | 557 | } |
512 | 558 | |
513 | 559 | /** |
@@ -530,11 +576,12 @@ discard block |
||
530 | 576 | { |
531 | 577 | $line=fgets($fp); |
532 | 578 | // We increase count only if read was success. We need test because feof return true only after fgets so we do n+1 fgets for a file with n lines. |
533 | - if (! $line === false) $nb++; |
|
579 | + if (! $line === false) { |
|
580 | + $nb++; |
|
581 | + } |
|
534 | 582 | } |
535 | 583 | fclose($fp); |
536 | - } |
|
537 | - else |
|
584 | + } else |
|
538 | 585 | { |
539 | 586 | $nb=-1; |
540 | 587 | } |
@@ -584,11 +631,17 @@ discard block |
||
584 | 631 | |
585 | 632 | dol_syslog("files.lib.php::dolReplaceInFile srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." indexdatabase=".$indexdatabase); |
586 | 633 | |
587 | - if (empty($srcfile)) return -1; |
|
588 | - if (empty($destfile)) $destfile=$srcfile; |
|
634 | + if (empty($srcfile)) { |
|
635 | + return -1; |
|
636 | + } |
|
637 | + if (empty($destfile)) { |
|
638 | + $destfile=$srcfile; |
|
639 | + } |
|
589 | 640 | |
590 | 641 | $destexists=dol_is_file($destfile); |
591 | - if (($destfile != $srcfile) && $destexists) return 0; |
|
642 | + if (($destfile != $srcfile) && $destexists) { |
|
643 | + return 0; |
|
644 | + } |
|
592 | 645 | |
593 | 646 | $tmpdestfile=$destfile.'.tmp'; |
594 | 647 | |
@@ -625,10 +678,14 @@ discard block |
||
625 | 678 | dol_syslog("files.lib.php::dolReplaceInFile failed to move tmp file to final dest", LOG_WARNING); |
626 | 679 | return -3; |
627 | 680 | } |
628 | - if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; |
|
629 | - if (empty($newmask)) // This should no happen |
|
681 | + if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) { |
|
682 | + $newmask=$conf->global->MAIN_UMASK; |
|
683 | + } |
|
684 | + if (empty($newmask)) { |
|
685 | + // This should no happen |
|
630 | 686 | { |
631 | 687 | dol_syslog("Warning: dolReplaceInFile called with empty value for newmask and no default value defined", LOG_WARNING); |
688 | + } |
|
632 | 689 | $newmask='0664'; |
633 | 690 | } |
634 | 691 | |
@@ -669,10 +726,14 @@ discard block |
||
669 | 726 | |
670 | 727 | dol_syslog("files.lib.php::dol_copy srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwriteifexists=".$overwriteifexists); |
671 | 728 | |
672 | - if (empty($srcfile) || empty($destfile)) return -1; |
|
729 | + if (empty($srcfile) || empty($destfile)) { |
|
730 | + return -1; |
|
731 | + } |
|
673 | 732 | |
674 | 733 | $destexists=dol_is_file($destfile); |
675 | - if (! $overwriteifexists && $destexists) return 0; |
|
734 | + if (! $overwriteifexists && $destexists) { |
|
735 | + return 0; |
|
736 | + } |
|
676 | 737 | |
677 | 738 | $newpathofsrcfile=dol_osencode($srcfile); |
678 | 739 | $newpathofdestfile=dol_osencode($destfile); |
@@ -696,10 +757,14 @@ discard block |
||
696 | 757 | dol_syslog("files.lib.php::dol_copy failed to copy", LOG_WARNING); |
697 | 758 | return -3; |
698 | 759 | } |
699 | - if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; |
|
700 | - if (empty($newmask)) // This should no happen |
|
760 | + if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) { |
|
761 | + $newmask=$conf->global->MAIN_UMASK; |
|
762 | + } |
|
763 | + if (empty($newmask)) { |
|
764 | + // This should no happen |
|
701 | 765 | { |
702 | 766 | dol_syslog("Warning: dol_copy called with empty value for newmask and no default value defined", LOG_WARNING); |
767 | + } |
|
703 | 768 | $newmask='0664'; |
704 | 769 | } |
705 | 770 | |
@@ -727,7 +792,9 @@ discard block |
||
727 | 792 | |
728 | 793 | dol_syslog("files.lib.php::dolCopyDir srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwriteifexists=".$overwriteifexists); |
729 | 794 | |
730 | - if (empty($srcfile) || empty($destfile)) return -1; |
|
795 | + if (empty($srcfile) || empty($destfile)) { |
|
796 | + return -1; |
|
797 | + } |
|
731 | 798 | |
732 | 799 | $destexists=dol_is_dir($destfile); |
733 | 800 | //if (! $overwriteifexists && $destexists) return 0; // The overwriteifexists is for files only, so propagated to dol_copy only. |
@@ -737,7 +804,9 @@ discard block |
||
737 | 804 | // We must set mask just before creating dir, becaause it can be set differently by dol_copy |
738 | 805 | umask(0); |
739 | 806 | $dirmaskdec=octdec($newmask); |
740 | - if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $dirmaskdec=octdec($conf->global->MAIN_UMASK); |
|
807 | + if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) { |
|
808 | + $dirmaskdec=octdec($conf->global->MAIN_UMASK); |
|
809 | + } |
|
741 | 810 | $dirmaskdec |= octdec('0200'); // Set w bit required to be able to create content for recursive subdirs files |
742 | 811 | dol_mkdir($destfile, '', decoct($dirmaskdec)); |
743 | 812 | } |
@@ -757,8 +826,7 @@ discard block |
||
757 | 826 | { |
758 | 827 | //var_dump("xxx dolCopyDir $srcfile/$file, $destfile/$file, $newmask, $overwriteifexists"); |
759 | 828 | $tmpresult=dolCopyDir($srcfile."/".$file, $destfile."/".$file, $newmask, $overwriteifexists, $arrayreplacement); |
760 | - } |
|
761 | - else |
|
829 | + } else |
|
762 | 830 | { |
763 | 831 | $newfile = $file; |
764 | 832 | // Replace destination filename with a new one |
@@ -775,17 +843,17 @@ discard block |
||
775 | 843 | if ($result > 0 && $tmpresult >= 0) |
776 | 844 | { |
777 | 845 | // Do nothing, so we don't set result to 0 if tmpresult is 0 and result was success in a previous pass |
778 | - } |
|
779 | - else |
|
846 | + } else |
|
780 | 847 | { |
781 | 848 | $result=$tmpresult; |
782 | 849 | } |
783 | - if ($result < 0) break; |
|
850 | + if ($result < 0) { |
|
851 | + break; |
|
852 | + } |
|
784 | 853 | } |
785 | 854 | } |
786 | 855 | closedir($dir_handle); |
787 | - } |
|
788 | - else |
|
856 | + } else |
|
789 | 857 | { |
790 | 858 | // Source directory does not exists |
791 | 859 | $result = -2; |
@@ -852,8 +920,9 @@ discard block |
||
852 | 920 | // We force delete and try again. Rename function sometimes fails to replace dest file with some windows NTFS partitions. |
853 | 921 | dol_delete_file($destfile); |
854 | 922 | $result=@rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @ |
923 | + } else { |
|
924 | + dol_syslog("files.lib.php::dol_move Failed.", LOG_WARNING); |
|
855 | 925 | } |
856 | - else dol_syslog("files.lib.php::dol_move Failed.", LOG_WARNING); |
|
857 | 926 | } |
858 | 927 | |
859 | 928 | // Move ok |
@@ -862,9 +931,11 @@ discard block |
||
862 | 931 | // Rename entry into ecm database |
863 | 932 | $rel_filetorenamebefore = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $srcfile); |
864 | 933 | $rel_filetorenameafter = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $destfile); |
865 | - if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter)) // If not a tmp file |
|
934 | + if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter)) { |
|
935 | + // If not a tmp file |
|
866 | 936 | { |
867 | 937 | $rel_filetorenamebefore = preg_replace('/^[\\/]/', '', $rel_filetorenamebefore); |
938 | + } |
|
868 | 939 | $rel_filetorenameafter = preg_replace('/^[\\/]/', '', $rel_filetorenameafter); |
869 | 940 | //var_dump($rel_filetorenamebefore.' - '.$rel_filetorenameafter); |
870 | 941 | |
@@ -873,16 +944,20 @@ discard block |
||
873 | 944 | |
874 | 945 | $ecmfiletarget=new EcmFiles($db); |
875 | 946 | $resultecmtarget = $ecmfiletarget->fetch(0, '', $rel_filetorenameafter); |
876 | - if ($resultecmtarget > 0) // An entry for target name already exists for target, we delete it, a new one will be created. |
|
947 | + if ($resultecmtarget > 0) { |
|
948 | + // An entry for target name already exists for target, we delete it, a new one will be created. |
|
877 | 949 | { |
878 | 950 | $ecmfiletarget->delete($user); |
879 | 951 | } |
952 | + } |
|
880 | 953 | |
881 | 954 | $ecmfile=new EcmFiles($db); |
882 | 955 | $resultecm = $ecmfile->fetch(0, '', $rel_filetorenamebefore); |
883 | - if ($resultecm > 0) // If an entry was found for src file, we use it to move entry |
|
956 | + if ($resultecm > 0) { |
|
957 | + // If an entry was found for src file, we use it to move entry |
|
884 | 958 | { |
885 | 959 | $filename = basename($rel_filetorenameafter); |
960 | + } |
|
886 | 961 | $rel_dir = dirname($rel_filetorenameafter); |
887 | 962 | $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
888 | 963 | $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
@@ -890,10 +965,11 @@ discard block |
||
890 | 965 | $ecmfile->filepath = $rel_dir; |
891 | 966 | $ecmfile->filename = $filename; |
892 | 967 | $resultecm = $ecmfile->update($user); |
893 | - } |
|
894 | - elseif ($resultecm == 0) // If no entry were found for src files, create/update target file |
|
968 | + } elseif ($resultecm == 0) { |
|
969 | + // If no entry were found for src files, create/update target file |
|
895 | 970 | { |
896 | 971 | $filename = basename($rel_filetorenameafter); |
972 | + } |
|
897 | 973 | $rel_dir = dirname($rel_filetorenameafter); |
898 | 974 | $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
899 | 975 | $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
@@ -910,18 +986,22 @@ discard block |
||
910 | 986 | { |
911 | 987 | setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); |
912 | 988 | } |
913 | - } |
|
914 | - elseif ($resultecm < 0) |
|
989 | + } elseif ($resultecm < 0) |
|
915 | 990 | { |
916 | 991 | setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); |
917 | 992 | } |
918 | 993 | |
919 | - if ($resultecm > 0) $result=true; |
|
920 | - else $result = false; |
|
994 | + if ($resultecm > 0) { |
|
995 | + $result=true; |
|
996 | + } else { |
|
997 | + $result = false; |
|
998 | + } |
|
921 | 999 | } |
922 | 1000 | } |
923 | 1001 | |
924 | - if (empty($newmask)) $newmask=empty($conf->global->MAIN_UMASK)?'0755':$conf->global->MAIN_UMASK; |
|
1002 | + if (empty($newmask)) { |
|
1003 | + $newmask=empty($conf->global->MAIN_UMASK)?'0755':$conf->global->MAIN_UMASK; |
|
1004 | + } |
|
925 | 1005 | $newmaskdec=octdec($newmask); |
926 | 1006 | // Currently method is restricted to files (dol_delete_files previously used is for files, and mask usage if for files too) |
927 | 1007 | // to allow mask usage for dir, we shoul introduce a new param "isdir" to 1 to complete newmask like this |
@@ -965,9 +1045,11 @@ discard block |
||
965 | 1045 | } |
966 | 1046 | $antivir=new AntiVir($db); |
967 | 1047 | $result = $antivir->dol_avscan_file($src_file); |
968 | - if ($result < 0) // If virus or error, we stop here |
|
1048 | + if ($result < 0) { |
|
1049 | + // If virus or error, we stop here |
|
969 | 1050 | { |
970 | 1051 | $reterrors=$antivir->errors; |
1052 | + } |
|
971 | 1053 | return $reterrors; |
972 | 1054 | } |
973 | 1055 | } |
@@ -1075,13 +1157,17 @@ discard block |
||
1075 | 1157 | } |
1076 | 1158 | } |
1077 | 1159 | |
1078 | - if ($reshook < 0) // At least one blocking error returned by one hook |
|
1160 | + if ($reshook < 0) { |
|
1161 | + // At least one blocking error returned by one hook |
|
1079 | 1162 | { |
1080 | 1163 | $errmsg = join(',', $hookmanager->errors); |
1081 | - if (empty($errmsg)) $errmsg = 'ErrorReturnedBySomeHooks'; // Should not occurs. Added if hook is bugged and does not set ->errors when there is error. |
|
1082 | - return $errmsg; |
|
1083 | 1164 | } |
1084 | - elseif (empty($reshook)) |
|
1165 | + if (empty($errmsg)) { |
|
1166 | + $errmsg = 'ErrorReturnedBySomeHooks'; |
|
1167 | + } |
|
1168 | + // Should not occurs. Added if hook is bugged and does not set ->errors when there is error. |
|
1169 | + return $errmsg; |
|
1170 | + } elseif (empty($reshook)) |
|
1085 | 1171 | { |
1086 | 1172 | // The file functions must be in OS filesystem encoding. |
1087 | 1173 | $src_file_osencoded=dol_osencode($src_file); |
@@ -1108,11 +1194,12 @@ discard block |
||
1108 | 1194 | $return=move_uploaded_file($src_file_osencoded, $file_name_osencoded); |
1109 | 1195 | if ($return) |
1110 | 1196 | { |
1111 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($file_name_osencoded, octdec($conf->global->MAIN_UMASK)); |
|
1197 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
1198 | + @chmod($file_name_osencoded, octdec($conf->global->MAIN_UMASK)); |
|
1199 | + } |
|
1112 | 1200 | dol_syslog("Files.lib::dol_move_uploaded_file Success to move ".$src_file." to ".$file_name." - Umask=".$conf->global->MAIN_UMASK, LOG_DEBUG); |
1113 | 1201 | return 1; // Success |
1114 | - } |
|
1115 | - else |
|
1202 | + } else |
|
1116 | 1203 | { |
1117 | 1204 | dol_syslog("Files.lib::dol_move_uploaded_file Failed to move ".$src_file." to ".$file_name, LOG_ERR); |
1118 | 1205 | return -3; // Unknown error |
@@ -1167,12 +1254,13 @@ discard block |
||
1167 | 1254 | $reshook=$hookmanager->executeHooks('deleteFile', $parameters, $object); |
1168 | 1255 | } |
1169 | 1256 | |
1170 | - if (empty($nohook) && $reshook != 0) // reshook = 0 to do standard actions, 1 = ok, -1 = ko |
|
1257 | + if (empty($nohook) && $reshook != 0) { |
|
1258 | + // reshook = 0 to do standard actions, 1 = ok, -1 = ko |
|
1171 | 1259 | { |
1172 | 1260 | if ($reshook < 0) return false; |
1173 | - return true; |
|
1174 | 1261 | } |
1175 | - else |
|
1262 | + return true; |
|
1263 | + } else |
|
1176 | 1264 | { |
1177 | 1265 | $error=0; |
1178 | 1266 | |
@@ -1188,21 +1276,28 @@ discard block |
||
1188 | 1276 | { |
1189 | 1277 | foreach ($listofdir as $filename) |
1190 | 1278 | { |
1191 | - if ($nophperrors) $ok=@unlink($filename); |
|
1192 | - else $ok=unlink($filename); |
|
1279 | + if ($nophperrors) { |
|
1280 | + $ok=@unlink($filename); |
|
1281 | + } else { |
|
1282 | + $ok=unlink($filename); |
|
1283 | + } |
|
1193 | 1284 | if ($ok) |
1194 | 1285 | { |
1195 | 1286 | dol_syslog("Removed file ".$filename, LOG_DEBUG); |
1196 | 1287 | |
1197 | 1288 | // Delete entry into ecm database |
1198 | 1289 | $rel_filetodelete = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $filename); |
1199 | - if (! preg_match('/(\/temp\/|\/thumbs\/|\.meta$)/', $rel_filetodelete)) // If not a tmp file |
|
1290 | + if (! preg_match('/(\/temp\/|\/thumbs\/|\.meta$)/', $rel_filetodelete)) { |
|
1291 | + // If not a tmp file |
|
1200 | 1292 | { |
1201 | 1293 | $rel_filetodelete = preg_replace('/^[\\/]/', '', $rel_filetodelete); |
1294 | + } |
|
1202 | 1295 | |
1203 | - if (is_object($db) && $indexdatabase) // $db may not be defined when lib is in a context with define('NOREQUIREDB',1) |
|
1296 | + if (is_object($db) && $indexdatabase) { |
|
1297 | + // $db may not be defined when lib is in a context with define('NOREQUIREDB',1) |
|
1204 | 1298 | { |
1205 | 1299 | dol_syslog("Try to remove also entries in database for full relative path = ".$rel_filetodelete, LOG_DEBUG); |
1300 | + } |
|
1206 | 1301 | include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
1207 | 1302 | $ecmfile=new EcmFiles($db); |
1208 | 1303 | $result = $ecmfile->fetch(0, '', $rel_filetodelete); |
@@ -1216,21 +1311,28 @@ discard block |
||
1216 | 1311 | } |
1217 | 1312 | } |
1218 | 1313 | } |
1314 | + } else { |
|
1315 | + dol_syslog("Failed to remove file ".$filename, LOG_WARNING); |
|
1219 | 1316 | } |
1220 | - else dol_syslog("Failed to remove file ".$filename, LOG_WARNING); |
|
1221 | 1317 | // TODO Failure to remove can be because file was already removed or because of permission |
1222 | 1318 | // If error because it does not exists, we should return true, and we should return false if this is a permission problem |
1223 | 1319 | } |
1320 | + } else { |
|
1321 | + dol_syslog("No files to delete found", LOG_DEBUG); |
|
1224 | 1322 | } |
1225 | - else dol_syslog("No files to delete found", LOG_DEBUG); |
|
1226 | - } |
|
1227 | - else |
|
1323 | + } else |
|
1228 | 1324 | { |
1229 | 1325 | $ok=false; |
1230 | - if ($nophperrors) $ok=@unlink($file_osencoded); |
|
1231 | - else $ok=unlink($file_osencoded); |
|
1232 | - if ($ok) dol_syslog("Removed file ".$file_osencoded, LOG_DEBUG); |
|
1233 | - else dol_syslog("Failed to remove file ".$file_osencoded, LOG_WARNING); |
|
1326 | + if ($nophperrors) { |
|
1327 | + $ok=@unlink($file_osencoded); |
|
1328 | + } else { |
|
1329 | + $ok=unlink($file_osencoded); |
|
1330 | + } |
|
1331 | + if ($ok) { |
|
1332 | + dol_syslog("Removed file ".$file_osencoded, LOG_DEBUG); |
|
1333 | + } else { |
|
1334 | + dol_syslog("Failed to remove file ".$file_osencoded, LOG_WARNING); |
|
1335 | + } |
|
1234 | 1336 | } |
1235 | 1337 | |
1236 | 1338 | return $ok; |
@@ -1280,19 +1382,23 @@ discard block |
||
1280 | 1382 | { |
1281 | 1383 | while (false !== ($item = readdir($handle))) |
1282 | 1384 | { |
1283 | - if (! utf8_check($item)) $item=utf8_encode($item); // should be useless |
|
1385 | + if (! utf8_check($item)) { |
|
1386 | + $item=utf8_encode($item); |
|
1387 | + } |
|
1388 | + // should be useless |
|
1284 | 1389 | |
1285 | 1390 | if ($item != "." && $item != "..") |
1286 | 1391 | { |
1287 | 1392 | if (is_dir(dol_osencode("$dir/$item")) && ! is_link(dol_osencode("$dir/$item"))) |
1288 | 1393 | { |
1289 | 1394 | $count=dol_delete_dir_recursive("$dir/$item", $count, $nophperrors, 0, $countdeleted); |
1290 | - } |
|
1291 | - else |
|
1395 | + } else |
|
1292 | 1396 | { |
1293 | 1397 | $result=dol_delete_file("$dir/$item", 1, $nophperrors); |
1294 | 1398 | $count++; |
1295 | - if ($result) $countdeleted++; |
|
1399 | + if ($result) { |
|
1400 | + $countdeleted++; |
|
1401 | + } |
|
1296 | 1402 | //else print 'Error on '.$item."\n"; |
1297 | 1403 | } |
1298 | 1404 | } |
@@ -1303,7 +1409,9 @@ discard block |
||
1303 | 1409 | { |
1304 | 1410 | $result=dol_delete_dir($dir, $nophperrors); |
1305 | 1411 | $count++; |
1306 | - if ($result) $countdeleted++; |
|
1412 | + if ($result) { |
|
1413 | + $countdeleted++; |
|
1414 | + } |
|
1307 | 1415 | //else print 'Error on '.$dir."\n"; |
1308 | 1416 | } |
1309 | 1417 | } |
@@ -1328,15 +1436,25 @@ discard block |
||
1328 | 1436 | // Define parent dir of elements |
1329 | 1437 | $element = $object->element; |
1330 | 1438 | |
1331 | - if ($object->element == 'order_supplier') $dir = $conf->fournisseur->commande->dir_output; |
|
1332 | - elseif ($object->element == 'invoice_supplier') $dir = $conf->fournisseur->facture->dir_output; |
|
1333 | - elseif ($object->element == 'project') $dir = $conf->projet->dir_output; |
|
1334 | - elseif ($object->element == 'shipping') $dir = $conf->expedition->dir_output.'/sending'; |
|
1335 | - elseif ($object->element == 'delivery') $dir = $conf->expedition->dir_output.'/receipt'; |
|
1336 | - elseif ($object->element == 'fichinter') $dir = $conf->ficheinter->dir_output; |
|
1337 | - else $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output; |
|
1439 | + if ($object->element == 'order_supplier') { |
|
1440 | + $dir = $conf->fournisseur->commande->dir_output; |
|
1441 | + } elseif ($object->element == 'invoice_supplier') { |
|
1442 | + $dir = $conf->fournisseur->facture->dir_output; |
|
1443 | + } elseif ($object->element == 'project') { |
|
1444 | + $dir = $conf->projet->dir_output; |
|
1445 | + } elseif ($object->element == 'shipping') { |
|
1446 | + $dir = $conf->expedition->dir_output.'/sending'; |
|
1447 | + } elseif ($object->element == 'delivery') { |
|
1448 | + $dir = $conf->expedition->dir_output.'/receipt'; |
|
1449 | + } elseif ($object->element == 'fichinter') { |
|
1450 | + $dir = $conf->ficheinter->dir_output; |
|
1451 | + } else { |
|
1452 | + $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output; |
|
1453 | + } |
|
1338 | 1454 | |
1339 | - if (empty($dir)) return 'ErrorObjectNoSupportedByFunction'; |
|
1455 | + if (empty($dir)) { |
|
1456 | + return 'ErrorObjectNoSupportedByFunction'; |
|
1457 | + } |
|
1340 | 1458 | |
1341 | 1459 | $refsan = dol_sanitizeFileName($object->ref); |
1342 | 1460 | $dir = $dir . "/" . $refsan ; |
@@ -1369,8 +1487,7 @@ discard block |
||
1369 | 1487 | $object->error=$langs->trans("ErrorFailedToDeleteFile",$filepreviewold); |
1370 | 1488 | return 0; |
1371 | 1489 | } |
1372 | - } |
|
1373 | - else |
|
1490 | + } else |
|
1374 | 1491 | { |
1375 | 1492 | $multiple = $filepreviewold . "."; |
1376 | 1493 | for ($i = 0; $i < 20; $i++) |
@@ -1404,18 +1521,29 @@ discard block |
||
1404 | 1521 | global $conf; |
1405 | 1522 | |
1406 | 1523 | // Create meta file |
1407 | - if (empty($conf->global->MAIN_DOC_CREATE_METAFILE)) return 0; // By default, no metafile. |
|
1524 | + if (empty($conf->global->MAIN_DOC_CREATE_METAFILE)) { |
|
1525 | + return 0; |
|
1526 | + } |
|
1527 | + // By default, no metafile. |
|
1408 | 1528 | |
1409 | 1529 | // Define parent dir of elements |
1410 | 1530 | $element=$object->element; |
1411 | 1531 | |
1412 | - if ($object->element == 'order_supplier') $dir = $conf->fournisseur->dir_output.'/commande'; |
|
1413 | - elseif ($object->element == 'invoice_supplier') $dir = $conf->fournisseur->dir_output.'/facture'; |
|
1414 | - elseif ($object->element == 'project') $dir = $conf->projet->dir_output; |
|
1415 | - elseif ($object->element == 'shipping') $dir = $conf->expedition->dir_output.'/sending'; |
|
1416 | - elseif ($object->element == 'delivery') $dir = $conf->expedition->dir_output.'/receipt'; |
|
1417 | - elseif ($object->element == 'fichinter') $dir = $conf->ficheinter->dir_output; |
|
1418 | - else $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output; |
|
1532 | + if ($object->element == 'order_supplier') { |
|
1533 | + $dir = $conf->fournisseur->dir_output.'/commande'; |
|
1534 | + } elseif ($object->element == 'invoice_supplier') { |
|
1535 | + $dir = $conf->fournisseur->dir_output.'/facture'; |
|
1536 | + } elseif ($object->element == 'project') { |
|
1537 | + $dir = $conf->projet->dir_output; |
|
1538 | + } elseif ($object->element == 'shipping') { |
|
1539 | + $dir = $conf->expedition->dir_output.'/sending'; |
|
1540 | + } elseif ($object->element == 'delivery') { |
|
1541 | + $dir = $conf->expedition->dir_output.'/receipt'; |
|
1542 | + } elseif ($object->element == 'fichinter') { |
|
1543 | + $dir = $conf->ficheinter->dir_output; |
|
1544 | + } else { |
|
1545 | + $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output; |
|
1546 | + } |
|
1419 | 1547 | |
1420 | 1548 | if ($dir) |
1421 | 1549 | { |
@@ -1455,12 +1583,12 @@ discard block |
||
1455 | 1583 | $fp = fopen($file,"w"); |
1456 | 1584 | fputs($fp,$meta); |
1457 | 1585 | fclose($fp); |
1458 | - if (! empty($conf->global->MAIN_UMASK)) |
|
1459 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
1586 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
1587 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
1588 | + } |
|
1460 | 1589 | |
1461 | 1590 | return 1; |
1462 | - } |
|
1463 | - else |
|
1591 | + } else |
|
1464 | 1592 | { |
1465 | 1593 | dol_syslog('FailedToDetectDirInDolMetaCreateFor'.$object->element, LOG_WARNING); |
1466 | 1594 | } |
@@ -1522,9 +1650,11 @@ discard block |
||
1522 | 1650 | |
1523 | 1651 | $res = 0; |
1524 | 1652 | |
1525 | - if (! empty($_FILES[$varfiles])) // For view $_FILES[$varfiles]['error'] |
|
1653 | + if (! empty($_FILES[$varfiles])) { |
|
1654 | + // For view $_FILES[$varfiles]['error'] |
|
1526 | 1655 | { |
1527 | 1656 | dol_syslog('dol_add_file_process upload_dir='.$upload_dir.' allowoverwrite='.$allowoverwrite.' donotupdatesession='.$donotupdatesession.' savingdocmask='.$savingdocmask, LOG_DEBUG); |
1657 | + } |
|
1528 | 1658 | if (dol_mkdir($upload_dir) >= 0) |
1529 | 1659 | { |
1530 | 1660 | $TFile = $_FILES[$varfiles]; |
@@ -1558,9 +1688,11 @@ discard block |
||
1558 | 1688 | |
1559 | 1689 | $resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destfull, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles); |
1560 | 1690 | |
1561 | - if (is_numeric($resupload) && $resupload > 0) // $resupload can be 'ErrorFileAlreadyExists' |
|
1691 | + if (is_numeric($resupload) && $resupload > 0) { |
|
1692 | + // $resupload can be 'ErrorFileAlreadyExists' |
|
1562 | 1693 | { |
1563 | 1694 | global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini; |
1695 | + } |
|
1564 | 1696 | |
1565 | 1697 | include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
1566 | 1698 | |
@@ -1600,19 +1732,20 @@ discard block |
||
1600 | 1732 | } |
1601 | 1733 | |
1602 | 1734 | $nbok++; |
1603 | - } |
|
1604 | - else |
|
1735 | + } else |
|
1605 | 1736 | { |
1606 | 1737 | $langs->load("errors"); |
1607 | - if ($resupload < 0) // Unknown error |
|
1738 | + if ($resupload < 0) { |
|
1739 | + // Unknown error |
|
1608 | 1740 | { |
1609 | 1741 | setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors'); |
1610 | 1742 | } |
1611 | - else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus |
|
1743 | + } else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) { |
|
1744 | + // Files infected by a virus |
|
1612 | 1745 | { |
1613 | 1746 | setEventMessages($langs->trans("ErrorFileIsInfectedWithAVirus"), null, 'errors'); |
1614 | 1747 | } |
1615 | - else // Known error |
|
1748 | + } else // Known error |
|
1616 | 1749 | { |
1617 | 1750 | setEventMessages($langs->trans($resupload), null, 'errors'); |
1618 | 1751 | } |
@@ -1639,8 +1772,7 @@ discard block |
||
1639 | 1772 | } else { |
1640 | 1773 | setEventMessages($langs->trans("ErrorFileNotLinked"), null, 'errors'); |
1641 | 1774 | } |
1642 | - } |
|
1643 | - else |
|
1775 | + } else |
|
1644 | 1776 | { |
1645 | 1777 | $langs->load("errors"); |
1646 | 1778 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("File")), null, 'errors'); |
@@ -1671,16 +1803,27 @@ discard block |
||
1671 | 1803 | $listofnames=array(); |
1672 | 1804 | $listofmimes=array(); |
1673 | 1805 | $keytoavoidconflict = empty($trackid)?'':'-'.$trackid; |
1674 | - if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]); |
|
1675 | - if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]); |
|
1676 | - if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]); |
|
1806 | + if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) { |
|
1807 | + $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]); |
|
1808 | + } |
|
1809 | + if (! empty($_SESSION["listofnames".$keytoavoidconflict])) { |
|
1810 | + $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]); |
|
1811 | + } |
|
1812 | + if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) { |
|
1813 | + $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]); |
|
1814 | + } |
|
1677 | 1815 | |
1678 | 1816 | if ($keytodelete >= 0) |
1679 | 1817 | { |
1680 | 1818 | $pathtodelete=$listofpaths[$keytodelete]; |
1681 | 1819 | $filetodelete=$listofnames[$keytodelete]; |
1682 | - if (empty($donotdeletefile)) $result = dol_delete_file($pathtodelete,1); // The delete of ecm database is inside the function dol_delete_file |
|
1683 | - else $result=0; |
|
1820 | + if (empty($donotdeletefile)) { |
|
1821 | + $result = dol_delete_file($pathtodelete,1); |
|
1822 | + } |
|
1823 | + // The delete of ecm database is inside the function dol_delete_file |
|
1824 | + else { |
|
1825 | + $result=0; |
|
1826 | + } |
|
1684 | 1827 | if ($result >= 0) |
1685 | 1828 | { |
1686 | 1829 | if (empty($donotdeletefile)) |
@@ -1720,9 +1863,11 @@ discard block |
||
1720 | 1863 | |
1721 | 1864 | $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $dir); |
1722 | 1865 | |
1723 | - if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir |
|
1866 | + if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) { |
|
1867 | + // If not a tmp dir |
|
1724 | 1868 | { |
1725 | 1869 | $filename = basename($file); |
1870 | + } |
|
1726 | 1871 | $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
1727 | 1872 | $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
1728 | 1873 | |
@@ -1785,8 +1930,12 @@ discard block |
||
1785 | 1930 | $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'ecm_files'; |
1786 | 1931 | $sql.= ' WHERE entity = '.$conf->entity; |
1787 | 1932 | $sql.= " AND filepath = '" . $db->escape($rel_dir) . "'"; |
1788 | - if ($file) $sql.= " AND filename = '" . $db->escape($file) . "'"; |
|
1789 | - if ($mode) $sql.= " AND gen_or_uploaded = '" . $db->escape($mode) . "'"; |
|
1933 | + if ($file) { |
|
1934 | + $sql.= " AND filename = '" . $db->escape($file) . "'"; |
|
1935 | + } |
|
1936 | + if ($mode) { |
|
1937 | + $sql.= " AND gen_or_uploaded = '" . $db->escape($mode) . "'"; |
|
1938 | + } |
|
1790 | 1939 | |
1791 | 1940 | $resql = $db->query($sql); |
1792 | 1941 | if (!$resql) |
@@ -1834,32 +1983,33 @@ discard block |
||
1834 | 1983 | $ret = $image->setImageFormat($ext); |
1835 | 1984 | if ($ret) |
1836 | 1985 | { |
1837 | - if (empty($fileoutput)) $fileoutput=$fileinput.".".$ext; |
|
1986 | + if (empty($fileoutput)) { |
|
1987 | + $fileoutput=$fileinput.".".$ext; |
|
1988 | + } |
|
1838 | 1989 | |
1839 | 1990 | $count = $image->getNumberImages(); |
1840 | 1991 | |
1841 | 1992 | if (! dol_is_file($fileoutput) || is_writeable($fileoutput)) |
1842 | 1993 | { |
1843 | 1994 | $ret = $image->writeImages($fileoutput, true); |
1844 | - } |
|
1845 | - else |
|
1995 | + } else |
|
1846 | 1996 | { |
1847 | 1997 | dol_syslog("Warning: Failed to write cache preview file '.$fileoutput.'. Check permission on file/dir", LOG_ERR); |
1848 | 1998 | } |
1849 | - if ($ret) return $count; |
|
1850 | - else return -3; |
|
1851 | - } |
|
1852 | - else |
|
1999 | + if ($ret) { |
|
2000 | + return $count; |
|
2001 | + } else { |
|
2002 | + return -3; |
|
2003 | + } |
|
2004 | + } else |
|
1853 | 2005 | { |
1854 | 2006 | return -2; |
1855 | 2007 | } |
1856 | - } |
|
1857 | - else |
|
2008 | + } else |
|
1858 | 2009 | { |
1859 | 2010 | return -1; |
1860 | 2011 | } |
1861 | - } |
|
1862 | - else |
|
2012 | + } else |
|
1863 | 2013 | { |
1864 | 2014 | return 0; |
1865 | 2015 | } |
@@ -1881,9 +2031,7 @@ discard block |
||
1881 | 2031 | try |
1882 | 2032 | { |
1883 | 2033 | $data = implode("", file(dol_osencode($inputfile))); |
1884 | - if ($mode == 'gz') { $foundhandler=1; $compressdata = gzencode($data, 9); } |
|
1885 | - elseif ($mode == 'bz') { $foundhandler=1; $compressdata = bzcompress($data, 9); } |
|
1886 | - elseif ($mode == 'zip') |
|
2034 | + if ($mode == 'gz') { $foundhandler=1; $compressdata = gzencode($data, 9); } elseif ($mode == 'bz') { $foundhandler=1; $compressdata = bzcompress($data, 9); } elseif ($mode == 'zip') |
|
1887 | 2035 | { |
1888 | 2036 | if (defined('ODTPHP_PATHTOPCLZIP')) |
1889 | 2037 | { |
@@ -1903,14 +2051,12 @@ discard block |
||
1903 | 2051 | fwrite($fp, $compressdata); |
1904 | 2052 | fclose($fp); |
1905 | 2053 | return 1; |
1906 | - } |
|
1907 | - else |
|
2054 | + } else |
|
1908 | 2055 | { |
1909 | 2056 | dol_syslog("Try to zip with format ".$mode." with no handler for this format",LOG_ERR); |
1910 | 2057 | return -2; |
1911 | 2058 | } |
1912 | - } |
|
1913 | - catch (Exception $e) |
|
2059 | + } catch (Exception $e) |
|
1914 | 2060 | { |
1915 | 2061 | global $langs, $errormsg; |
1916 | 2062 | $langs->load("errors"); |
@@ -1938,8 +2084,9 @@ discard block |
||
1938 | 2084 | $archive = new PclZip($inputfile); |
1939 | 2085 | $result=$archive->extract(PCLZIP_OPT_PATH, $outputdir); |
1940 | 2086 | //var_dump($result); |
1941 | - if (! is_array($result) && $result <= 0) return array('error'=>$archive->errorInfo(true)); |
|
1942 | - else |
|
2087 | + if (! is_array($result) && $result <= 0) { |
|
2088 | + return array('error'=>$archive->errorInfo(true)); |
|
2089 | + } else |
|
1943 | 2090 | { |
1944 | 2091 | $ok=1; $errmsg=''; |
1945 | 2092 | // Loop on each file to check result for unzipping file |
@@ -1954,8 +2101,11 @@ discard block |
||
1954 | 2101 | } |
1955 | 2102 | } |
1956 | 2103 | |
1957 | - if ($ok) return array(); |
|
1958 | - else return array('error'=>$errmsg); |
|
2104 | + if ($ok) { |
|
2105 | + return array(); |
|
2106 | + } else { |
|
2107 | + return array('error'=>$errmsg); |
|
2108 | + } |
|
1959 | 2109 | } |
1960 | 2110 | } |
1961 | 2111 | |
@@ -1969,8 +2119,7 @@ discard block |
||
1969 | 2119 | $zip->extractTo($outputdir.'/'); |
1970 | 2120 | $zip->close(); |
1971 | 2121 | return array(); |
1972 | - } |
|
1973 | - else |
|
2122 | + } else |
|
1974 | 2123 | { |
1975 | 2124 | return array('error'=>'ErrUnzipFails'); |
1976 | 2125 | } |
@@ -2004,9 +2153,7 @@ discard block |
||
2004 | 2153 | |
2005 | 2154 | try |
2006 | 2155 | { |
2007 | - if ($mode == 'gz') { $foundhandler=0; } |
|
2008 | - elseif ($mode == 'bz') { $foundhandler=0; } |
|
2009 | - elseif ($mode == 'zip') |
|
2156 | + if ($mode == 'gz') { $foundhandler=0; } elseif ($mode == 'bz') { $foundhandler=0; } elseif ($mode == 'zip') |
|
2010 | 2157 | { |
2011 | 2158 | /*if (defined('ODTPHP_PATHTOPCLZIP')) |
2012 | 2159 | { |
@@ -2059,13 +2206,11 @@ discard block |
||
2059 | 2206 | { |
2060 | 2207 | dol_syslog("Try to zip with format ".$mode." with no handler for this format",LOG_ERR); |
2061 | 2208 | return -2; |
2062 | - } |
|
2063 | - else |
|
2209 | + } else |
|
2064 | 2210 | { |
2065 | 2211 | return 0; |
2066 | 2212 | } |
2067 | - } |
|
2068 | - catch (Exception $e) |
|
2213 | + } catch (Exception $e) |
|
2069 | 2214 | { |
2070 | 2215 | global $langs, $errormsg; |
2071 | 2216 | $langs->load("errors"); |
@@ -2111,16 +2256,25 @@ discard block |
||
2111 | 2256 | global $conf, $db, $user; |
2112 | 2257 | global $dolibarr_main_data_root, $dolibarr_main_document_root_alt; |
2113 | 2258 | |
2114 | - if (! is_object($fuser)) $fuser=$user; |
|
2259 | + if (! is_object($fuser)) { |
|
2260 | + $fuser=$user; |
|
2261 | + } |
|
2115 | 2262 | |
2116 | - if (empty($modulepart)) return 'ErrorBadParameter'; |
|
2263 | + if (empty($modulepart)) { |
|
2264 | + return 'ErrorBadParameter'; |
|
2265 | + } |
|
2117 | 2266 | if (empty($entity)) |
2118 | 2267 | { |
2119 | - if (empty($conf->multicompany->enabled)) $entity=1; |
|
2120 | - else $entity=0; |
|
2268 | + if (empty($conf->multicompany->enabled)) { |
|
2269 | + $entity=1; |
|
2270 | + } else { |
|
2271 | + $entity=0; |
|
2272 | + } |
|
2121 | 2273 | } |
2122 | 2274 | // Fix modulepart |
2123 | - if ($modulepart == 'users') $modulepart='user'; |
|
2275 | + if ($modulepart == 'users') { |
|
2276 | + $modulepart='user'; |
|
2277 | + } |
|
2124 | 2278 | |
2125 | 2279 | dol_syslog('modulepart='.$modulepart.' original_file='.$original_file.' entity='.$entity); |
2126 | 2280 | // We define $accessallowed and $sqlprotectagainstexternals |
@@ -2129,7 +2283,9 @@ discard block |
||
2129 | 2283 | $ret=array(); |
2130 | 2284 | |
2131 | 2285 | // Find the subdirectory name as the reference. For exemple original_file='10/myfile.pdf' -> refname='10' |
2132 | - if (empty($refname)) $refname=basename(dirname($original_file)."/"); |
|
2286 | + if (empty($refname)) { |
|
2287 | + $refname=basename(dirname($original_file)."/"); |
|
2288 | + } |
|
2133 | 2289 | |
2134 | 2290 | $relative_original_file = $original_file; |
2135 | 2291 | |
@@ -2143,7 +2299,9 @@ discard block |
||
2143 | 2299 | // Wrapping for miscellaneous medias files |
2144 | 2300 | if ($modulepart == 'medias' && !empty($dolibarr_main_data_root)) |
2145 | 2301 | { |
2146 | - if (empty($entity) || empty($conf->medias->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); |
|
2302 | + if (empty($entity) || empty($conf->medias->multidir_output[$entity])) { |
|
2303 | + return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); |
|
2304 | + } |
|
2147 | 2305 | $accessallowed=1; |
2148 | 2306 | $original_file=$conf->medias->multidir_output[$entity].'/'.$original_file; |
2149 | 2307 | } |
@@ -2184,132 +2342,176 @@ discard block |
||
2184 | 2342 | // Wrapping pour les apercu factures |
2185 | 2343 | elseif ($modulepart == 'apercufacture' && !empty($conf->facture->dir_output)) |
2186 | 2344 | { |
2187 | - if ($fuser->rights->facture->{$lire}) $accessallowed=1; |
|
2345 | + if ($fuser->rights->facture->{$lire}) { |
|
2346 | + $accessallowed=1; |
|
2347 | + } |
|
2188 | 2348 | $original_file=$conf->facture->dir_output.'/'.$original_file; |
2189 | 2349 | } |
2190 | 2350 | // Wrapping pour les apercu propal |
2191 | 2351 | elseif ($modulepart == 'apercupropal' && !empty($conf->propal->multidir_output[$entity])) |
2192 | 2352 | { |
2193 | - if ($fuser->rights->propale->{$lire}) $accessallowed=1; |
|
2353 | + if ($fuser->rights->propale->{$lire}) { |
|
2354 | + $accessallowed=1; |
|
2355 | + } |
|
2194 | 2356 | $original_file=$conf->propal->multidir_output[$entity].'/'.$original_file; |
2195 | 2357 | } |
2196 | 2358 | // Wrapping pour les apercu commande |
2197 | 2359 | elseif ($modulepart == 'apercucommande' && !empty($conf->commande->dir_output)) |
2198 | 2360 | { |
2199 | - if ($fuser->rights->commande->{$lire}) $accessallowed=1; |
|
2361 | + if ($fuser->rights->commande->{$lire}) { |
|
2362 | + $accessallowed=1; |
|
2363 | + } |
|
2200 | 2364 | $original_file=$conf->commande->dir_output.'/'.$original_file; |
2201 | 2365 | } |
2202 | 2366 | // Wrapping pour les apercu intervention |
2203 | 2367 | elseif (($modulepart == 'apercufichinter' || $modulepart == 'apercuficheinter') && !empty($conf->ficheinter->dir_output)) |
2204 | 2368 | { |
2205 | - if ($fuser->rights->ficheinter->{$lire}) $accessallowed=1; |
|
2369 | + if ($fuser->rights->ficheinter->{$lire}) { |
|
2370 | + $accessallowed=1; |
|
2371 | + } |
|
2206 | 2372 | $original_file=$conf->ficheinter->dir_output.'/'.$original_file; |
2207 | 2373 | } |
2208 | 2374 | // Wrapping pour les apercu conat |
2209 | 2375 | elseif (($modulepart == 'apercucontract') && !empty($conf->contrat->dir_output)) |
2210 | 2376 | { |
2211 | - if ($fuser->rights->contrat->{$lire}) $accessallowed=1; |
|
2377 | + if ($fuser->rights->contrat->{$lire}) { |
|
2378 | + $accessallowed=1; |
|
2379 | + } |
|
2212 | 2380 | $original_file=$conf->contrat->dir_output.'/'.$original_file; |
2213 | 2381 | } |
2214 | 2382 | // Wrapping pour les apercu supplier proposal |
2215 | 2383 | elseif (($modulepart == 'apercusupplier_proposal' || $modulepart == 'apercusupplier_proposal') && !empty($conf->supplier_proposal->dir_output)) |
2216 | 2384 | { |
2217 | - if ($fuser->rights->supplier_proposal->{$lire}) $accessallowed=1; |
|
2385 | + if ($fuser->rights->supplier_proposal->{$lire}) { |
|
2386 | + $accessallowed=1; |
|
2387 | + } |
|
2218 | 2388 | $original_file=$conf->supplier_proposal->dir_output.'/'.$original_file; |
2219 | 2389 | } |
2220 | 2390 | // Wrapping pour les apercu supplier order |
2221 | 2391 | elseif (($modulepart == 'apercusupplier_order' || $modulepart == 'apercusupplier_order') && !empty($conf->fournisseur->commande->dir_output)) |
2222 | 2392 | { |
2223 | - if ($fuser->rights->fournisseur->commande->{$lire}) $accessallowed=1; |
|
2393 | + if ($fuser->rights->fournisseur->commande->{$lire}) { |
|
2394 | + $accessallowed=1; |
|
2395 | + } |
|
2224 | 2396 | $original_file=$conf->fournisseur->commande->dir_output.'/'.$original_file; |
2225 | 2397 | } |
2226 | 2398 | // Wrapping pour les apercu supplier invoice |
2227 | 2399 | elseif (($modulepart == 'apercusupplier_invoice' || $modulepart == 'apercusupplier_invoice') && !empty($conf->fournisseur->facture->dir_output)) |
2228 | 2400 | { |
2229 | - if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed=1; |
|
2401 | + if ($fuser->rights->fournisseur->facture->{$lire}) { |
|
2402 | + $accessallowed=1; |
|
2403 | + } |
|
2230 | 2404 | $original_file=$conf->fournisseur->facture->dir_output.'/'.$original_file; |
2231 | 2405 | } |
2232 | 2406 | // Wrapping pour les apercu supplier invoice |
2233 | 2407 | elseif (($modulepart == 'apercuexpensereport') && !empty($conf->expensereport->dir_output)) |
2234 | 2408 | { |
2235 | - if ($fuser->rights->expensereport->{$lire}) $accessallowed=1; |
|
2409 | + if ($fuser->rights->expensereport->{$lire}) { |
|
2410 | + $accessallowed=1; |
|
2411 | + } |
|
2236 | 2412 | $original_file=$conf->expensereport->dir_output.'/'.$original_file; |
2237 | 2413 | } |
2238 | 2414 | // Wrapping pour les images des stats propales |
2239 | 2415 | elseif ($modulepart == 'propalstats' && !empty($conf->propal->multidir_temp[$entity])) |
2240 | 2416 | { |
2241 | - if ($fuser->rights->propale->{$lire}) $accessallowed=1; |
|
2417 | + if ($fuser->rights->propale->{$lire}) { |
|
2418 | + $accessallowed=1; |
|
2419 | + } |
|
2242 | 2420 | $original_file=$conf->propal->multidir_temp[$entity].'/'.$original_file; |
2243 | 2421 | } |
2244 | 2422 | // Wrapping pour les images des stats commandes |
2245 | 2423 | elseif ($modulepart == 'orderstats' && !empty($conf->commande->dir_temp)) |
2246 | 2424 | { |
2247 | - if ($fuser->rights->commande->{$lire}) $accessallowed=1; |
|
2425 | + if ($fuser->rights->commande->{$lire}) { |
|
2426 | + $accessallowed=1; |
|
2427 | + } |
|
2248 | 2428 | $original_file=$conf->commande->dir_temp.'/'.$original_file; |
2249 | - } |
|
2250 | - elseif ($modulepart == 'orderstatssupplier' && !empty($conf->fournisseur->dir_output)) |
|
2429 | + } elseif ($modulepart == 'orderstatssupplier' && !empty($conf->fournisseur->dir_output)) |
|
2251 | 2430 | { |
2252 | - if ($fuser->rights->fournisseur->commande->{$lire}) $accessallowed=1; |
|
2431 | + if ($fuser->rights->fournisseur->commande->{$lire}) { |
|
2432 | + $accessallowed=1; |
|
2433 | + } |
|
2253 | 2434 | $original_file=$conf->fournisseur->commande->dir_temp.'/'.$original_file; |
2254 | 2435 | } |
2255 | 2436 | // Wrapping pour les images des stats factures |
2256 | 2437 | elseif ($modulepart == 'billstats' && !empty($conf->facture->dir_temp)) |
2257 | 2438 | { |
2258 | - if ($fuser->rights->facture->{$lire}) $accessallowed=1; |
|
2439 | + if ($fuser->rights->facture->{$lire}) { |
|
2440 | + $accessallowed=1; |
|
2441 | + } |
|
2259 | 2442 | $original_file=$conf->facture->dir_temp.'/'.$original_file; |
2260 | - } |
|
2261 | - elseif ($modulepart == 'billstatssupplier' && !empty($conf->fournisseur->dir_output)) |
|
2443 | + } elseif ($modulepart == 'billstatssupplier' && !empty($conf->fournisseur->dir_output)) |
|
2262 | 2444 | { |
2263 | - if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed=1; |
|
2445 | + if ($fuser->rights->fournisseur->facture->{$lire}) { |
|
2446 | + $accessallowed=1; |
|
2447 | + } |
|
2264 | 2448 | $original_file=$conf->fournisseur->facture->dir_temp.'/'.$original_file; |
2265 | 2449 | } |
2266 | 2450 | // Wrapping pour les images des stats expeditions |
2267 | 2451 | elseif ($modulepart == 'expeditionstats' && !empty($conf->expedition->dir_temp)) |
2268 | 2452 | { |
2269 | - if ($fuser->rights->expedition->{$lire}) $accessallowed=1; |
|
2453 | + if ($fuser->rights->expedition->{$lire}) { |
|
2454 | + $accessallowed=1; |
|
2455 | + } |
|
2270 | 2456 | $original_file=$conf->expedition->dir_temp.'/'.$original_file; |
2271 | 2457 | } |
2272 | 2458 | // Wrapping pour les images des stats expeditions |
2273 | 2459 | elseif ($modulepart == 'tripsexpensesstats' && !empty($conf->deplacement->dir_temp)) |
2274 | 2460 | { |
2275 | - if ($fuser->rights->deplacement->{$lire}) $accessallowed=1; |
|
2461 | + if ($fuser->rights->deplacement->{$lire}) { |
|
2462 | + $accessallowed=1; |
|
2463 | + } |
|
2276 | 2464 | $original_file=$conf->deplacement->dir_temp.'/'.$original_file; |
2277 | 2465 | } |
2278 | 2466 | // Wrapping pour les images des stats expeditions |
2279 | 2467 | elseif ($modulepart == 'memberstats' && !empty($conf->adherent->dir_temp)) |
2280 | 2468 | { |
2281 | - if ($fuser->rights->adherent->{$lire}) $accessallowed=1; |
|
2469 | + if ($fuser->rights->adherent->{$lire}) { |
|
2470 | + $accessallowed=1; |
|
2471 | + } |
|
2282 | 2472 | $original_file=$conf->adherent->dir_temp.'/'.$original_file; |
2283 | 2473 | } |
2284 | 2474 | // Wrapping pour les images des stats produits |
2285 | 2475 | elseif (preg_match('/^productstats_/i',$modulepart) && !empty($conf->product->dir_temp)) |
2286 | 2476 | { |
2287 | - if ($fuser->rights->produit->{$lire} || $fuser->rights->service->{$lire}) $accessallowed=1; |
|
2477 | + if ($fuser->rights->produit->{$lire} || $fuser->rights->service->{$lire}) { |
|
2478 | + $accessallowed=1; |
|
2479 | + } |
|
2288 | 2480 | $original_file=(!empty($conf->product->multidir_temp[$entity])?$conf->product->multidir_temp[$entity]:$conf->service->multidir_temp[$entity]).'/'.$original_file; |
2289 | 2481 | } |
2290 | 2482 | // Wrapping for taxes |
2291 | 2483 | elseif ($modulepart == 'tax' && !empty($conf->tax->dir_output)) |
2292 | 2484 | { |
2293 | - if ($fuser->rights->tax->charges->{$lire}) $accessallowed=1; |
|
2485 | + if ($fuser->rights->tax->charges->{$lire}) { |
|
2486 | + $accessallowed=1; |
|
2487 | + } |
|
2294 | 2488 | $original_file=$conf->tax->dir_output.'/'.$original_file; |
2295 | 2489 | } |
2296 | 2490 | // Wrapping for events |
2297 | 2491 | elseif ($modulepart == 'actions' && !empty($conf->agenda->dir_output)) |
2298 | 2492 | { |
2299 | - if ($fuser->rights->agenda->myactions->{$read}) $accessallowed=1; |
|
2493 | + if ($fuser->rights->agenda->myactions->{$read}) { |
|
2494 | + $accessallowed=1; |
|
2495 | + } |
|
2300 | 2496 | $original_file=$conf->agenda->dir_output.'/'.$original_file; |
2301 | 2497 | } |
2302 | 2498 | // Wrapping for categories |
2303 | 2499 | elseif ($modulepart == 'category' && !empty($conf->categorie->dir_output)) |
2304 | 2500 | { |
2305 | - if (empty($entity) || empty($conf->categorie->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); |
|
2306 | - if ($fuser->rights->categorie->{$lire}) $accessallowed=1; |
|
2501 | + if (empty($entity) || empty($conf->categorie->multidir_output[$entity])) { |
|
2502 | + return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); |
|
2503 | + } |
|
2504 | + if ($fuser->rights->categorie->{$lire}) { |
|
2505 | + $accessallowed=1; |
|
2506 | + } |
|
2307 | 2507 | $original_file=$conf->categorie->multidir_output[$entity].'/'.$original_file; |
2308 | 2508 | } |
2309 | 2509 | // Wrapping pour les prelevements |
2310 | 2510 | elseif ($modulepart == 'prelevement' && !empty($conf->prelevement->dir_output)) |
2311 | 2511 | { |
2312 | - if ($fuser->rights->prelevement->bons->{$lire} || preg_match('/^specimen/i',$original_file)) $accessallowed=1; |
|
2512 | + if ($fuser->rights->prelevement->bons->{$lire} || preg_match('/^specimen/i',$original_file)) { |
|
2513 | + $accessallowed=1; |
|
2514 | + } |
|
2313 | 2515 | $original_file=$conf->prelevement->dir_output.'/'.$original_file; |
2314 | 2516 | } |
2315 | 2517 | // Wrapping pour les graph energie |
@@ -2372,7 +2574,9 @@ discard block |
||
2372 | 2574 | // Wrapping for third parties |
2373 | 2575 | else if (($modulepart == 'company' || $modulepart == 'societe') && !empty($conf->societe->dir_output)) |
2374 | 2576 | { |
2375 | - if (empty($entity) || empty($conf->societe->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); |
|
2577 | + if (empty($entity) || empty($conf->societe->multidir_output[$entity])) { |
|
2578 | + return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); |
|
2579 | + } |
|
2376 | 2580 | if ($fuser->rights->societe->{$lire} || preg_match('/^specimen/i',$original_file)) |
2377 | 2581 | { |
2378 | 2582 | $accessallowed=1; |
@@ -2384,7 +2588,9 @@ discard block |
||
2384 | 2588 | // Wrapping for contact |
2385 | 2589 | else if ($modulepart == 'contact' && !empty($conf->societe->dir_output)) |
2386 | 2590 | { |
2387 | - if (empty($entity) || empty($conf->societe->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); |
|
2591 | + if (empty($entity) || empty($conf->societe->multidir_output[$entity])) { |
|
2592 | + return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); |
|
2593 | + } |
|
2388 | 2594 | if ($fuser->rights->societe->{$lire}) |
2389 | 2595 | { |
2390 | 2596 | $accessallowed=1; |
@@ -2410,64 +2616,56 @@ discard block |
||
2410 | 2616 | $accessallowed=1; |
2411 | 2617 | } |
2412 | 2618 | $original_file=$conf->propal->multidir_output[$entity].'/temp/massgeneration/'.$user->id.'/'.$original_file; |
2413 | - } |
|
2414 | - else if ($modulepart == 'massfilesarea_orders') |
|
2619 | + } else if ($modulepart == 'massfilesarea_orders') |
|
2415 | 2620 | { |
2416 | 2621 | if ($fuser->rights->commande->{$lire} || preg_match('/^specimen/i',$original_file)) |
2417 | 2622 | { |
2418 | 2623 | $accessallowed=1; |
2419 | 2624 | } |
2420 | 2625 | $original_file=$conf->commande->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; |
2421 | - } |
|
2422 | - else if ($modulepart == 'massfilesarea_invoices') |
|
2626 | + } else if ($modulepart == 'massfilesarea_invoices') |
|
2423 | 2627 | { |
2424 | 2628 | if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i',$original_file)) |
2425 | 2629 | { |
2426 | 2630 | $accessallowed=1; |
2427 | 2631 | } |
2428 | 2632 | $original_file=$conf->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; |
2429 | - } |
|
2430 | - else if ($modulepart == 'massfilesarea_expensereport') |
|
2633 | + } else if ($modulepart == 'massfilesarea_expensereport') |
|
2431 | 2634 | { |
2432 | 2635 | if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i',$original_file)) |
2433 | 2636 | { |
2434 | 2637 | $accessallowed=1; |
2435 | 2638 | } |
2436 | 2639 | $original_file=$conf->expensereport->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; |
2437 | - } |
|
2438 | - else if ($modulepart == 'massfilesarea_interventions') |
|
2640 | + } else if ($modulepart == 'massfilesarea_interventions') |
|
2439 | 2641 | { |
2440 | 2642 | if ($fuser->rights->ficheinter->{$lire} || preg_match('/^specimen/i',$original_file)) |
2441 | 2643 | { |
2442 | 2644 | $accessallowed=1; |
2443 | 2645 | } |
2444 | 2646 | $original_file=$conf->ficheinter->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; |
2445 | - } |
|
2446 | - else if ($modulepart == 'massfilesarea_supplier_proposal' && !empty($conf->supplier_proposal->dir_output)) |
|
2647 | + } else if ($modulepart == 'massfilesarea_supplier_proposal' && !empty($conf->supplier_proposal->dir_output)) |
|
2447 | 2648 | { |
2448 | 2649 | if ($fuser->rights->supplier_proposal->{$lire} || preg_match('/^specimen/i',$original_file)) |
2449 | 2650 | { |
2450 | 2651 | $accessallowed=1; |
2451 | 2652 | } |
2452 | 2653 | $original_file=$conf->supplier_proposal->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; |
2453 | - } |
|
2454 | - else if ($modulepart == 'massfilesarea_supplier_order') |
|
2654 | + } else if ($modulepart == 'massfilesarea_supplier_order') |
|
2455 | 2655 | { |
2456 | 2656 | if ($fuser->rights->fournisseur->commande->{$lire} || preg_match('/^specimen/i',$original_file)) |
2457 | 2657 | { |
2458 | 2658 | $accessallowed=1; |
2459 | 2659 | } |
2460 | 2660 | $original_file=$conf->fournisseur->commande->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; |
2461 | - } |
|
2462 | - else if ($modulepart == 'massfilesarea_supplier_invoice') |
|
2661 | + } else if ($modulepart == 'massfilesarea_supplier_invoice') |
|
2463 | 2662 | { |
2464 | 2663 | if ($fuser->rights->fournisseur->facture->{$lire} || preg_match('/^specimen/i',$original_file)) |
2465 | 2664 | { |
2466 | 2665 | $accessallowed=1; |
2467 | 2666 | } |
2468 | 2667 | $original_file=$conf->fournisseur->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; |
2469 | - } |
|
2470 | - else if ($modulepart == 'massfilesarea_contract' && !empty($conf->contrat->dir_output)) |
|
2668 | + } else if ($modulepart == 'massfilesarea_contract' && !empty($conf->contrat->dir_output)) |
|
2471 | 2669 | { |
2472 | 2670 | if ($fuser->rights->contrat->{$lire} || preg_match('/^specimen/i',$original_file)) |
2473 | 2671 | { |
@@ -2528,8 +2726,7 @@ discard block |
||
2528 | 2726 | } |
2529 | 2727 | $original_file=$conf->projet->dir_output.'/'.$original_file; |
2530 | 2728 | $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('project').")"; |
2531 | - } |
|
2532 | - else if ($modulepart == 'project_task' && !empty($conf->projet->dir_output)) |
|
2729 | + } else if ($modulepart == 'project_task' && !empty($conf->projet->dir_output)) |
|
2533 | 2730 | { |
2534 | 2731 | if ($fuser->rights->projet->{$lire} || preg_match('/^specimen/i',$original_file)) |
2535 | 2732 | { |
@@ -2578,8 +2775,11 @@ discard block |
||
2578 | 2775 | { |
2579 | 2776 | $accessallowed=1; |
2580 | 2777 | } |
2581 | - if ($fuser->societe_id > 0) $original_file=$conf->facture->dir_output.'/payments/private/'.$fuser->id.'/'.$original_file; |
|
2582 | - else $original_file=$conf->facture->dir_output.'/payments/'.$original_file; |
|
2778 | + if ($fuser->societe_id > 0) { |
|
2779 | + $original_file=$conf->facture->dir_output.'/payments/private/'.$fuser->id.'/'.$original_file; |
|
2780 | + } else { |
|
2781 | + $original_file=$conf->facture->dir_output.'/payments/'.$original_file; |
|
2782 | + } |
|
2583 | 2783 | } |
2584 | 2784 | |
2585 | 2785 | // Wrapping for accounting exports |
@@ -2634,24 +2834,33 @@ discard block |
||
2634 | 2834 | // Wrapping pour les produits et services |
2635 | 2835 | else if ($modulepart == 'product' || $modulepart == 'produit' || $modulepart == 'service' || $modulepart == 'produit|service') |
2636 | 2836 | { |
2637 | - if (empty($entity) || (empty($conf->product->multidir_output[$entity]) && empty($conf->service->multidir_output[$entity]))) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); |
|
2837 | + if (empty($entity) || (empty($conf->product->multidir_output[$entity]) && empty($conf->service->multidir_output[$entity]))) { |
|
2838 | + return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); |
|
2839 | + } |
|
2638 | 2840 | if (($fuser->rights->produit->{$lire} || $fuser->rights->service->{$lire}) || preg_match('/^specimen/i',$original_file)) |
2639 | 2841 | { |
2640 | 2842 | $accessallowed=1; |
2641 | 2843 | } |
2642 | - if (! empty($conf->product->enabled)) $original_file=$conf->product->multidir_output[$entity].'/'.$original_file; |
|
2643 | - elseif (! empty($conf->service->enabled)) $original_file=$conf->service->multidir_output[$entity].'/'.$original_file; |
|
2844 | + if (! empty($conf->product->enabled)) { |
|
2845 | + $original_file=$conf->product->multidir_output[$entity].'/'.$original_file; |
|
2846 | + } elseif (! empty($conf->service->enabled)) { |
|
2847 | + $original_file=$conf->service->multidir_output[$entity].'/'.$original_file; |
|
2848 | + } |
|
2644 | 2849 | } |
2645 | 2850 | |
2646 | 2851 | // Wrapping pour les lots produits |
2647 | 2852 | else if ($modulepart == 'product_batch' || $modulepart == 'produitlot') |
2648 | 2853 | { |
2649 | - if (empty($entity) || (empty($conf->productbatch->multidir_output[$entity]))) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); |
|
2854 | + if (empty($entity) || (empty($conf->productbatch->multidir_output[$entity]))) { |
|
2855 | + return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); |
|
2856 | + } |
|
2650 | 2857 | if (($fuser->rights->produit->{$lire} ) || preg_match('/^specimen/i',$original_file)) |
2651 | 2858 | { |
2652 | 2859 | $accessallowed=1; |
2653 | 2860 | } |
2654 | - if (! empty($conf->productbatch->enabled)) $original_file=$conf->productbatch->multidir_output[$entity].'/'.$original_file; |
|
2861 | + if (! empty($conf->productbatch->enabled)) { |
|
2862 | + $original_file=$conf->productbatch->multidir_output[$entity].'/'.$original_file; |
|
2863 | + } |
|
2655 | 2864 | } |
2656 | 2865 | |
2657 | 2866 | // Wrapping pour les contrats |
@@ -2732,14 +2941,18 @@ discard block |
||
2732 | 2941 | // Wrapping for backups |
2733 | 2942 | else if ($modulepart == 'systemtools' && !empty($conf->admin->dir_output)) |
2734 | 2943 | { |
2735 | - if ($fuser->admin) $accessallowed=1; |
|
2944 | + if ($fuser->admin) { |
|
2945 | + $accessallowed=1; |
|
2946 | + } |
|
2736 | 2947 | $original_file=$conf->admin->dir_output.'/'.$original_file; |
2737 | 2948 | } |
2738 | 2949 | |
2739 | 2950 | // Wrapping for upload file test |
2740 | 2951 | else if ($modulepart == 'admin_temp' && !empty($conf->admin->dir_temp)) |
2741 | 2952 | { |
2742 | - if ($fuser->admin) $accessallowed=1; |
|
2953 | + if ($fuser->admin) { |
|
2954 | + $accessallowed=1; |
|
2955 | + } |
|
2743 | 2956 | $original_file=$conf->admin->dir_temp.'/'.$original_file; |
2744 | 2957 | } |
2745 | 2958 | |
@@ -2748,7 +2961,9 @@ discard block |
||
2748 | 2961 | { |
2749 | 2962 | $accessallowed=1; |
2750 | 2963 | $dir='files'; |
2751 | - if (dol_mimetype($original_file) == 'application/x-bittorrent') $dir='torrents'; |
|
2964 | + if (dol_mimetype($original_file) == 'application/x-bittorrent') { |
|
2965 | + $dir='torrents'; |
|
2966 | + } |
|
2752 | 2967 | $original_file=$conf->bittorrent->dir_output.'/'.$dir.'/'.$original_file; |
2753 | 2968 | } |
2754 | 2969 | |
@@ -2776,45 +2991,62 @@ discard block |
||
2776 | 2991 | // If modulepart=module Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart |
2777 | 2992 | else |
2778 | 2993 | { |
2779 | - if (preg_match('/^specimen/i',$original_file)) $accessallowed=1; // If link to a file called specimen. Test must be done before changing $original_file int full path. |
|
2780 | - if ($fuser->admin) $accessallowed=1; // If user is admin |
|
2994 | + if (preg_match('/^specimen/i',$original_file)) { |
|
2995 | + $accessallowed=1; |
|
2996 | + } |
|
2997 | + // If link to a file called specimen. Test must be done before changing $original_file int full path. |
|
2998 | + if ($fuser->admin) { |
|
2999 | + $accessallowed=1; |
|
3000 | + } |
|
3001 | + // If user is admin |
|
2781 | 3002 | |
2782 | 3003 | // Define $accessallowed |
2783 | 3004 | if (preg_match('/^([a-z]+)_user_temp$/i',$modulepart,$reg)) |
2784 | 3005 | { |
2785 | - if (empty($conf->{$reg[1]}->dir_temp)) // modulepart not supported |
|
3006 | + if (empty($conf->{$reg[1]}->dir_temp)) { |
|
3007 | + // modulepart not supported |
|
2786 | 3008 | { |
2787 | 3009 | dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')'); |
3010 | + } |
|
2788 | 3011 | exit; |
2789 | 3012 | } |
2790 | - if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1; |
|
3013 | + if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) { |
|
3014 | + $accessallowed=1; |
|
3015 | + } |
|
2791 | 3016 | $original_file=$conf->{$reg[1]}->dir_temp.'/'.$fuser->id.'/'.$original_file; |
2792 | - } |
|
2793 | - else if (preg_match('/^([a-z]+)_temp$/i',$modulepart,$reg)) |
|
3017 | + } else if (preg_match('/^([a-z]+)_temp$/i',$modulepart,$reg)) |
|
2794 | 3018 | { |
2795 | - if (empty($conf->{$reg[1]}->dir_temp)) // modulepart not supported |
|
3019 | + if (empty($conf->{$reg[1]}->dir_temp)) { |
|
3020 | + // modulepart not supported |
|
2796 | 3021 | { |
2797 | 3022 | dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')'); |
3023 | + } |
|
2798 | 3024 | exit; |
2799 | 3025 | } |
2800 | - if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1; |
|
3026 | + if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) { |
|
3027 | + $accessallowed=1; |
|
3028 | + } |
|
2801 | 3029 | $original_file=$conf->{$reg[1]}->dir_temp.'/'.$original_file; |
2802 | - } |
|
2803 | - else if (preg_match('/^([a-z]+)_user$/i',$modulepart,$reg)) |
|
3030 | + } else if (preg_match('/^([a-z]+)_user$/i',$modulepart,$reg)) |
|
2804 | 3031 | { |
2805 | - if (empty($conf->{$reg[1]}->dir_output)) // modulepart not supported |
|
3032 | + if (empty($conf->{$reg[1]}->dir_output)) { |
|
3033 | + // modulepart not supported |
|
2806 | 3034 | { |
2807 | 3035 | dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')'); |
3036 | + } |
|
2808 | 3037 | exit; |
2809 | 3038 | } |
2810 | - if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1; |
|
3039 | + if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) { |
|
3040 | + $accessallowed=1; |
|
3041 | + } |
|
2811 | 3042 | $original_file=$conf->{$reg[1]}->dir_output.'/'.$fuser->id.'/'.$original_file; |
2812 | - } |
|
2813 | - else if (preg_match('/^massfilesarea_([a-z]+)$/i', $modulepart, $reg)) |
|
3043 | + } else if (preg_match('/^massfilesarea_([a-z]+)$/i', $modulepart, $reg)) |
|
2814 | 3044 | { |
2815 | - if (empty($conf->{$reg[1]}->dir_output)) // modulepart not supported |
|
3045 | + if (empty($conf->{$reg[1]}->dir_output)) { |
|
3046 | + // modulepart not supported |
|
2816 | 3047 | { |
2817 | 3048 | dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')'); |
3049 | + } |
|
2818 | 3050 | exit; |
2819 | 3051 | } |
2820 | 3052 | if ($fuser->rights->{$reg[1]}->{$lire} || preg_match('/^specimen/i', $original_file)) |
@@ -2822,12 +3054,13 @@ discard block |
||
2822 | 3054 | $accessallowed=1; |
2823 | 3055 | } |
2824 | 3056 | $original_file=$conf->{$reg[1]}->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; |
2825 | - } |
|
2826 | - else |
|
3057 | + } else |
|
2827 | 3058 | { |
2828 | - if (empty($conf->$modulepart->dir_output)) // modulepart not supported |
|
3059 | + if (empty($conf->$modulepart->dir_output)) { |
|
3060 | + // modulepart not supported |
|
2829 | 3061 | { |
2830 | 3062 | dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')'); |
3063 | + } |
|
2831 | 3064 | exit; |
2832 | 3065 | } |
2833 | 3066 | |
@@ -2835,12 +3068,15 @@ discard block |
||
2835 | 3068 | $subperm=GETPOST('subperm'); |
2836 | 3069 | if ($perm || $subperm) |
2837 | 3070 | { |
2838 | - if (($perm && ! $subperm && $fuser->rights->$modulepart->$perm) || ($perm && $subperm && $fuser->rights->$modulepart->$perm->$subperm)) $accessallowed=1; |
|
3071 | + if (($perm && ! $subperm && $fuser->rights->$modulepart->$perm) || ($perm && $subperm && $fuser->rights->$modulepart->$perm->$subperm)) { |
|
3072 | + $accessallowed=1; |
|
3073 | + } |
|
2839 | 3074 | $original_file=$conf->$modulepart->dir_output.'/'.$original_file; |
2840 | - } |
|
2841 | - else |
|
3075 | + } else |
|
2842 | 3076 | { |
2843 | - if ($fuser->rights->$modulepart->{$lire} || $fuser->rights->$modulepart->{$read}) $accessallowed=1; |
|
3077 | + if ($fuser->rights->$modulepart->{$lire} || $fuser->rights->$modulepart->{$read}) { |
|
3078 | + $accessallowed=1; |
|
3079 | + } |
|
2844 | 3080 | $original_file=$conf->$modulepart->dir_output.'/'.$original_file; |
2845 | 3081 | } |
2846 | 3082 | } |
@@ -2858,11 +3094,13 @@ discard block |
||
2858 | 3094 | |
2859 | 3095 | // Define $sqlprotectagainstexternals for modules who want to protect access using a SQL query. |
2860 | 3096 | $sqlProtectConstName = strtoupper($modulepart).'_SQLPROTECTAGAINSTEXTERNALS_FOR_DOCUMENTS'; |
2861 | - if (! empty($conf->global->$sqlProtectConstName)) // If module want to define its own $sqlprotectagainstexternals |
|
3097 | + if (! empty($conf->global->$sqlProtectConstName)) { |
|
3098 | + // If module want to define its own $sqlprotectagainstexternals |
|
2862 | 3099 | { |
2863 | 3100 | // Example: mymodule__SQLPROTECTAGAINSTEXTERNALS_FOR_DOCUMENTS = "SELECT fk_soc FROM ".MAIN_DB_PREFIX.$modulepart." WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; |
2864 | 3101 | eval('$sqlprotectagainstexternals = "'.$conf->global->$sqlProtectConstName.'";'); |
2865 | 3102 | } |
3103 | + } |
|
2866 | 3104 | } |
2867 | 3105 | |
2868 | 3106 | $ret = array( |
@@ -2884,7 +3122,9 @@ discard block |
||
2884 | 3122 | */ |
2885 | 3123 | function dol_filecache($directory, $filename, $object) |
2886 | 3124 | { |
2887 | - if (! dol_is_dir($directory)) dol_mkdir($directory); |
|
3125 | + if (! dol_is_dir($directory)) { |
|
3126 | + dol_mkdir($directory); |
|
3127 | + } |
|
2888 | 3128 | $cachefile = $directory . $filename; |
2889 | 3129 | file_put_contents($cachefile, serialize($object), LOCK_EX); |
2890 | 3130 | @chmod($cachefile, 0644); |
@@ -2938,9 +3178,11 @@ discard block |
||
2938 | 3178 | |
2939 | 3179 | $exclude = 'install'; |
2940 | 3180 | |
2941 | - foreach ($dir->md5file as $file) // $file is a simpleXMLElement |
|
3181 | + foreach ($dir->md5file as $file) { |
|
3182 | + // $file is a simpleXMLElement |
|
2942 | 3183 | { |
2943 | 3184 | $filename = $path.$file['name']; |
3185 | + } |
|
2944 | 3186 | $file_list['insignature'][] = $filename; |
2945 | 3187 | $expectedmd5 = (string) $file; |
2946 | 3188 | |
@@ -2949,27 +3191,31 @@ discard block |
||
2949 | 3191 | if (!file_exists($pathref.'/'.$filename)) |
2950 | 3192 | { |
2951 | 3193 | $file_list['missing'][] = array('filename'=>$filename, 'expectedmd5'=>$expectedmd5); |
2952 | - } |
|
2953 | - else |
|
3194 | + } else |
|
2954 | 3195 | { |
2955 | 3196 | $md5_local = md5_file($pathref.'/'.$filename); |
2956 | 3197 | |
2957 | - if ($conffile == '/etc/dolibarr/conf.php' && $filename == '/filefunc.inc.php') // For install with deb or rpm, we ignore test on filefunc.inc.php that was modified by package |
|
3198 | + if ($conffile == '/etc/dolibarr/conf.php' && $filename == '/filefunc.inc.php') { |
|
3199 | + // For install with deb or rpm, we ignore test on filefunc.inc.php that was modified by package |
|
2958 | 3200 | { |
2959 | 3201 | $checksumconcat[] = $expectedmd5; |
2960 | 3202 | } |
2961 | - else |
|
3203 | + } else |
|
2962 | 3204 | { |
2963 | - if ($md5_local != $expectedmd5) $file_list['updated'][] = array('filename'=>$filename, 'expectedmd5'=>$expectedmd5, 'md5'=>(string) $md5_local); |
|
3205 | + if ($md5_local != $expectedmd5) { |
|
3206 | + $file_list['updated'][] = array('filename'=>$filename, 'expectedmd5'=>$expectedmd5, 'md5'=>(string) $md5_local); |
|
3207 | + } |
|
2964 | 3208 | $checksumconcat[] = $md5_local; |
2965 | 3209 | } |
2966 | 3210 | } |
2967 | 3211 | } |
2968 | 3212 | |
2969 | - foreach ($dir->dir as $subdir) // $subdir['name'] is '' or '/accountancy/admin' for example |
|
3213 | + foreach ($dir->dir as $subdir) { |
|
3214 | + // $subdir['name'] is '' or '/accountancy/admin' for example |
|
2970 | 3215 | { |
2971 | 3216 | getFilesUpdated($file_list, $subdir, $path.$subdir['name'].'/', $pathref, $checksumconcat); |
2972 | 3217 | } |
3218 | + } |
|
2973 | 3219 | |
2974 | 3220 | return $file_list; |
2975 | 3221 | } |
@@ -35,7 +35,9 @@ |
||
35 | 35 | function expedition_prepare_head(Expedition $object) |
36 | 36 | { |
37 | 37 | global $langs, $conf, $user; |
38 | - if (! empty($conf->expedition->enabled)) $langs->load("sendings"); |
|
38 | + if (! empty($conf->expedition->enabled)) { |
|
39 | + $langs->load("sendings"); |
|
40 | + } |
|
39 | 41 | $langs->load("orders"); |
40 | 42 | |
41 | 43 | $h = 0; |
@@ -48,7 +48,9 @@ discard block |
||
48 | 48 | $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
49 | 49 | $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id; |
50 | 50 | $head[$h][1] = $langs->trans('ContactsAddresses'); |
51 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
51 | + if ($nbContact > 0) { |
|
52 | + $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
53 | + } |
|
52 | 54 | $head[$h][2] = 'contact'; |
53 | 55 | $h++; |
54 | 56 | } |
@@ -62,11 +64,17 @@ discard block |
||
62 | 64 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
63 | 65 | { |
64 | 66 | $nbNote = 0; |
65 | - if(!empty($object->note_private)) $nbNote++; |
|
66 | - if(!empty($object->note_public)) $nbNote++; |
|
67 | + if(!empty($object->note_private)) { |
|
68 | + $nbNote++; |
|
69 | + } |
|
70 | + if(!empty($object->note_public)) { |
|
71 | + $nbNote++; |
|
72 | + } |
|
67 | 73 | $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id; |
68 | 74 | $head[$h][1] = $langs->trans('Notes'); |
69 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
75 | + if ($nbNote > 0) { |
|
76 | + $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
77 | + } |
|
70 | 78 | $head[$h][2] = 'note'; |
71 | 79 | $h++; |
72 | 80 | } |
@@ -78,7 +86,9 @@ discard block |
||
78 | 86 | $nbLinks=Link::count($db, $object->element, $object->id); |
79 | 87 | $head[$h][0] = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$object->id; |
80 | 88 | $head[$h][1] = $langs->trans('Documents'); |
81 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
89 | + if (($nbFiles+$nbLinks) > 0) { |
|
90 | + $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
91 | + } |
|
82 | 92 | $head[$h][2] = 'documents'; |
83 | 93 | $h++; |
84 | 94 | |
@@ -116,7 +126,9 @@ discard block |
||
116 | 126 | $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
117 | 127 | $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id; |
118 | 128 | $head[$h][1] = $langs->trans('ContactsAddresses'); |
119 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
129 | + if ($nbContact > 0) { |
|
130 | + $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
131 | + } |
|
120 | 132 | $head[$h][2] = 'contact'; |
121 | 133 | $h++; |
122 | 134 | } |
@@ -139,11 +151,17 @@ discard block |
||
139 | 151 | if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) |
140 | 152 | { |
141 | 153 | $nbNote = 0; |
142 | - if(!empty($object->note_private)) $nbNote++; |
|
143 | - if(!empty($object->note_public)) $nbNote++; |
|
154 | + if(!empty($object->note_private)) { |
|
155 | + $nbNote++; |
|
156 | + } |
|
157 | + if(!empty($object->note_public)) { |
|
158 | + $nbNote++; |
|
159 | + } |
|
144 | 160 | $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id; |
145 | 161 | $head[$h][1] = $langs->trans("Notes"); |
146 | - if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
162 | + if ($nbNote > 0) { |
|
163 | + $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>'; |
|
164 | + } |
|
147 | 165 | $head[$h][2] = 'note'; |
148 | 166 | $h++; |
149 | 167 | } |
@@ -155,7 +173,9 @@ discard block |
||
155 | 173 | $nbLinks=Link::count($db, $object->element, $object->id); |
156 | 174 | $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/document.php?id='.$object->id; |
157 | 175 | $head[$h][1] = $langs->trans('Documents'); |
158 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
176 | + if (($nbFiles+$nbLinks) > 0) { |
|
177 | + $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
178 | + } |
|
159 | 179 | $head[$h][2] = 'documents'; |
160 | 180 | $h++; |
161 | 181 |
@@ -50,8 +50,9 @@ discard block |
||
50 | 50 | { |
51 | 51 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
52 | 52 | $pdfformat=dol_getDefaultFormat($outputlangs); |
53 | + } else { |
|
54 | + $pdfformat=$conf->global->MAIN_PDF_FORMAT; |
|
53 | 55 | } |
54 | - else $pdfformat=$conf->global->MAIN_PDF_FORMAT; |
|
55 | 56 | |
56 | 57 | $sql="SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format"; |
57 | 58 | $sql.=" WHERE code = '".$pdfformat."'"; |
@@ -123,17 +124,25 @@ discard block |
||
123 | 124 | require_once TCPDF_PATH.'tcpdf.php'; |
124 | 125 | |
125 | 126 | // We need to instantiate tcpdi object (instead of tcpdf) to use merging features. But we can disable it (this will break all merge features). |
126 | - if (empty($conf->global->MAIN_DISABLE_TCPDI)) require_once TCPDI_PATH.'tcpdi.php'; |
|
127 | + if (empty($conf->global->MAIN_DISABLE_TCPDI)) { |
|
128 | + require_once TCPDI_PATH.'tcpdi.php'; |
|
129 | + } |
|
127 | 130 | |
128 | 131 | //$arrayformat=pdf_getFormat(); |
129 | 132 | //$format=array($arrayformat['width'],$arrayformat['height']); |
130 | 133 | //$metric=$arrayformat['unit']; |
131 | 134 | |
132 | 135 | $pdfa=false; // PDF-1.3 |
133 | - if (! empty($conf->global->PDF_USE_1A)) $pdfa=true; // PDF1/A |
|
136 | + if (! empty($conf->global->PDF_USE_1A)) { |
|
137 | + $pdfa=true; |
|
138 | + } |
|
139 | + // PDF1/A |
|
134 | 140 | |
135 | - if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype,$metric,$format,true,'UTF-8',false,$pdfa); |
|
136 | - else $pdf = new TCPDF($pagetype,$metric,$format,true,'UTF-8',false,$pdfa); |
|
141 | + if (class_exists('TCPDI')) { |
|
142 | + $pdf = new TCPDI($pagetype,$metric,$format,true,'UTF-8',false,$pdfa); |
|
143 | + } else { |
|
144 | + $pdf = new TCPDF($pagetype,$metric,$format,true,'UTF-8',false,$pdfa); |
|
145 | + } |
|
137 | 146 | |
138 | 147 | // Protection and encryption of pdf |
139 | 148 | if (! empty($conf->global->PDF_SECURITY_ENCRYPTION)) |
@@ -202,14 +211,18 @@ discard block |
||
202 | 211 | { |
203 | 212 | global $conf; |
204 | 213 | |
205 | - if (! empty($conf->global->MAIN_PDF_FORCE_FONT)) return $conf->global->MAIN_PDF_FORCE_FONT; |
|
214 | + if (! empty($conf->global->MAIN_PDF_FORCE_FONT)) { |
|
215 | + return $conf->global->MAIN_PDF_FORCE_FONT; |
|
216 | + } |
|
206 | 217 | |
207 | 218 | $font='Helvetica'; // By default, for FPDI, or ISO language on TCPDF |
208 | - if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower) |
|
219 | + if (class_exists('TCPDF')) { |
|
220 | + // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower) |
|
209 | 221 | { |
210 | 222 | if ($outputlangs->trans('FONTFORPDF')!='FONTFORPDF') |
211 | 223 | { |
212 | 224 | $font=$outputlangs->trans('FONTFORPDF'); |
225 | + } |
|
213 | 226 | } |
214 | 227 | } |
215 | 228 | return $font; |
@@ -224,11 +237,13 @@ discard block |
||
224 | 237 | function pdf_getPDFFontSize($outputlangs) |
225 | 238 | { |
226 | 239 | $size=10; // By default, for FPDI or ISO language on TCPDF |
227 | - if (class_exists('TCPDF')) // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower) |
|
240 | + if (class_exists('TCPDF')) { |
|
241 | + // If TCPDF on, we can use an UTF8 one like DejaVuSans if required (slower) |
|
228 | 242 | { |
229 | 243 | if ($outputlangs->trans('FONTSIZEFORPDF')!='FONTSIZEFORPDF') |
230 | 244 | { |
231 | 245 | $size = (int) $outputlangs->trans('FONTSIZEFORPDF'); |
246 | + } |
|
232 | 247 | } |
233 | 248 | } |
234 | 249 | return $size; |
@@ -252,7 +267,9 @@ discard block |
||
252 | 267 | if ($tmp['height']) |
253 | 268 | { |
254 | 269 | $width=round($height*$tmp['width']/$tmp['height']); |
255 | - if ($width > $maxwidth) $height=$height*$maxwidth/$width; |
|
270 | + if ($width > $maxwidth) { |
|
271 | + $height=$height*$maxwidth/$width; |
|
272 | + } |
|
256 | 273 | } |
257 | 274 | //print $tmp['width'].' '.$tmp['height'].' '.$width; exit; |
258 | 275 | return $height; |
@@ -283,8 +300,7 @@ discard block |
||
283 | 300 | $height = 0; |
284 | 301 | if ($end_page == $start_page) { |
285 | 302 | $height = $end_y - $start_y; |
286 | - } |
|
287 | - else |
|
303 | + } else |
|
288 | 304 | { |
289 | 305 | for ($page=$start_page; $page <= $end_page; ++$page) { |
290 | 306 | $pdf->setPage($page); |
@@ -354,15 +370,33 @@ discard block |
||
354 | 370 | { |
355 | 371 | global $conf, $hookmanager; |
356 | 372 | |
357 | - if ($mode == 'source' && ! is_object($sourcecompany)) return -1; |
|
358 | - if ($mode == 'target' && ! is_object($targetcompany)) return -1; |
|
373 | + if ($mode == 'source' && ! is_object($sourcecompany)) { |
|
374 | + return -1; |
|
375 | + } |
|
376 | + if ($mode == 'target' && ! is_object($targetcompany)) { |
|
377 | + return -1; |
|
378 | + } |
|
359 | 379 | |
360 | - if (! empty($sourcecompany->state_id) && empty($sourcecompany->departement)) $sourcecompany->departement=getState($sourcecompany->state_id); //TODO deprecated |
|
361 | - if (! empty($sourcecompany->state_id) && empty($sourcecompany->state)) $sourcecompany->state=getState($sourcecompany->state_id); |
|
362 | - if (! empty($sourcecompany->state_id) && !isset($sourcecompany->departement_id)) $sourcecompany->departement_id=getState($sourcecompany->state_id,'2'); |
|
363 | - if (! empty($targetcompany->state_id) && empty($targetcompany->departement)) $targetcompany->departement=getState($targetcompany->state_id); //TODO deprecated |
|
364 | - if (! empty($targetcompany->state_id) && empty($targetcompany->state)) $targetcompany->state=getState($targetcompany->state_id); |
|
365 | - if (! empty($targetcompany->state_id) && !isset($targetcompany->departement_id)) $targetcompany->departement_id=getState($targetcompany->state_id,'2'); |
|
380 | + if (! empty($sourcecompany->state_id) && empty($sourcecompany->departement)) { |
|
381 | + $sourcecompany->departement=getState($sourcecompany->state_id); |
|
382 | + } |
|
383 | + //TODO deprecated |
|
384 | + if (! empty($sourcecompany->state_id) && empty($sourcecompany->state)) { |
|
385 | + $sourcecompany->state=getState($sourcecompany->state_id); |
|
386 | + } |
|
387 | + if (! empty($sourcecompany->state_id) && !isset($sourcecompany->departement_id)) { |
|
388 | + $sourcecompany->departement_id=getState($sourcecompany->state_id,'2'); |
|
389 | + } |
|
390 | + if (! empty($targetcompany->state_id) && empty($targetcompany->departement)) { |
|
391 | + $targetcompany->departement=getState($targetcompany->state_id); |
|
392 | + } |
|
393 | + //TODO deprecated |
|
394 | + if (! empty($targetcompany->state_id) && empty($targetcompany->state)) { |
|
395 | + $targetcompany->state=getState($targetcompany->state_id); |
|
396 | + } |
|
397 | + if (! empty($targetcompany->state_id) && !isset($targetcompany->departement_id)) { |
|
398 | + $targetcompany->departement_id=getState($targetcompany->state_id,'2'); |
|
399 | + } |
|
366 | 400 | |
367 | 401 | $reshook=0; |
368 | 402 | $stringaddress = ''; |
@@ -378,61 +412,85 @@ discard block |
||
378 | 412 | if ($mode == 'source') |
379 | 413 | { |
380 | 414 | $withCountry = 0; |
381 | - if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) $withCountry = 1; |
|
415 | + if (!empty($sourcecompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) { |
|
416 | + $withCountry = 1; |
|
417 | + } |
|
382 | 418 | |
383 | 419 | $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($sourcecompany, $withCountry, "\n", $outputlangs))."\n"; |
384 | 420 | |
385 | 421 | if (empty($conf->global->MAIN_PDF_DISABLESOURCEDETAILS)) |
386 | 422 | { |
387 | 423 | // Phone |
388 | - if ($sourcecompany->phone) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone); |
|
424 | + if ($sourcecompany->phone) { |
|
425 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("PhoneShort").": ".$outputlangs->convToOutputCharset($sourcecompany->phone); |
|
426 | + } |
|
389 | 427 | // Fax |
390 | - if ($sourcecompany->fax) $stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($sourcecompany->fax); |
|
428 | + if ($sourcecompany->fax) { |
|
429 | + $stringaddress .= ($stringaddress ? ($sourcecompany->phone ? " - " : "\n") : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($sourcecompany->fax); |
|
430 | + } |
|
391 | 431 | |
392 | - if ($sourcecompany->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($sourcecompany->email); |
|
432 | + if ($sourcecompany->email) { |
|
433 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($sourcecompany->email); |
|
434 | + } |
|
393 | 435 | // Web |
394 | - if ($sourcecompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url); |
|
436 | + if ($sourcecompany->url) { |
|
437 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($sourcecompany->url); |
|
438 | + } |
|
395 | 439 | } |
396 | 440 | // Intra VAT |
397 | 441 | if (! empty($conf->global->MAIN_TVAINTRA_IN_SOURCE_ADDRESS)) |
398 | 442 | { |
399 | - if ($sourcecompany->tva_intra) $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($sourcecompany->tva_intra); |
|
443 | + if ($sourcecompany->tva_intra) { |
|
444 | + $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($sourcecompany->tva_intra); |
|
445 | + } |
|
400 | 446 | } |
401 | 447 | // Professionnal Ids |
402 | 448 | if (! empty($conf->global->MAIN_PROFID1_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof1)) |
403 | 449 | { |
404 | 450 | $tmp=$outputlangs->transcountrynoentities("ProfId1",$sourcecompany->country_code); |
405 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
451 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) { |
|
452 | + $tmp=$reg[1]; |
|
453 | + } |
|
406 | 454 | $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof1); |
407 | 455 | } |
408 | 456 | if (! empty($conf->global->MAIN_PROFID2_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof2)) |
409 | 457 | { |
410 | 458 | $tmp=$outputlangs->transcountrynoentities("ProfId2",$sourcecompany->country_code); |
411 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
459 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) { |
|
460 | + $tmp=$reg[1]; |
|
461 | + } |
|
412 | 462 | $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof2); |
413 | 463 | } |
414 | 464 | if (! empty($conf->global->MAIN_PROFID3_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof3)) |
415 | 465 | { |
416 | 466 | $tmp=$outputlangs->transcountrynoentities("ProfId3",$sourcecompany->country_code); |
417 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
467 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) { |
|
468 | + $tmp=$reg[1]; |
|
469 | + } |
|
418 | 470 | $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof3); |
419 | 471 | } |
420 | 472 | if (! empty($conf->global->MAIN_PROFID4_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof4)) |
421 | 473 | { |
422 | 474 | $tmp=$outputlangs->transcountrynoentities("ProfId4",$sourcecompany->country_code); |
423 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
475 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) { |
|
476 | + $tmp=$reg[1]; |
|
477 | + } |
|
424 | 478 | $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof4); |
425 | 479 | } |
426 | 480 | if (! empty($conf->global->MAIN_PROFID5_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof5)) |
427 | 481 | { |
428 | 482 | $tmp=$outputlangs->transcountrynoentities("ProfId5",$sourcecompany->country_code); |
429 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
483 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) { |
|
484 | + $tmp=$reg[1]; |
|
485 | + } |
|
430 | 486 | $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof5); |
431 | 487 | } |
432 | 488 | if (! empty($conf->global->MAIN_PROFID6_IN_SOURCE_ADDRESS) && ! empty($sourcecompany->idprof6)) |
433 | 489 | { |
434 | 490 | $tmp=$outputlangs->transcountrynoentities("ProfId6",$sourcecompany->country_code); |
435 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
491 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) { |
|
492 | + $tmp=$reg[1]; |
|
493 | + } |
|
436 | 494 | $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($sourcecompany->idprof6); |
437 | 495 | } |
438 | 496 | } |
@@ -460,8 +518,7 @@ discard block |
||
460 | 518 | // Country |
461 | 519 | if (!empty($targetcontact->country_code) && $targetcontact->country_code != $sourcecompany->country_code) { |
462 | 520 | $stringaddress.= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcontact->country_code)); |
463 | - } |
|
464 | - else if (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) { |
|
521 | + } else if (empty($targetcontact->country_code) && !empty($targetcompany->country_code) && ($targetcompany->country_code != $sourcecompany->country_code)) { |
|
465 | 522 | $stringaddress.= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); |
466 | 523 | } |
467 | 524 | |
@@ -470,58 +527,87 @@ discard block |
||
470 | 527 | // Phone |
471 | 528 | if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/',$mode)) |
472 | 529 | { |
473 | - if (! empty($targetcontact->phone_pro) || ! empty($targetcontact->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; |
|
474 | - if (! empty($targetcontact->phone_pro)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro); |
|
475 | - if (! empty($targetcontact->phone_pro) && ! empty($targetcontact->phone_mobile)) $stringaddress .= " / "; |
|
476 | - if (! empty($targetcontact->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile); |
|
530 | + if (! empty($targetcontact->phone_pro) || ! empty($targetcontact->phone_mobile)) { |
|
531 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; |
|
532 | + } |
|
533 | + if (! empty($targetcontact->phone_pro)) { |
|
534 | + $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_pro); |
|
535 | + } |
|
536 | + if (! empty($targetcontact->phone_pro) && ! empty($targetcontact->phone_mobile)) { |
|
537 | + $stringaddress .= " / "; |
|
538 | + } |
|
539 | + if (! empty($targetcontact->phone_mobile)) { |
|
540 | + $stringaddress .= $outputlangs->convToOutputCharset($targetcontact->phone_mobile); |
|
541 | + } |
|
477 | 542 | } |
478 | 543 | // Fax |
479 | 544 | if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/',$mode)) |
480 | 545 | { |
481 | - if ($targetcontact->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax); |
|
546 | + if ($targetcontact->fax) { |
|
547 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcontact->fax); |
|
548 | + } |
|
482 | 549 | } |
483 | 550 | |
484 | 551 | if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/',$mode)) |
485 | 552 | { |
486 | - if ($targetcontact->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email); |
|
553 | + if ($targetcontact->email) { |
|
554 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcontact->email); |
|
555 | + } |
|
487 | 556 | } |
488 | 557 | // Web |
489 | 558 | if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/',$mode)) |
490 | 559 | { |
491 | - if ($targetcontact->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url); |
|
560 | + if ($targetcontact->url) { |
|
561 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcontact->url); |
|
562 | + } |
|
492 | 563 | } |
493 | 564 | } |
494 | - } |
|
495 | - else |
|
565 | + } else |
|
496 | 566 | { |
497 | 567 | $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset(dol_format_address($targetcompany)); |
498 | 568 | // Country |
499 | - if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); |
|
569 | + if (!empty($targetcompany->country_code) && $targetcompany->country_code != $sourcecompany->country_code) { |
|
570 | + $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$targetcompany->country_code)); |
|
571 | + } |
|
500 | 572 | |
501 | 573 | if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || preg_match('/targetwithdetails/',$mode)) |
502 | 574 | { |
503 | 575 | // Phone |
504 | 576 | if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_phone/',$mode)) |
505 | 577 | { |
506 | - if (! empty($targetcompany->phone) || ! empty($targetcompany->phone_mobile)) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; |
|
507 | - if (! empty($targetcompany->phone)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone); |
|
508 | - if (! empty($targetcompany->phone) && ! empty($targetcompany->phone_mobile)) $stringaddress .= " / "; |
|
509 | - if (! empty($targetcompany->phone_mobile)) $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile); |
|
578 | + if (! empty($targetcompany->phone) || ! empty($targetcompany->phone_mobile)) { |
|
579 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Phone").": "; |
|
580 | + } |
|
581 | + if (! empty($targetcompany->phone)) { |
|
582 | + $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone); |
|
583 | + } |
|
584 | + if (! empty($targetcompany->phone) && ! empty($targetcompany->phone_mobile)) { |
|
585 | + $stringaddress .= " / "; |
|
586 | + } |
|
587 | + if (! empty($targetcompany->phone_mobile)) { |
|
588 | + $stringaddress .= $outputlangs->convToOutputCharset($targetcompany->phone_mobile); |
|
589 | + } |
|
510 | 590 | } |
511 | 591 | // Fax |
512 | 592 | if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_fax/',$mode)) |
513 | 593 | { |
514 | - if ($targetcompany->fax) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax); |
|
594 | + if ($targetcompany->fax) { |
|
595 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($targetcompany->fax); |
|
596 | + } |
|
515 | 597 | } |
516 | 598 | |
517 | 599 | if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_email/',$mode)) |
518 | 600 | { |
519 | - if ($targetcompany->email) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email); |
|
601 | + if ($targetcompany->email) { |
|
602 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($targetcompany->email); |
|
603 | + } |
|
520 | 604 | } |
521 | 605 | // Web |
522 | 606 | if (! empty($conf->global->MAIN_PDF_ADDALSOTARGETDETAILS) || $mode == 'targetwithdetails' || preg_match('/targetwithdetails_url/',$mode)) |
523 | 607 | { |
524 | - if ($targetcompany->url) $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url); |
|
608 | + if ($targetcompany->url) { |
|
609 | + $stringaddress .= ($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($targetcompany->url); |
|
610 | + } |
|
525 | 611 | } |
526 | 612 | } |
527 | 613 | } |
@@ -529,44 +615,58 @@ discard block |
||
529 | 615 | // Intra VAT |
530 | 616 | if (empty($conf->global->MAIN_TVAINTRA_NOT_IN_ADDRESS)) |
531 | 617 | { |
532 | - if ($targetcompany->tva_intra) $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra); |
|
618 | + if ($targetcompany->tva_intra) { |
|
619 | + $stringaddress.=($stringaddress ? "\n" : '' ).$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra); |
|
620 | + } |
|
533 | 621 | } |
534 | 622 | |
535 | 623 | // Professionnal Ids |
536 | 624 | if (! empty($conf->global->MAIN_PROFID1_IN_ADDRESS) && ! empty($targetcompany->idprof1)) |
537 | 625 | { |
538 | 626 | $tmp=$outputlangs->transcountrynoentities("ProfId1",$targetcompany->country_code); |
539 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
627 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) { |
|
628 | + $tmp=$reg[1]; |
|
629 | + } |
|
540 | 630 | $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof1); |
541 | 631 | } |
542 | 632 | if (! empty($conf->global->MAIN_PROFID2_IN_ADDRESS) && ! empty($targetcompany->idprof2)) |
543 | 633 | { |
544 | 634 | $tmp=$outputlangs->transcountrynoentities("ProfId2",$targetcompany->country_code); |
545 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
635 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) { |
|
636 | + $tmp=$reg[1]; |
|
637 | + } |
|
546 | 638 | $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof2); |
547 | 639 | } |
548 | 640 | if (! empty($conf->global->MAIN_PROFID3_IN_ADDRESS) && ! empty($targetcompany->idprof3)) |
549 | 641 | { |
550 | 642 | $tmp=$outputlangs->transcountrynoentities("ProfId3",$targetcompany->country_code); |
551 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
643 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) { |
|
644 | + $tmp=$reg[1]; |
|
645 | + } |
|
552 | 646 | $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof3); |
553 | 647 | } |
554 | 648 | if (! empty($conf->global->MAIN_PROFID4_IN_ADDRESS) && ! empty($targetcompany->idprof4)) |
555 | 649 | { |
556 | 650 | $tmp=$outputlangs->transcountrynoentities("ProfId4",$targetcompany->country_code); |
557 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
651 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) { |
|
652 | + $tmp=$reg[1]; |
|
653 | + } |
|
558 | 654 | $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof4); |
559 | 655 | } |
560 | 656 | if (! empty($conf->global->MAIN_PROFID5_IN_ADDRESS) && ! empty($targetcompany->idprof5)) |
561 | 657 | { |
562 | 658 | $tmp=$outputlangs->transcountrynoentities("ProfId5",$targetcompany->country_code); |
563 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
659 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) { |
|
660 | + $tmp=$reg[1]; |
|
661 | + } |
|
564 | 662 | $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof5); |
565 | 663 | } |
566 | 664 | if (! empty($conf->global->MAIN_PROFID6_IN_ADDRESS) && ! empty($targetcompany->idprof6)) |
567 | 665 | { |
568 | 666 | $tmp=$outputlangs->transcountrynoentities("ProfId6",$targetcompany->country_code); |
569 | - if (preg_match('/\((.+)\)/',$tmp,$reg)) $tmp=$reg[1]; |
|
667 | + if (preg_match('/\((.+)\)/',$tmp,$reg)) { |
|
668 | + $tmp=$reg[1]; |
|
669 | + } |
|
570 | 670 | $stringaddress.=($stringaddress ? "\n" : '' ).$tmp.': '.$outputlangs->convToOutputCharset($targetcompany->idprof6); |
571 | 671 | } |
572 | 672 | |
@@ -602,9 +702,12 @@ discard block |
||
602 | 702 | global $conf; |
603 | 703 | |
604 | 704 | // Add a background image on document |
605 | - if (! empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) // Warning, this option make TCPDF generation being crazy and some content disappeared behind the image |
|
705 | + if (! empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF)) { |
|
706 | + // Warning, this option make TCPDF generation being crazy and some content disappeared behind the image |
|
606 | 707 | { |
607 | - $pdf->SetAutoPageBreak(0,0); // Disable auto pagebreak before adding image |
|
708 | + $pdf->SetAutoPageBreak(0,0); |
|
709 | + } |
|
710 | + // Disable auto pagebreak before adding image |
|
608 | 711 | $pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_X:0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y)?$conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y:0), 0, $page_height); |
609 | 712 | $pdf->SetAutoPageBreak(1,0); // Restore pagebreak |
610 | 713 | } |
@@ -645,10 +748,15 @@ discard block |
||
645 | 748 | global $langs, $mysoc, $user; |
646 | 749 | |
647 | 750 | // Print Draft Watermark |
648 | - if ($unit=='pt') $k=1; |
|
649 | - elseif ($unit=='mm') $k=72/25.4; |
|
650 | - elseif ($unit=='cm') $k=72/2.54; |
|
651 | - elseif ($unit=='in') $k=72; |
|
751 | + if ($unit=='pt') { |
|
752 | + $k=1; |
|
753 | + } elseif ($unit=='mm') { |
|
754 | + $k=72/25.4; |
|
755 | + } elseif ($unit=='cm') { |
|
756 | + $k=72/2.54; |
|
757 | + } elseif ($unit=='in') { |
|
758 | + $k=72; |
|
759 | + } |
|
652 | 760 | |
653 | 761 | // Make substitution |
654 | 762 | $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, null); |
@@ -710,7 +818,9 @@ discard block |
||
710 | 818 | |
711 | 819 | // Use correct name of bank id according to country |
712 | 820 | $bickey="BICNumber"; |
713 | - if ($account->getCountryCode() == 'IN') $bickey="SWIFT"; |
|
821 | + if ($account->getCountryCode() == 'IN') { |
|
822 | + $bickey="SWIFT"; |
|
823 | + } |
|
714 | 824 | |
715 | 825 | // Get format of bank account according to its country |
716 | 826 | $usedetailedbban=$account->useDetailedBBAN(); |
@@ -728,7 +838,8 @@ discard block |
||
728 | 838 | $cury+=3; |
729 | 839 | } |
730 | 840 | |
731 | - if (empty($conf->global->PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN)) // Note that some countries still need bank number, BIC/IBAN not enougth for them |
|
841 | + if (empty($conf->global->PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN)) { |
|
842 | + // Note that some countries still need bank number, BIC/IBAN not enougth for them |
|
732 | 843 | { |
733 | 844 | // Note: |
734 | 845 | // bank = code_banque (FR), sort code (GB, IR. Example: 12-34-56) |
@@ -736,6 +847,7 @@ discard block |
||
736 | 847 | // number = account number |
737 | 848 | // key = check control key used only when $usedetailedbban = 1 |
738 | 849 | if (empty($onlynumber)) $pdf->line($curx+1, $cury+1, $curx+1, $cury+6); |
850 | + } |
|
739 | 851 | |
740 | 852 | |
741 | 853 | foreach ($account->getFieldsToShow() as $val) |
@@ -759,7 +871,7 @@ discard block |
||
759 | 871 | // Key |
760 | 872 | $tmplength = 15; |
761 | 873 | $content = $account->cle_rib; |
762 | - }elseif ($val == 'IBAN' || $val == 'BIC') { |
|
874 | + } elseif ($val == 'IBAN' || $val == 'BIC') { |
|
763 | 875 | // Key |
764 | 876 | $tmplength = 0; |
765 | 877 | $content = ''; |
@@ -781,8 +893,7 @@ discard block |
||
781 | 893 | $curx=$savcurx; |
782 | 894 | $cury+=8; |
783 | 895 | } |
784 | - } |
|
785 | - else |
|
896 | + } else |
|
786 | 897 | { |
787 | 898 | $pdf->SetFont('','B',$default_font_size - $diffsizecontent); |
788 | 899 | $pdf->SetXY($curx, $cury); |
@@ -794,7 +905,9 @@ discard block |
||
794 | 905 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': ' . $outputlangs->convToOutputCharset($account->number), 0, 'L', 0); |
795 | 906 | $cury+=3; |
796 | 907 | |
797 | - if ($diffsizecontent <= 2) $cury+=1; |
|
908 | + if ($diffsizecontent <= 2) { |
|
909 | + $cury+=1; |
|
910 | + } |
|
798 | 911 | } |
799 | 912 | |
800 | 913 | $pdf->SetFont('','',$default_font_size - $diffsizecontent); |
@@ -818,10 +931,10 @@ discard block |
||
818 | 931 | $tmpy=$pdf->getStringHeight(100, $val); |
819 | 932 | $cury+=$tmpy; |
820 | 933 | $cur+=1; |
934 | + } else if (! $usedetailedbban) { |
|
935 | + $cury+=1; |
|
821 | 936 | } |
822 | 937 | |
823 | - else if (! $usedetailedbban) $cury+=1; |
|
824 | - |
|
825 | 938 | // Use correct name of bank id according to country |
826 | 939 | $ibankey = FormBank::getIBANLabel($account); |
827 | 940 | |
@@ -835,7 +948,9 @@ discard block |
||
835 | 948 | for ($i = 0; $i < $nbIbanDisplay_temp; $i++) |
836 | 949 | { |
837 | 950 | $ibanDisplay .= $ibanDisplay_temp[$i]; |
838 | - if($i%4 == 3 && $i > 0) $ibanDisplay .= " "; |
|
951 | + if($i%4 == 3 && $i > 0) { |
|
952 | + $ibanDisplay .= " "; |
|
953 | + } |
|
839 | 954 | } |
840 | 955 | |
841 | 956 | $pdf->SetFont('','B',$default_font_size - 3); |
@@ -963,21 +1078,28 @@ discard block |
||
963 | 1078 | if ($fromcompany->capital) |
964 | 1079 | { |
965 | 1080 | $tmpamounttoshow = price2num($fromcompany->capital); // This field is a free string |
966 | - if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf",price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency)); |
|
967 | - else $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf",$tmpamounttoshow,$outputlangs); |
|
1081 | + if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) { |
|
1082 | + $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf",price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency)); |
|
1083 | + } else { |
|
1084 | + $line3.=($line3?" - ":"").$outputlangs->transnoentities("CapitalOf",$tmpamounttoshow,$outputlangs); |
|
1085 | + } |
|
968 | 1086 | } |
969 | 1087 | // Prof Id 1 |
970 | 1088 | if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || ! $fromcompany->idprof2)) |
971 | 1089 | { |
972 | 1090 | $field=$outputlangs->transcountrynoentities("ProfId1",$fromcompany->country_code); |
973 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
1091 | + if (preg_match('/\((.*)\)/i',$field,$reg)) { |
|
1092 | + $field=$reg[1]; |
|
1093 | + } |
|
974 | 1094 | $line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof1); |
975 | 1095 | } |
976 | 1096 | // Prof Id 2 |
977 | 1097 | if ($fromcompany->idprof2) |
978 | 1098 | { |
979 | 1099 | $field=$outputlangs->transcountrynoentities("ProfId2",$fromcompany->country_code); |
980 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
1100 | + if (preg_match('/\((.*)\)/i',$field,$reg)) { |
|
1101 | + $field=$reg[1]; |
|
1102 | + } |
|
981 | 1103 | $line3.=($line3?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof2); |
982 | 1104 | } |
983 | 1105 | |
@@ -986,28 +1108,36 @@ discard block |
||
986 | 1108 | if ($fromcompany->idprof3) |
987 | 1109 | { |
988 | 1110 | $field=$outputlangs->transcountrynoentities("ProfId3",$fromcompany->country_code); |
989 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
1111 | + if (preg_match('/\((.*)\)/i',$field,$reg)) { |
|
1112 | + $field=$reg[1]; |
|
1113 | + } |
|
990 | 1114 | $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof3); |
991 | 1115 | } |
992 | 1116 | // Prof Id 4 |
993 | 1117 | if ($fromcompany->idprof4) |
994 | 1118 | { |
995 | 1119 | $field=$outputlangs->transcountrynoentities("ProfId4",$fromcompany->country_code); |
996 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
1120 | + if (preg_match('/\((.*)\)/i',$field,$reg)) { |
|
1121 | + $field=$reg[1]; |
|
1122 | + } |
|
997 | 1123 | $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof4); |
998 | 1124 | } |
999 | 1125 | // Prof Id 5 |
1000 | 1126 | if ($fromcompany->idprof5) |
1001 | 1127 | { |
1002 | 1128 | $field=$outputlangs->transcountrynoentities("ProfId5",$fromcompany->country_code); |
1003 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
1129 | + if (preg_match('/\((.*)\)/i',$field,$reg)) { |
|
1130 | + $field=$reg[1]; |
|
1131 | + } |
|
1004 | 1132 | $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof5); |
1005 | 1133 | } |
1006 | 1134 | // Prof Id 6 |
1007 | 1135 | if ($fromcompany->idprof6) |
1008 | 1136 | { |
1009 | 1137 | $field=$outputlangs->transcountrynoentities("ProfId6",$fromcompany->country_code); |
1010 | - if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1]; |
|
1138 | + if (preg_match('/\((.*)\)/i',$field,$reg)) { |
|
1139 | + $field=$reg[1]; |
|
1140 | + } |
|
1011 | 1141 | $line4.=($line4?" - ":"").$field.": ".$outputlangs->convToOutputCharset($fromcompany->idprof6); |
1012 | 1142 | } |
1013 | 1143 | // IntraCommunautary VAT |
@@ -1021,18 +1151,20 @@ discard block |
||
1021 | 1151 | |
1022 | 1152 | // The start of the bottom of this page footer is positioned according to # of lines |
1023 | 1153 | $freetextheight=0; |
1024 | - if ($line) // Free text |
|
1154 | + if ($line) { |
|
1155 | + // Free text |
|
1025 | 1156 | { |
1026 | 1157 | //$line="sample text<br>\nfd<strong>sf</strong>sdf<br>\nghfghg<br>"; |
1027 | 1158 | if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) |
1028 | 1159 | { |
1029 | - $width=20000; $align='L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text. |
|
1160 | + $width=20000; |
|
1161 | + } |
|
1162 | + $align='L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text. |
|
1030 | 1163 | if (! empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) { |
1031 | 1164 | $width=200; $align='C'; |
1032 | 1165 | } |
1033 | 1166 | $freetextheight=$pdf->getStringHeight($width,$line); |
1034 | - } |
|
1035 | - else |
|
1167 | + } else |
|
1036 | 1168 | { |
1037 | 1169 | $freetextheight=pdfGetHeightForHtmlContent($pdf,dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); // New method (works for HTML content) |
1038 | 1170 | //print '<br>'.$freetextheight;exit; |
@@ -1042,14 +1174,17 @@ discard block |
||
1042 | 1174 | $marginwithfooter=$marge_basse + $freetextheight + (! empty($line1)?3:0) + (! empty($line2)?3:0) + (! empty($line3)?3:0) + (! empty($line4)?3:0); |
1043 | 1175 | $posy=$marginwithfooter+0; |
1044 | 1176 | |
1045 | - if ($line) // Free text |
|
1177 | + if ($line) { |
|
1178 | + // Free text |
|
1046 | 1179 | { |
1047 | 1180 | $pdf->SetXY($dims['lm'],-$posy); |
1048 | - if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) // by default |
|
1181 | + } |
|
1182 | + if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { |
|
1183 | + // by default |
|
1049 | 1184 | { |
1050 | 1185 | $pdf->MultiCell(0, 3, $line, 0, $align, 0); |
1051 | 1186 | } |
1052 | - else |
|
1187 | + } else |
|
1053 | 1188 | { |
1054 | 1189 | $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims['lm'], $dims['hk']-$marginwithfooter, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); |
1055 | 1190 | } |
@@ -1162,15 +1297,21 @@ discard block |
||
1162 | 1297 | $reshook=0; |
1163 | 1298 | $result=''; |
1164 | 1299 | //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1165 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1300 | + if (is_object($hookmanager)) { |
|
1301 | + // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1166 | 1302 | { |
1167 | 1303 | $special_code = $object->lines[$i]->special_code; |
1168 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1304 | + } |
|
1305 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1306 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1307 | + } |
|
1169 | 1308 | $parameters = array('pdf'=>$pdf,'i'=>$i,'outputlangs'=>$outputlangs,'w'=>$w,'h'=>$h,'posx'=>$posx,'posy'=>$posy,'hideref'=>$hideref,'hidedesc'=>$hidedesc,'issupplierline'=>$issupplierline,'special_code'=>$special_code); |
1170 | 1309 | $action=''; |
1171 | 1310 | $reshook=$hookmanager->executeHooks('pdf_writelinedesc',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
1172 | 1311 | |
1173 | - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1312 | + if (!empty($hookmanager->resPrint)) { |
|
1313 | + $result.=$hookmanager->resPrint; |
|
1314 | + } |
|
1174 | 1315 | } |
1175 | 1316 | if (empty($reshook)) |
1176 | 1317 | { |
@@ -1208,8 +1349,7 @@ discard block |
||
1208 | 1349 | { |
1209 | 1350 | include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; |
1210 | 1351 | $prodser = new ProductFournisseur($db); |
1211 | - } |
|
1212 | - else |
|
1352 | + } else |
|
1213 | 1353 | { |
1214 | 1354 | include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
1215 | 1355 | $prodser = new Product($db); |
@@ -1230,7 +1370,9 @@ discard block |
||
1230 | 1370 | // If we want another language, and if label is same than default language (we did force it to a specific value), we can use translation. |
1231 | 1371 | //var_dump($outputlangs->defaultlang.' - '.$langs->defaultlang.' - '.$label.' - '.$prodser->label);exit; |
1232 | 1372 | $textwasmodified=($label == $prodser->label); |
1233 | - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified)) $label=$prodser->multilangs[$outputlangs->defaultlang]["label"]; |
|
1373 | + if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified)) { |
|
1374 | + $label=$prodser->multilangs[$outputlangs->defaultlang]["label"]; |
|
1375 | + } |
|
1234 | 1376 | |
1235 | 1377 | // Set desc |
1236 | 1378 | // Manage HTML entities description test because $prodser->description is store with htmlentities but $desc no |
@@ -1240,11 +1382,15 @@ discard block |
||
1240 | 1382 | } else { |
1241 | 1383 | $textwasmodified=($desc == $prodser->description); |
1242 | 1384 | } |
1243 | - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; |
|
1385 | + if (! empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) { |
|
1386 | + $desc=$prodser->multilangs[$outputlangs->defaultlang]["description"]; |
|
1387 | + } |
|
1244 | 1388 | |
1245 | 1389 | // Set note |
1246 | 1390 | $textwasmodified=($note == $prodser->note); |
1247 | - if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; |
|
1391 | + if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) { |
|
1392 | + $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; |
|
1393 | + } |
|
1248 | 1394 | } |
1249 | 1395 | } |
1250 | 1396 | |
@@ -1265,29 +1411,28 @@ discard block |
||
1265 | 1411 | $discount->fetch($object->lines[$i]->fk_remise_except); |
1266 | 1412 | $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; |
1267 | 1413 | $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote",$sourceref); |
1268 | - } |
|
1269 | - elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except) |
|
1414 | + } elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except) |
|
1270 | 1415 | { |
1271 | 1416 | $discount=new DiscountAbsolute($db); |
1272 | 1417 | $discount->fetch($object->lines[$i]->fk_remise_except); |
1273 | 1418 | $sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source; |
1274 | 1419 | $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit",$sourceref); |
1275 | 1420 | // Add date of deposit |
1276 | - if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec,'day','',$outputlangs).')'; |
|
1421 | + if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) { |
|
1422 | + echo ' ('.dol_print_date($discount->datec,'day','',$outputlangs).')'; |
|
1423 | + } |
|
1277 | 1424 | } |
1278 | 1425 | if ($desc == '(EXCESS RECEIVED)' && $object->lines[$i]->fk_remise_except) |
1279 | 1426 | { |
1280 | 1427 | $discount=new DiscountAbsolute($db); |
1281 | 1428 | $discount->fetch($object->lines[$i]->fk_remise_except); |
1282 | 1429 | $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived",$discount->ref_facture_source); |
1283 | - } |
|
1284 | - elseif ($desc == '(EXCESS PAID)' && $object->lines[$i]->fk_remise_except) |
|
1430 | + } elseif ($desc == '(EXCESS PAID)' && $object->lines[$i]->fk_remise_except) |
|
1285 | 1431 | { |
1286 | 1432 | $discount=new DiscountAbsolute($db); |
1287 | 1433 | $discount->fetch($object->lines[$i]->fk_remise_except); |
1288 | 1434 | $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid",$discount->ref_invoice_supplier_source); |
1289 | - } |
|
1290 | - else |
|
1435 | + } else |
|
1291 | 1436 | { |
1292 | 1437 | if ($idprod) |
1293 | 1438 | { |
@@ -1296,14 +1441,12 @@ discard block |
||
1296 | 1441 | if (!empty($conf->global->MAIN_DOCUMENTS_DESCRIPTION_FIRST)) |
1297 | 1442 | { |
1298 | 1443 | $libelleproduitservice=$desc."\n".$libelleproduitservice; |
1299 | - } |
|
1300 | - else |
|
1444 | + } else |
|
1301 | 1445 | { |
1302 | 1446 | $libelleproduitservice.=$desc; |
1303 | 1447 | } |
1304 | 1448 | } |
1305 | - } |
|
1306 | - else |
|
1449 | + } else |
|
1307 | 1450 | { |
1308 | 1451 | $libelleproduitservice.=$desc; |
1309 | 1452 | } |
@@ -1313,13 +1456,14 @@ discard block |
||
1313 | 1456 | // We add ref of product (and supplier ref if defined) |
1314 | 1457 | $prefix_prodserv = ""; |
1315 | 1458 | $ref_prodserv = ""; |
1316 | - if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this |
|
1459 | + if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) { |
|
1460 | + // In standard mode, we do not show this |
|
1317 | 1461 | { |
1318 | 1462 | if ($prodser->isService()) |
1319 | 1463 | { |
1320 | 1464 | $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." "; |
1321 | - } |
|
1322 | - else |
|
1465 | + } |
|
1466 | + } else |
|
1323 | 1467 | { |
1324 | 1468 | $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product")." "; |
1325 | 1469 | } |
@@ -1329,22 +1473,25 @@ discard block |
||
1329 | 1473 | { |
1330 | 1474 | if ($issupplierline) |
1331 | 1475 | { |
1332 | - if ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) |
|
1333 | - $ref_prodserv = $ref_supplier; |
|
1334 | - elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) |
|
1335 | - $ref_prodserv = $ref_supplier. ' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')'; |
|
1336 | - else // Common case |
|
1476 | + if ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 1) { |
|
1477 | + $ref_prodserv = $ref_supplier; |
|
1478 | + } elseif ($conf->global->PDF_HIDE_PRODUCT_REF_IN_SUPPLIER_LINES == 2) { |
|
1479 | + $ref_prodserv = $ref_supplier. ' ('.$outputlangs->transnoentitiesnoconv("InternalRef").' '.$prodser->ref.')'; |
|
1480 | + } else // Common case |
|
1337 | 1481 | { |
1338 | 1482 | $ref_prodserv = $prodser->ref; // Show local ref |
1339 | - if ($ref_supplier) $ref_prodserv.= ($prodser->ref?' (':'').$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.($prodser->ref?')':''); |
|
1483 | + if ($ref_supplier) { |
|
1484 | + $ref_prodserv.= ($prodser->ref?' (':'').$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.($prodser->ref?')':''); |
|
1485 | + } |
|
1340 | 1486 | } |
1341 | - } |
|
1342 | - else |
|
1487 | + } else |
|
1343 | 1488 | { |
1344 | 1489 | $ref_prodserv = $prodser->ref; // Show local ref only |
1345 | 1490 | } |
1346 | 1491 | |
1347 | - if (! empty($libelleproduitservice) && ! empty($ref_prodserv)) $ref_prodserv .= " - "; |
|
1492 | + if (! empty($libelleproduitservice) && ! empty($ref_prodserv)) { |
|
1493 | + $ref_prodserv .= " - "; |
|
1494 | + } |
|
1348 | 1495 | } |
1349 | 1496 | |
1350 | 1497 | if(!empty($ref_prodserv) && !empty($conf->global->ADD_HTML_FORMATING_INTO_DESC_DOC)){ $ref_prodserv = '<b>'.$ref_prodserv.'</b>'; } |
@@ -1361,8 +1508,9 @@ discard block |
||
1361 | 1508 | { |
1362 | 1509 | // Adding the descriptions if they are filled |
1363 | 1510 | $desccateg=$cate->add_description; |
1364 | - if ($desccateg) |
|
1365 | - $libelleproduitservice.='__N__'.$desccateg; |
|
1511 | + if ($desccateg) { |
|
1512 | + $libelleproduitservice.='__N__'.$desccateg; |
|
1513 | + } |
|
1366 | 1514 | } |
1367 | 1515 | } |
1368 | 1516 | |
@@ -1385,7 +1533,7 @@ discard block |
||
1385 | 1533 | //print '>'.$outputlangs->charset_output.','.$period; |
1386 | 1534 | if(!empty($conf->global->ADD_HTML_FORMATING_INTO_DESC_DOC)){ |
1387 | 1535 | $libelleproduitservice.= '<b style="color:#333666;" ><em>'."__N__</b> ".$period.'</em>'; |
1388 | - }else{ |
|
1536 | + } else{ |
|
1389 | 1537 | $libelleproduitservice.="__N__".$period; |
1390 | 1538 | } |
1391 | 1539 | //print $libelleproduitservice; |
@@ -1397,17 +1545,26 @@ discard block |
||
1397 | 1545 | foreach ($dbatch as $detail) |
1398 | 1546 | { |
1399 | 1547 | $dte=array(); |
1400 | - if ($detail->eatby) $dte[]=$outputlangs->transnoentitiesnoconv('printEatby',dol_print_date($detail->eatby, $format, false, $outputlangs)); |
|
1401 | - if ($detail->sellby) $dte[]=$outputlangs->transnoentitiesnoconv('printSellby',dol_print_date($detail->sellby, $format, false, $outputlangs)); |
|
1402 | - if ($detail->batch) $dte[]=$outputlangs->transnoentitiesnoconv('printBatch',$detail->batch); |
|
1548 | + if ($detail->eatby) { |
|
1549 | + $dte[]=$outputlangs->transnoentitiesnoconv('printEatby',dol_print_date($detail->eatby, $format, false, $outputlangs)); |
|
1550 | + } |
|
1551 | + if ($detail->sellby) { |
|
1552 | + $dte[]=$outputlangs->transnoentitiesnoconv('printSellby',dol_print_date($detail->sellby, $format, false, $outputlangs)); |
|
1553 | + } |
|
1554 | + if ($detail->batch) { |
|
1555 | + $dte[]=$outputlangs->transnoentitiesnoconv('printBatch',$detail->batch); |
|
1556 | + } |
|
1403 | 1557 | $dte[]=$outputlangs->transnoentitiesnoconv('printQty',$detail->qty); |
1404 | 1558 | $libelleproduitservice.= "__N__ ".implode(" - ", $dte); |
1405 | 1559 | } |
1406 | 1560 | } |
1407 | 1561 | |
1408 | 1562 | // Now we convert \n into br |
1409 | - if (dol_textishtml($libelleproduitservice)) $libelleproduitservice=preg_replace('/__N__/','<br>',$libelleproduitservice); |
|
1410 | - else $libelleproduitservice=preg_replace('/__N__/',"\n",$libelleproduitservice); |
|
1563 | + if (dol_textishtml($libelleproduitservice)) { |
|
1564 | + $libelleproduitservice=preg_replace('/__N__/','<br>',$libelleproduitservice); |
|
1565 | + } else { |
|
1566 | + $libelleproduitservice=preg_replace('/__N__/',"\n",$libelleproduitservice); |
|
1567 | + } |
|
1411 | 1568 | $libelleproduitservice=dol_htmlentitiesbr($libelleproduitservice,1); |
1412 | 1569 | |
1413 | 1570 | return $libelleproduitservice; |
@@ -1429,10 +1586,14 @@ discard block |
||
1429 | 1586 | $reshook=0; |
1430 | 1587 | $result=''; |
1431 | 1588 | //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1432 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1589 | + if (is_object($hookmanager)) { |
|
1590 | + // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1433 | 1591 | { |
1434 | 1592 | $special_code = $object->lines[$i]->special_code; |
1435 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1593 | + } |
|
1594 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1595 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1596 | + } |
|
1436 | 1597 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
1437 | 1598 | $action=''; |
1438 | 1599 | $reshook = $hookmanager->executeHooks('pdf_getlinenum',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
@@ -1462,10 +1623,14 @@ discard block |
||
1462 | 1623 | $reshook=0; |
1463 | 1624 | $result=''; |
1464 | 1625 | //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1465 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1626 | + if (is_object($hookmanager)) { |
|
1627 | + // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1466 | 1628 | { |
1467 | 1629 | $special_code = $object->lines[$i]->special_code; |
1468 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1630 | + } |
|
1631 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1632 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1633 | + } |
|
1469 | 1634 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
1470 | 1635 | $action=''; |
1471 | 1636 | $reshook = $hookmanager->executeHooks('pdf_getlineref',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
@@ -1494,10 +1659,14 @@ discard block |
||
1494 | 1659 | $reshook=0; |
1495 | 1660 | $result=''; |
1496 | 1661 | //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1497 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1662 | + if (is_object($hookmanager)) { |
|
1663 | + // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1498 | 1664 | { |
1499 | 1665 | $special_code = $object->lines[$i]->special_code; |
1500 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1666 | + } |
|
1667 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1668 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1669 | + } |
|
1501 | 1670 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
1502 | 1671 | $action=''; |
1503 | 1672 | $reshook = $hookmanager->executeHooks('pdf_getlineref_supplier',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
@@ -1526,15 +1695,21 @@ discard block |
||
1526 | 1695 | $result=''; |
1527 | 1696 | $reshook=0; |
1528 | 1697 | //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1529 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run |
|
1698 | + if (is_object($hookmanager)) { |
|
1699 | + // Old code is commented on preceding line. Reproduce this test in the pdf_xxx function if you don't want your hook to run |
|
1530 | 1700 | { |
1531 | 1701 | $special_code = $object->lines[$i]->special_code; |
1532 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1702 | + } |
|
1703 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1704 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1705 | + } |
|
1533 | 1706 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
1534 | 1707 | $action=''; |
1535 | 1708 | $reshook = $hookmanager->executeHooks('pdf_getlinevatrate',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
1536 | 1709 | |
1537 | - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1710 | + if (!empty($hookmanager->resPrint)) { |
|
1711 | + $result.=$hookmanager->resPrint; |
|
1712 | + } |
|
1538 | 1713 | } |
1539 | 1714 | if (empty($reshook)) |
1540 | 1715 | { |
@@ -1547,8 +1722,11 @@ discard block |
||
1547 | 1722 | { |
1548 | 1723 | if ($object->lines[$i]->total_localtax1 != 0) |
1549 | 1724 | { |
1550 | - if (preg_replace('/[\s0%]/','',$tmpresult)) $tmpresult.='/'; |
|
1551 | - else $tmpresult=''; |
|
1725 | + if (preg_replace('/[\s0%]/','',$tmpresult)) { |
|
1726 | + $tmpresult.='/'; |
|
1727 | + } else { |
|
1728 | + $tmpresult=''; |
|
1729 | + } |
|
1552 | 1730 | $tmpresult.=vatrate(abs($object->lines[$i]->localtax1_tx), 0); |
1553 | 1731 | } |
1554 | 1732 | } |
@@ -1556,8 +1734,11 @@ discard block |
||
1556 | 1734 | { |
1557 | 1735 | if ($object->lines[$i]->total_localtax2 != 0) |
1558 | 1736 | { |
1559 | - if (preg_replace('/[\s0%]/','',$tmpresult)) $tmpresult.='/'; |
|
1560 | - else $tmpresult=''; |
|
1737 | + if (preg_replace('/[\s0%]/','',$tmpresult)) { |
|
1738 | + $tmpresult.='/'; |
|
1739 | + } else { |
|
1740 | + $tmpresult=''; |
|
1741 | + } |
|
1561 | 1742 | $tmpresult.=vatrate(abs($object->lines[$i]->localtax2_tx), 0); |
1562 | 1743 | } |
1563 | 1744 | } |
@@ -1583,20 +1764,28 @@ discard block |
||
1583 | 1764 | global $conf, $hookmanager; |
1584 | 1765 | |
1585 | 1766 | $sign=1; |
1586 | - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
1767 | + if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) { |
|
1768 | + $sign=-1; |
|
1769 | + } |
|
1587 | 1770 | |
1588 | 1771 | $result=''; |
1589 | 1772 | $reshook=0; |
1590 | 1773 | //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1591 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1774 | + if (is_object($hookmanager)) { |
|
1775 | + // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1592 | 1776 | { |
1593 | 1777 | $special_code = $object->lines[$i]->special_code; |
1594 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1778 | + } |
|
1779 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1780 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1781 | + } |
|
1595 | 1782 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
1596 | 1783 | $action=''; |
1597 | 1784 | $reshook = $hookmanager->executeHooks('pdf_getlineupexcltax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
1598 | 1785 | |
1599 | - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1786 | + if (!empty($hookmanager->resPrint)) { |
|
1787 | + $result.=$hookmanager->resPrint; |
|
1788 | + } |
|
1600 | 1789 | } |
1601 | 1790 | if (empty($reshook)) |
1602 | 1791 | { |
@@ -1623,24 +1812,34 @@ discard block |
||
1623 | 1812 | global $hookmanager,$conf; |
1624 | 1813 | |
1625 | 1814 | $sign=1; |
1626 | - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
1815 | + if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) { |
|
1816 | + $sign=-1; |
|
1817 | + } |
|
1627 | 1818 | |
1628 | 1819 | $result=''; |
1629 | 1820 | $reshook=0; |
1630 | 1821 | //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1631 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1822 | + if (is_object($hookmanager)) { |
|
1823 | + // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1632 | 1824 | { |
1633 | 1825 | $special_code = $object->lines[$i]->special_code; |
1634 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1826 | + } |
|
1827 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1828 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1829 | + } |
|
1635 | 1830 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
1636 | 1831 | $action=''; |
1637 | 1832 | $reshook = $hookmanager->executeHooks('pdf_getlineupwithtax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
1638 | 1833 | |
1639 | - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1834 | + if (!empty($hookmanager->resPrint)) { |
|
1835 | + $result.=$hookmanager->resPrint; |
|
1836 | + } |
|
1640 | 1837 | } |
1641 | 1838 | if (empty($reshook)) |
1642 | 1839 | { |
1643 | - if (empty($hidedetails) || $hidedetails > 1) $result.=price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice)*($object->lines[$i]->tva_tx)/100), 0, $outputlangs); |
|
1840 | + if (empty($hidedetails) || $hidedetails > 1) { |
|
1841 | + $result.=price($sign * (($object->lines[$i]->subprice) + ($object->lines[$i]->subprice)*($object->lines[$i]->tva_tx)/100), 0, $outputlangs); |
|
1842 | + } |
|
1644 | 1843 | } |
1645 | 1844 | return $result; |
1646 | 1845 | } |
@@ -1661,20 +1860,30 @@ discard block |
||
1661 | 1860 | $result=''; |
1662 | 1861 | $reshook=0; |
1663 | 1862 | //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1664 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1863 | + if (is_object($hookmanager)) { |
|
1864 | + // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1665 | 1865 | { |
1666 | 1866 | $special_code = $object->lines[$i]->special_code; |
1667 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1867 | + } |
|
1868 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1869 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1870 | + } |
|
1668 | 1871 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
1669 | 1872 | $action=''; |
1670 | 1873 | $reshook = $hookmanager->executeHooks('pdf_getlineqty',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
1671 | 1874 | |
1672 | - if(!empty($hookmanager->resPrint)) $result=$hookmanager->resPrint; |
|
1875 | + if(!empty($hookmanager->resPrint)) { |
|
1876 | + $result=$hookmanager->resPrint; |
|
1877 | + } |
|
1673 | 1878 | } |
1674 | 1879 | if (empty($reshook)) |
1675 | 1880 | { |
1676 | - if ($object->lines[$i]->special_code == 3) return ''; |
|
1677 | - if (empty($hidedetails) || $hidedetails > 1) $result.=$object->lines[$i]->qty; |
|
1881 | + if ($object->lines[$i]->special_code == 3) { |
|
1882 | + return ''; |
|
1883 | + } |
|
1884 | + if (empty($hidedetails) || $hidedetails > 1) { |
|
1885 | + $result.=$object->lines[$i]->qty; |
|
1886 | + } |
|
1678 | 1887 | } |
1679 | 1888 | return $result; |
1680 | 1889 | } |
@@ -1695,20 +1904,30 @@ discard block |
||
1695 | 1904 | $reshook=0; |
1696 | 1905 | $result=''; |
1697 | 1906 | //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1698 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1907 | + if (is_object($hookmanager)) { |
|
1908 | + // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1699 | 1909 | { |
1700 | 1910 | $special_code = $object->lines[$i]->special_code; |
1701 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1911 | + } |
|
1912 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1913 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1914 | + } |
|
1702 | 1915 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
1703 | 1916 | $action=''; |
1704 | 1917 | $reshook = $hookmanager->executeHooks('pdf_getlineqty_asked',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
1705 | 1918 | |
1706 | - if (!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1919 | + if (!empty($hookmanager->resPrint)) { |
|
1920 | + $result.=$hookmanager->resPrint; |
|
1921 | + } |
|
1707 | 1922 | } |
1708 | 1923 | if (empty($reshook)) |
1709 | 1924 | { |
1710 | - if ($object->lines[$i]->special_code == 3) return ''; |
|
1711 | - if (empty($hidedetails) || $hidedetails > 1) $result.=$object->lines[$i]->qty_asked; |
|
1925 | + if ($object->lines[$i]->special_code == 3) { |
|
1926 | + return ''; |
|
1927 | + } |
|
1928 | + if (empty($hidedetails) || $hidedetails > 1) { |
|
1929 | + $result.=$object->lines[$i]->qty_asked; |
|
1930 | + } |
|
1712 | 1931 | } |
1713 | 1932 | return $result; |
1714 | 1933 | } |
@@ -1729,20 +1948,30 @@ discard block |
||
1729 | 1948 | $reshook=0; |
1730 | 1949 | $result=''; |
1731 | 1950 | //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1732 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1951 | + if (is_object($hookmanager)) { |
|
1952 | + // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1733 | 1953 | { |
1734 | 1954 | $special_code = $object->lines[$i]->special_code; |
1735 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1955 | + } |
|
1956 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
1957 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1958 | + } |
|
1736 | 1959 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
1737 | 1960 | $action=''; |
1738 | 1961 | $reshook = $hookmanager->executeHooks('pdf_getlineqty_shipped',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
1739 | 1962 | |
1740 | - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
1963 | + if(!empty($hookmanager->resPrint)) { |
|
1964 | + $result.=$hookmanager->resPrint; |
|
1965 | + } |
|
1741 | 1966 | } |
1742 | 1967 | if (empty($reshook)) |
1743 | 1968 | { |
1744 | - if ($object->lines[$i]->special_code == 3) return ''; |
|
1745 | - if (empty($hidedetails) || $hidedetails > 1) $result.=$object->lines[$i]->qty_shipped; |
|
1969 | + if ($object->lines[$i]->special_code == 3) { |
|
1970 | + return ''; |
|
1971 | + } |
|
1972 | + if (empty($hidedetails) || $hidedetails > 1) { |
|
1973 | + $result.=$object->lines[$i]->qty_shipped; |
|
1974 | + } |
|
1746 | 1975 | } |
1747 | 1976 | return $result; |
1748 | 1977 | } |
@@ -1763,20 +1992,30 @@ discard block |
||
1763 | 1992 | $reshook=0; |
1764 | 1993 | $result=''; |
1765 | 1994 | //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1766 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1995 | + if (is_object($hookmanager)) { |
|
1996 | + // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1767 | 1997 | { |
1768 | 1998 | $special_code = $object->lines[$i]->special_code; |
1769 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
1999 | + } |
|
2000 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
2001 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
2002 | + } |
|
1770 | 2003 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
1771 | 2004 | $action=''; |
1772 | 2005 | $reshook = $hookmanager->executeHooks('pdf_getlineqty_keeptoship',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
1773 | 2006 | |
1774 | - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
2007 | + if(!empty($hookmanager->resPrint)) { |
|
2008 | + $result.=$hookmanager->resPrint; |
|
2009 | + } |
|
1775 | 2010 | } |
1776 | 2011 | if (empty($reshook)) |
1777 | 2012 | { |
1778 | - if ($object->lines[$i]->special_code == 3) return ''; |
|
1779 | - if (empty($hidedetails) || $hidedetails > 1) $result.=($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped); |
|
2013 | + if ($object->lines[$i]->special_code == 3) { |
|
2014 | + return ''; |
|
2015 | + } |
|
2016 | + if (empty($hidedetails) || $hidedetails > 1) { |
|
2017 | + $result.=($object->lines[$i]->qty_asked - $object->lines[$i]->qty_shipped); |
|
2018 | + } |
|
1780 | 2019 | } |
1781 | 2020 | return $result; |
1782 | 2021 | } |
@@ -1798,9 +2037,11 @@ discard block |
||
1798 | 2037 | $reshook=0; |
1799 | 2038 | $result=''; |
1800 | 2039 | //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1801 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
2040 | + if (is_object($hookmanager)) { |
|
2041 | + // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1802 | 2042 | { |
1803 | 2043 | $special_code = $object->lines[$i]->special_code; |
2044 | + } |
|
1804 | 2045 | if (!empty($object->lines[$i]->fk_parent_line)) { |
1805 | 2046 | $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
1806 | 2047 | } |
@@ -1813,12 +2054,18 @@ discard block |
||
1813 | 2054 | $action = ''; |
1814 | 2055 | $reshook = $hookmanager->executeHooks('pdf_getlineunit', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
1815 | 2056 | |
1816 | - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
2057 | + if(!empty($hookmanager->resPrint)) { |
|
2058 | + $result.=$hookmanager->resPrint; |
|
2059 | + } |
|
1817 | 2060 | } |
1818 | 2061 | if (empty($reshook)) |
1819 | 2062 | { |
1820 | - if ($object->lines[$i]->special_code == 3) return ''; |
|
1821 | - if (empty($hidedetails) || $hidedetails > 1) $result.=$langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short')); |
|
2063 | + if ($object->lines[$i]->special_code == 3) { |
|
2064 | + return ''; |
|
2065 | + } |
|
2066 | + if (empty($hidedetails) || $hidedetails > 1) { |
|
2067 | + $result.=$langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short')); |
|
2068 | + } |
|
1822 | 2069 | } |
1823 | 2070 | return $result; |
1824 | 2071 | } |
@@ -1842,20 +2089,30 @@ discard block |
||
1842 | 2089 | $reshook=0; |
1843 | 2090 | $result=''; |
1844 | 2091 | //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1845 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
2092 | + if (is_object($hookmanager)) { |
|
2093 | + // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1846 | 2094 | { |
1847 | 2095 | $special_code = $object->lines[$i]->special_code; |
1848 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
2096 | + } |
|
2097 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
2098 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
2099 | + } |
|
1849 | 2100 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
1850 | 2101 | $action=''; |
1851 | 2102 | $reshook = $hookmanager->executeHooks('pdf_getlineremisepercent',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
1852 | 2103 | |
1853 | - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
2104 | + if(!empty($hookmanager->resPrint)) { |
|
2105 | + $result.=$hookmanager->resPrint; |
|
2106 | + } |
|
1854 | 2107 | } |
1855 | 2108 | if (empty($reshook)) |
1856 | 2109 | { |
1857 | - if ($object->lines[$i]->special_code == 3) return ''; |
|
1858 | - if (empty($hidedetails) || $hidedetails > 1) $result.=dol_print_reduction($object->lines[$i]->remise_percent,$outputlangs); |
|
2110 | + if ($object->lines[$i]->special_code == 3) { |
|
2111 | + return ''; |
|
2112 | + } |
|
2113 | + if (empty($hidedetails) || $hidedetails > 1) { |
|
2114 | + $result.=dol_print_reduction($object->lines[$i]->remise_percent,$outputlangs); |
|
2115 | + } |
|
1859 | 2116 | } |
1860 | 2117 | return $result; |
1861 | 2118 | } |
@@ -1872,25 +2129,35 @@ discard block |
||
1872 | 2129 | */ |
1873 | 2130 | function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookmanager = null) |
1874 | 2131 | { |
1875 | - if (empty($hookmanager)) global $hookmanager; |
|
2132 | + if (empty($hookmanager)) { |
|
2133 | + global $hookmanager; |
|
2134 | + } |
|
1876 | 2135 | global $conf; |
1877 | 2136 | |
1878 | 2137 | $reshook=0; |
1879 | 2138 | $result=''; |
1880 | 2139 | //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1881 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
2140 | + if (is_object($hookmanager)) { |
|
2141 | + // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1882 | 2142 | { |
1883 | 2143 | $special_code = $object->lines[$i]->special_code; |
1884 | - if (!empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
2144 | + } |
|
2145 | + if (!empty($object->lines[$i]->fk_parent_line)) { |
|
2146 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
2147 | + } |
|
1885 | 2148 | $parameters = array('i' => $i, 'outputlangs' => $outputlangs, 'hidedetails' => $hidedetails, 'special_code' => $special_code); |
1886 | 2149 | $action = ''; |
1887 | 2150 | $reshook = $hookmanager->executeHooks('pdf_getlineprogress', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
1888 | 2151 | |
1889 | - if(!empty($hookmanager->resPrint)) return $hookmanager->resPrint; |
|
2152 | + if(!empty($hookmanager->resPrint)) { |
|
2153 | + return $hookmanager->resPrint; |
|
2154 | + } |
|
1890 | 2155 | } |
1891 | 2156 | if (empty($reshook)) |
1892 | 2157 | { |
1893 | - if ($object->lines[$i]->special_code == 3) return ''; |
|
2158 | + if ($object->lines[$i]->special_code == 3) { |
|
2159 | + return ''; |
|
2160 | + } |
|
1894 | 2161 | if (empty($hidedetails) || $hidedetails > 1) |
1895 | 2162 | { |
1896 | 2163 | if ($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF) |
@@ -1901,9 +2168,9 @@ discard block |
||
1901 | 2168 | $prev_progress = $object->lines[$i]->get_prev_progress($object->id); |
1902 | 2169 | } |
1903 | 2170 | $result = ($object->lines[$i]->situation_percent - $prev_progress) . '%'; |
2171 | + } else { |
|
2172 | + $result = $object->lines[$i]->situation_percent . '%'; |
|
1904 | 2173 | } |
1905 | - else |
|
1906 | - $result = $object->lines[$i]->situation_percent . '%'; |
|
1907 | 2174 | } |
1908 | 2175 | } |
1909 | 2176 | return $result; |
@@ -1923,20 +2190,28 @@ discard block |
||
1923 | 2190 | global $conf, $hookmanager; |
1924 | 2191 | |
1925 | 2192 | $sign=1; |
1926 | - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
2193 | + if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) { |
|
2194 | + $sign=-1; |
|
2195 | + } |
|
1927 | 2196 | |
1928 | 2197 | $reshook=0; |
1929 | 2198 | $result=''; |
1930 | 2199 | //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1931 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
2200 | + if (is_object($hookmanager)) { |
|
2201 | + // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1932 | 2202 | { |
1933 | 2203 | $special_code = $object->lines[$i]->special_code; |
1934 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
2204 | + } |
|
2205 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
2206 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
2207 | + } |
|
1935 | 2208 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code, 'sign'=>$sign); |
1936 | 2209 | $action=''; |
1937 | 2210 | $reshook = $hookmanager->executeHooks('pdf_getlinetotalexcltax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
1938 | 2211 | |
1939 | - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
2212 | + if(!empty($hookmanager->resPrint)) { |
|
2213 | + $result.=$hookmanager->resPrint; |
|
2214 | + } |
|
1940 | 2215 | } |
1941 | 2216 | if (empty($reshook)) |
1942 | 2217 | { |
@@ -1957,9 +2232,9 @@ discard block |
||
1957 | 2232 | $progress = ($object->lines[$i]->situation_percent - $prev_progress) / 100; |
1958 | 2233 | } |
1959 | 2234 | $result.=price($sign * ($total_ht/($object->lines[$i]->situation_percent/100)) * $progress, 0, $outputlangs); |
2235 | + } else { |
|
2236 | + $result.=price($sign * $total_ht, 0, $outputlangs); |
|
1960 | 2237 | } |
1961 | - else |
|
1962 | - $result.=price($sign * $total_ht, 0, $outputlangs); |
|
1963 | 2238 | } |
1964 | 2239 | } |
1965 | 2240 | return $result; |
@@ -1979,28 +2254,37 @@ discard block |
||
1979 | 2254 | global $hookmanager,$conf; |
1980 | 2255 | |
1981 | 2256 | $sign=1; |
1982 | - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
2257 | + if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) { |
|
2258 | + $sign=-1; |
|
2259 | + } |
|
1983 | 2260 | |
1984 | 2261 | $reshook=0; |
1985 | 2262 | $result=''; |
1986 | 2263 | //if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) ) |
1987 | - if (is_object($hookmanager)) // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
2264 | + if (is_object($hookmanager)) { |
|
2265 | + // Old code is commented on preceding line. Reproduct this test in the pdf_xxx function if you don't want your hook to run |
|
1988 | 2266 | { |
1989 | 2267 | $special_code = $object->lines[$i]->special_code; |
1990 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
2268 | + } |
|
2269 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
2270 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
2271 | + } |
|
1991 | 2272 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
1992 | 2273 | $action=''; |
1993 | 2274 | $reshook = $hookmanager->executeHooks('pdf_getlinetotalwithtax',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
1994 | 2275 | |
1995 | - if(!empty($hookmanager->resPrint)) $result.=$hookmanager->resPrint; |
|
2276 | + if(!empty($hookmanager->resPrint)) { |
|
2277 | + $result.=$hookmanager->resPrint; |
|
2278 | + } |
|
1996 | 2279 | } |
1997 | 2280 | if (empty($reshook)) |
1998 | 2281 | { |
1999 | 2282 | if ($object->lines[$i]->special_code == 3) |
2000 | 2283 | { |
2001 | 2284 | $result.=$outputlangs->transnoentities("Option"); |
2002 | - } |
|
2003 | - elseif (empty($hidedetails) || $hidedetails > 1) $result.=price($sign * ($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs); |
|
2285 | + } elseif (empty($hidedetails) || $hidedetails > 1) { |
|
2286 | + $result.=price($sign * ($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht)*($object->lines[$i]->tva_tx)/100, 0, $outputlangs); |
|
2287 | + } |
|
2004 | 2288 | } |
2005 | 2289 | return $result; |
2006 | 2290 | } |
@@ -2029,21 +2313,20 @@ discard block |
||
2029 | 2313 | if ($type=='all') |
2030 | 2314 | { |
2031 | 2315 | $total += $object->lines[$i]->qty; |
2032 | - } |
|
2033 | - else if ($type==9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) |
|
2316 | + } else if ($type==9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line))) |
|
2034 | 2317 | { |
2035 | 2318 | $special_code = $object->lines[$i]->special_code; |
2036 | - if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
2319 | + if (! empty($object->lines[$i]->fk_parent_line)) { |
|
2320 | + $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); |
|
2321 | + } |
|
2037 | 2322 | $parameters = array('i'=>$i,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'special_code'=>$special_code); |
2038 | 2323 | $action=''; |
2039 | 2324 | $reshook = $hookmanager->executeHooks('pdf_getTotalQty',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
2040 | 2325 | return $hookmanager->resPrint; |
2041 | - } |
|
2042 | - else if ($type==0 && $object->lines[$i]->product_type == 0) |
|
2326 | + } else if ($type==0 && $object->lines[$i]->product_type == 0) |
|
2043 | 2327 | { |
2044 | 2328 | $total += $object->lines[$i]->qty; |
2045 | - } |
|
2046 | - else if ($type==1 && $object->lines[$i]->product_type == 1) |
|
2329 | + } else if ($type==1 && $object->lines[$i]->product_type == 1) |
|
2047 | 2330 | { |
2048 | 2331 | $total += $object->lines[$i]->qty; |
2049 | 2332 | } |
@@ -2074,8 +2357,7 @@ discard block |
||
2074 | 2357 | if ($objecttype == 'facture') |
2075 | 2358 | { |
2076 | 2359 | // For invoice, we don't want to have a reference line on document. Image we are using recuring invoice, we will have a line longer than document width. |
2077 | - } |
|
2078 | - elseif ($objecttype == 'propal' || $objecttype == 'supplier_proposal') |
|
2360 | + } elseif ($objecttype == 'propal' || $objecttype == 'supplier_proposal') |
|
2079 | 2361 | { |
2080 | 2362 | $outputlangs->load('propal'); |
2081 | 2363 | |
@@ -2086,8 +2368,7 @@ discard block |
||
2086 | 2368 | $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DatePropal"); |
2087 | 2369 | $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date,'day','',$outputlangs); |
2088 | 2370 | } |
2089 | - } |
|
2090 | - else if ($objecttype == 'commande' || $objecttype == 'supplier_order') |
|
2371 | + } else if ($objecttype == 'commande' || $objecttype == 'supplier_order') |
|
2091 | 2372 | { |
2092 | 2373 | $outputlangs->load('orders'); |
2093 | 2374 | foreach($objects as $elementobject) |
@@ -2097,8 +2378,7 @@ discard block |
||
2097 | 2378 | $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate"); |
2098 | 2379 | $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date,'day','',$outputlangs); |
2099 | 2380 | } |
2100 | - } |
|
2101 | - else if ($objecttype == 'contrat') |
|
2381 | + } else if ($objecttype == 'contrat') |
|
2102 | 2382 | { |
2103 | 2383 | $outputlangs->load('contracts'); |
2104 | 2384 | foreach($objects as $elementobject) |
@@ -2108,8 +2388,7 @@ discard block |
||
2108 | 2388 | $linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateContract"); |
2109 | 2389 | $linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date_contrat,'day','',$outputlangs); |
2110 | 2390 | } |
2111 | - } |
|
2112 | - else if ($objecttype == 'shipping') |
|
2391 | + } else if ($objecttype == 'shipping') |
|
2113 | 2392 | { |
2114 | 2393 | $outputlangs->loadLangs(array("orders", "sendings")); |
2115 | 2394 | |
@@ -2117,24 +2396,31 @@ discard block |
||
2117 | 2396 | { |
2118 | 2397 | $order=null; |
2119 | 2398 | // We concat this record info into fields xxx_value. title is overwrote. |
2120 | - if (empty($object->linkedObjects['commande']) && $object->element != 'commande') // There is not already a link to order and object is not the order, so we show also info with order |
|
2399 | + if (empty($object->linkedObjects['commande']) && $object->element != 'commande') { |
|
2400 | + // There is not already a link to order and object is not the order, so we show also info with order |
|
2121 | 2401 | { |
2122 | 2402 | $elementobject->fetchObjectLinked(); |
2123 | - if (! empty($elementobject->linkedObjects['commande'])) $order = reset($elementobject->linkedObjects['commande']); |
|
2403 | + } |
|
2404 | + if (! empty($elementobject->linkedObjects['commande'])) { |
|
2405 | + $order = reset($elementobject->linkedObjects['commande']); |
|
2406 | + } |
|
2124 | 2407 | } |
2125 | 2408 | if (! is_object($order)) |
2126 | 2409 | { |
2127 | 2410 | $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefSending"); |
2128 | - if (! empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'].=' / '; |
|
2411 | + if (! empty($linkedobjects[$objecttype]['ref_value'])) { |
|
2412 | + $linkedobjects[$objecttype]['ref_value'].=' / '; |
|
2413 | + } |
|
2129 | 2414 | $linkedobjects[$objecttype]['ref_value'].= $outputlangs->transnoentities($elementobject->ref); |
2130 | 2415 | //$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("DateShipment"); |
2131 | 2416 | //if (! empty($linkedobjects[$objecttype]['date_value'])) $linkedobjects[$objecttype]['date_value'].=' / '; |
2132 | 2417 | //$linkedobjects[$objecttype]['date_value'].= dol_print_date($elementobject->date_delivery,'day','',$outputlangs); |
2133 | - } |
|
2134 | - else |
|
2418 | + } else |
|
2135 | 2419 | { |
2136 | 2420 | $linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("RefOrder") . ' / ' . $outputlangs->transnoentities("RefSending"); |
2137 | - if (empty($linkedobjects[$objecttype]['ref_value'])) $linkedobjects[$objecttype]['ref_value'] = $outputlangs->convToOutputCharset($order->ref) . ($order->ref_client ? ' ('.$order->ref_client.')' : ''); |
|
2421 | + if (empty($linkedobjects[$objecttype]['ref_value'])) { |
|
2422 | + $linkedobjects[$objecttype]['ref_value'] = $outputlangs->convToOutputCharset($order->ref) . ($order->ref_client ? ' ('.$order->ref_client.')' : ''); |
|
2423 | + } |
|
2138 | 2424 | $linkedobjects[$objecttype]['ref_value'].= ' / ' . $outputlangs->transnoentities($elementobject->ref); |
2139 | 2425 | //$linkedobjects[$objecttype]['date_title'] = $outputlangs->transnoentities("OrderDate") . ($elementobject->date_delivery ? ' / ' . $outputlangs->transnoentities("DateShipment") : ''); |
2140 | 2426 | //if (empty($linkedobjects[$objecttype]['date_value'])) $linkedobjects[$objecttype]['date_value'] = dol_print_date($order->date,'day','',$outputlangs); |
@@ -2150,7 +2436,9 @@ discard block |
||
2150 | 2436 | $parameters = array('linkedobjects' => $linkedobjects, 'outputlangs'=>$outputlangs); |
2151 | 2437 | $action=''; |
2152 | 2438 | $hookmanager->executeHooks('pdf_getLinkedObjects',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
2153 | - if (! empty($hookmanager->resArray)) $linkedobjects = $hookmanager->resArray; |
|
2439 | + if (! empty($hookmanager->resArray)) { |
|
2440 | + $linkedobjects = $hookmanager->resArray; |
|
2441 | + } |
|
2154 | 2442 | } |
2155 | 2443 | |
2156 | 2444 | return $linkedobjects; |
@@ -2174,12 +2462,13 @@ discard block |
||
2174 | 2462 | if ($tmp['height']) |
2175 | 2463 | { |
2176 | 2464 | $width=(int) round($maxheight*$tmp['width']/$tmp['height']); // I try to use maxheight |
2177 | - if ($width > $maxwidth) // Pb with maxheight, so i use maxwidth |
|
2465 | + if ($width > $maxwidth) { |
|
2466 | + // Pb with maxheight, so i use maxwidth |
|
2178 | 2467 | { |
2179 | 2468 | $width=$maxwidth; |
2180 | - $height=(int) round($maxwidth*$tmp['height']/$tmp['width']); |
|
2181 | 2469 | } |
2182 | - else // No pb with maxheight |
|
2470 | + $height=(int) round($maxwidth*$tmp['height']/$tmp['width']); |
|
2471 | + } else // No pb with maxheight |
|
2183 | 2472 | { |
2184 | 2473 | $height=$maxheight; |
2185 | 2474 | } |
@@ -89,14 +89,20 @@ discard block |
||
89 | 89 | $result=array(); |
90 | 90 | |
91 | 91 | // Clean parameters |
92 | - if (empty($info_bits)) $info_bits=0; |
|
93 | - if (empty($txtva)) $txtva=0; |
|
92 | + if (empty($info_bits)) { |
|
93 | + $info_bits=0; |
|
94 | + } |
|
95 | + if (empty($txtva)) { |
|
96 | + $txtva=0; |
|
97 | + } |
|
94 | 98 | if (empty($seller) || ! is_object($seller)) |
95 | 99 | { |
96 | 100 | dol_syslog("Price.lib::calcul_price_total Warning: function is called with parameter seller that is missing", LOG_WARNING); |
97 | - if (! is_object($mysoc)) // mysoc may be not defined (during migration process) |
|
101 | + if (! is_object($mysoc)) { |
|
102 | + // mysoc may be not defined (during migration process) |
|
98 | 103 | { |
99 | 104 | $mysoc=new Societe($db); |
105 | + } |
|
100 | 106 | $mysoc->setMysoc($conf); |
101 | 107 | } |
102 | 108 | $seller=$mysoc; // If sell is done to a customer, $seller is not provided, we use $mysoc |
@@ -111,11 +117,19 @@ discard block |
||
111 | 117 | |
112 | 118 | $countryid=$seller->country_id; |
113 | 119 | |
114 | - if (is_numeric($uselocaltax1_rate)) $uselocaltax1_rate=(float) $uselocaltax1_rate; |
|
115 | - if (is_numeric($uselocaltax2_rate)) $uselocaltax2_rate=(float) $uselocaltax2_rate; |
|
120 | + if (is_numeric($uselocaltax1_rate)) { |
|
121 | + $uselocaltax1_rate=(float) $uselocaltax1_rate; |
|
122 | + } |
|
123 | + if (is_numeric($uselocaltax2_rate)) { |
|
124 | + $uselocaltax2_rate=(float) $uselocaltax2_rate; |
|
125 | + } |
|
116 | 126 | |
117 | - if ($uselocaltax1_rate < 0) $uselocaltax1_rate=$seller->localtax1_assuj; |
|
118 | - if ($uselocaltax2_rate < 0) $uselocaltax2_rate=$seller->localtax2_assuj; |
|
127 | + if ($uselocaltax1_rate < 0) { |
|
128 | + $uselocaltax1_rate=$seller->localtax1_assuj; |
|
129 | + } |
|
130 | + if ($uselocaltax2_rate < 0) { |
|
131 | + $uselocaltax2_rate=$seller->localtax2_assuj; |
|
132 | + } |
|
119 | 133 | |
120 | 134 | //var_dump($uselocaltax1_rate.' - '.$uselocaltax2_rate); |
121 | 135 | dol_syslog('Price.lib::calcul_price_total qty='.$qty.' pu='.$pu.' remise_percent_ligne='.$remise_percent_ligne.' txtva='.$txtva.' uselocaltax1_rate='.$uselocaltax1_rate.' uselocaltax2_rate='.$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$price_base_type.' type='.$type.' progress='.$progress); |
@@ -130,8 +144,7 @@ discard block |
||
130 | 144 | $localtax1_rate = $localtaxes_array[1]; |
131 | 145 | $localtax2_type = $localtaxes_array[2]; |
132 | 146 | $localtax2_rate = $localtaxes_array[3]; |
133 | - } |
|
134 | - else // deprecated method. values and type for localtaxes must be provided by caller and loaded with getLocalTaxesFromRate |
|
147 | + } else // deprecated method. values and type for localtaxes must be provided by caller and loaded with getLocalTaxesFromRate |
|
135 | 148 | { |
136 | 149 | $sql = "SELECT taux, localtax1, localtax2, localtax1_type, localtax2_type"; |
137 | 150 | $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as cv"; |
@@ -150,24 +163,29 @@ discard block |
||
150 | 163 | $localtax2_type=$obj->localtax2_type; |
151 | 164 | //var_dump($localtax1_rate.' '.$localtax2_rate.' '.$localtax1_type.' '.$localtax2_type);exit; |
152 | 165 | } |
166 | + } else { |
|
167 | + dol_print_error($db); |
|
153 | 168 | } |
154 | - else dol_print_error($db); |
|
155 | 169 | } |
156 | 170 | |
157 | 171 | // pu calculation from pu_devise if pu empty |
158 | 172 | if (empty($pu) && !empty($pu_devise)) { |
159 | - if (! empty($multicurrency_tx)) $pu = $pu_devise / $multicurrency_tx; |
|
160 | - else |
|
173 | + if (! empty($multicurrency_tx)) { |
|
174 | + $pu = $pu_devise / $multicurrency_tx; |
|
175 | + } else |
|
161 | 176 | { |
162 | 177 | dol_syslog('Price.lib::calcul_price_total function called with bad parameters combination (multicurrency_tx empty when pu_devise not) ', LOG_ERR); |
163 | 178 | return array(); |
164 | 179 | } |
165 | 180 | } |
166 | - if ($pu === '') $pu=0; |
|
181 | + if ($pu === '') { |
|
182 | + $pu=0; |
|
183 | + } |
|
167 | 184 | // pu_devise calculation from pu |
168 | 185 | if (empty($pu_devise) && !empty($multicurrency_tx)) { |
169 | - if (is_numeric($pu) && is_numeric($multicurrency_tx)) $pu_devise = $pu * $multicurrency_tx; |
|
170 | - else |
|
186 | + if (is_numeric($pu) && is_numeric($multicurrency_tx)) { |
|
187 | + $pu_devise = $pu * $multicurrency_tx; |
|
188 | + } else |
|
171 | 189 | { |
172 | 190 | dol_syslog('Price.lib::calcul_price_total function called with bad parameters combination (pu or multicurrency_tx are not numeric)', LOG_ERR); |
173 | 191 | return array(); |
@@ -180,7 +198,9 @@ discard block |
||
180 | 198 | $tot_avec_remise = $tot_avec_remise_ligne * (1 - ($remise_percent_global / 100)); |
181 | 199 | |
182 | 200 | // initialize result array |
183 | - for ($i=0; $i <= 15; $i++) $result[$i] = 0; |
|
201 | + for ($i=0; $i <= 15; $i++) { |
|
202 | + $result[$i] = 0; |
|
203 | + } |
|
184 | 204 | |
185 | 205 | // if there's some localtax including vat, we calculate localtaxes (we will add later) |
186 | 206 | |
@@ -190,8 +210,7 @@ discard block |
||
190 | 210 | $tot_sans_remise_wt = price2num($tot_sans_remise * (1 + ($txtva / 100)),'MU'); |
191 | 211 | $tot_avec_remise_wt = price2num($tot_avec_remise * (1 + ($txtva / 100)),'MU'); |
192 | 212 | $pu_wt = price2num($pu * (1 + ($txtva / 100)),'MU'); |
193 | - } |
|
194 | - else |
|
213 | + } else |
|
195 | 214 | { |
196 | 215 | $tot_sans_remise_wt = $tot_sans_remise; |
197 | 216 | $tot_avec_remise_wt = $tot_avec_remise; |
@@ -207,10 +226,14 @@ discard block |
||
207 | 226 | $apply_tax = true; |
208 | 227 | break; |
209 | 228 | case '4': // localtax on product |
210 | - if ($type == 0) $apply_tax = true; |
|
229 | + if ($type == 0) { |
|
230 | + $apply_tax = true; |
|
231 | + } |
|
211 | 232 | break; |
212 | 233 | case '6': // localtax on service |
213 | - if ($type == 1) $apply_tax = true; |
|
234 | + if ($type == 1) { |
|
235 | + $apply_tax = true; |
|
236 | + } |
|
214 | 237 | break; |
215 | 238 | } |
216 | 239 | |
@@ -231,10 +254,14 @@ discard block |
||
231 | 254 | $apply_tax = true; |
232 | 255 | break; |
233 | 256 | case '4': // localtax on product |
234 | - if ($type == 0) $apply_tax = true; |
|
257 | + if ($type == 0) { |
|
258 | + $apply_tax = true; |
|
259 | + } |
|
235 | 260 | break; |
236 | 261 | case '6': // localtax on service |
237 | - if ($type == 1) $apply_tax = true; |
|
262 | + if ($type == 1) { |
|
263 | + $apply_tax = true; |
|
264 | + } |
|
238 | 265 | break; |
239 | 266 | } |
240 | 267 | if ($uselocaltax2_rate && $apply_tax) { |
@@ -266,8 +293,7 @@ discard block |
||
266 | 293 | $result[5] = price2num($pu * (1 + ( (($info_bits & 1)?0:$txtva) / 100)) + $localtaxes[2], 'MU'); // Selon TVA NPR ou non |
267 | 294 | $result5bis= price2num($pu * (1 + ($txtva / 100)) + $localtaxes[2], 'MU'); // Si TVA consideree normale (non NPR) |
268 | 295 | $result[4] = price2num($result5bis - ($result[3] + $localtaxes[2]), 'MU'); |
269 | - } |
|
270 | - else |
|
296 | + } else |
|
271 | 297 | { |
272 | 298 | // We work to define prices using the price with tax |
273 | 299 | $result[8] = price2num($tot_sans_remise + $localtaxes[0], 'MT'); |
@@ -302,10 +328,14 @@ discard block |
||
302 | 328 | $apply_tax = true; |
303 | 329 | break; |
304 | 330 | case '3': // localtax on product |
305 | - if ($type == 0) $apply_tax = true; |
|
331 | + if ($type == 0) { |
|
332 | + $apply_tax = true; |
|
333 | + } |
|
306 | 334 | break; |
307 | 335 | case '5': // localtax on service |
308 | - if ($type == 1) $apply_tax = true; |
|
336 | + if ($type == 1) { |
|
337 | + $apply_tax = true; |
|
338 | + } |
|
309 | 339 | break; |
310 | 340 | } |
311 | 341 | if ($uselocaltax1_rate && $apply_tax) { |
@@ -325,10 +355,14 @@ discard block |
||
325 | 355 | $apply_tax = true; |
326 | 356 | break; |
327 | 357 | case '3': // localtax on product |
328 | - if ($type == 0) $apply_tax = true; |
|
358 | + if ($type == 0) { |
|
359 | + $apply_tax = true; |
|
360 | + } |
|
329 | 361 | break; |
330 | 362 | case '5': // localtax on service |
331 | - if ($type == 1) $apply_tax = true; |
|
363 | + if ($type == 1) { |
|
364 | + $apply_tax = true; |
|
365 | + } |
|
332 | 366 | break; |
333 | 367 | } |
334 | 368 | if ($uselocaltax2_rate && $apply_tax) { |
@@ -352,8 +386,7 @@ discard block |
||
352 | 386 | $result[2]=price2num($result[0]+$result[1], 'MT'); |
353 | 387 | $result[9]=round($result[9]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; |
354 | 388 | $result[10]=round($result[10]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; |
355 | - } |
|
356 | - else |
|
389 | + } else |
|
357 | 390 | { |
358 | 391 | $result[1]=round($result[1]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; |
359 | 392 | $result[2]=round($result[2]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; |
@@ -386,8 +419,7 @@ discard block |
||
386 | 419 | $result[18] = price2num($result[2] * $multicurrency_tx, 'MT'); |
387 | 420 | $result[19] = price2num($pu_devise, 'MU'); |
388 | 421 | */ |
389 | - } |
|
390 | - else |
|
422 | + } else |
|
391 | 423 | { |
392 | 424 | $result[16] = $result[0]; |
393 | 425 | $result[17] = $result[1]; |
@@ -112,17 +112,14 @@ discard block |
||
112 | 112 | if (! function_exists("ldap_connect")) |
113 | 113 | { |
114 | 114 | print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans('LDAPFunctionsNotAvailableOnPHP').'">'.$butlabel.'</a>'; |
115 | - } |
|
116 | - else if (empty($conf->global->LDAP_SERVER_HOST)) |
|
115 | + } else if (empty($conf->global->LDAP_SERVER_HOST)) |
|
117 | 116 | { |
118 | 117 | print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans('LDAPSetupNotComplete').'">'.$butlabel.'</a>'; |
119 | - } |
|
120 | - else if (empty($key) || empty($dn) || empty($objectclass)) |
|
118 | + } else if (empty($key) || empty($dn) || empty($objectclass)) |
|
121 | 119 | { |
122 | 120 | $langs->load("errors"); |
123 | 121 | print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans('ErrorLDAPSetupNotComplete').'">'.$butlabel.'</a>'; |
124 | - } |
|
125 | - else |
|
122 | + } else |
|
126 | 123 | { |
127 | 124 | print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action='.$testlabel.'">'.$butlabel.'</a>'; |
128 | 125 | } |
@@ -146,15 +143,28 @@ discard block |
||
146 | 143 | global $bc, $conf; |
147 | 144 | |
148 | 145 | $count--; |
149 | - if ($count == 0) return -1; // To stop loop |
|
150 | - if (! is_array($result)) return -1; |
|
146 | + if ($count == 0) { |
|
147 | + return -1; |
|
148 | + } |
|
149 | + // To stop loop |
|
150 | + if (! is_array($result)) { |
|
151 | + return -1; |
|
152 | + } |
|
151 | 153 | |
152 | 154 | foreach($result as $key => $val) |
153 | 155 | { |
154 | - if ("$key" == "objectclass") continue; |
|
155 | - if ("$key" == "count") continue; |
|
156 | - if ("$key" == "dn") continue; |
|
157 | - if ("$val" == "objectclass") continue; |
|
156 | + if ("$key" == "objectclass") { |
|
157 | + continue; |
|
158 | + } |
|
159 | + if ("$key" == "count") { |
|
160 | + continue; |
|
161 | + } |
|
162 | + if ("$key" == "dn") { |
|
163 | + continue; |
|
164 | + } |
|
165 | + if ("$val" == "objectclass") { |
|
166 | + continue; |
|
167 | + } |
|
158 | 168 | |
159 | 169 | $lastkey[$level]=$key; |
160 | 170 | |
@@ -168,19 +178,25 @@ discard block |
||
168 | 178 | print '<td>'; |
169 | 179 | print $key; |
170 | 180 | print '</td><td>'; |
171 | - if (strtolower($key) == 'userpassword') $hide=1; |
|
181 | + if (strtolower($key) == 'userpassword') { |
|
182 | + $hide=1; |
|
183 | + } |
|
172 | 184 | } |
173 | 185 | show_ldap_content($val,$level+1,$count,$var,$hide,$val["count"]); |
174 | - } |
|
175 | - else if ($subcount) |
|
186 | + } else if ($subcount) |
|
176 | 187 | { |
177 | 188 | $subcount--; |
178 | 189 | $newstring=dol_htmlentitiesbr($val); |
179 | - if ($hide) print preg_replace('/./i','*',$newstring); |
|
180 | - else print $newstring; |
|
190 | + if ($hide) { |
|
191 | + print preg_replace('/./i','*',$newstring); |
|
192 | + } else { |
|
193 | + print $newstring; |
|
194 | + } |
|
181 | 195 | print '<br>'; |
182 | 196 | } |
183 | - if ("$val" != $lastkey[$level] && !$subcount) print '</td></tr>'; |
|
197 | + if ("$val" != $lastkey[$level] && !$subcount) { |
|
198 | + print '</td></tr>'; |
|
199 | + } |
|
184 | 200 | } |
185 | 201 | return 1; |
186 | 202 | } |
@@ -55,8 +55,7 @@ discard block |
||
55 | 55 | $entity = "&#". $unicode . ';'; |
56 | 56 | $decodedStr .= utf8_encode($entity); |
57 | 57 | $pos += 4; |
58 | - } |
|
59 | - else { |
|
58 | + } else { |
|
60 | 59 | // we have an escaped ascii character |
61 | 60 | $hexVal = substr($source, $pos, 2); |
62 | 61 | $decodedStr .= chr(hexdec($hexVal)); |
@@ -97,7 +96,10 @@ discard block |
||
97 | 96 | { |
98 | 97 | while (($file = readdir($handle))!==false) |
99 | 98 | { |
100 | - if (preg_match('/disabled/',$file)) continue; // We discard module if it contains disabled into name. |
|
99 | + if (preg_match('/disabled/',$file)) { |
|
100 | + continue; |
|
101 | + } |
|
102 | + // We discard module if it contains disabled into name. |
|
101 | 103 | |
102 | 104 | if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes') |
103 | 105 | { |
@@ -129,8 +131,14 @@ discard block |
||
129 | 131 | $outputlangs=$langs; |
130 | 132 | } |
131 | 133 | |
132 | - if ($outputlangs->defaultlang == 'ca_CA') $selected='CAP4'; // Canada |
|
133 | - if ($outputlangs->defaultlang == 'en_US') $selected='USLetter'; // US |
|
134 | + if ($outputlangs->defaultlang == 'ca_CA') { |
|
135 | + $selected='CAP4'; |
|
136 | + } |
|
137 | + // Canada |
|
138 | + if ($outputlangs->defaultlang == 'en_US') { |
|
139 | + $selected='USLetter'; |
|
140 | + } |
|
141 | + // US |
|
134 | 142 | return $selected; |
135 | 143 | } |
136 | 144 | |
@@ -155,29 +163,42 @@ discard block |
||
155 | 163 | { |
156 | 164 | $content=file_get_contents($formfile); |
157 | 165 | $isutf8=utf8_check($content); |
158 | - if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') print utf8_encode($content); |
|
159 | - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') print utf8_decode($content); |
|
160 | - else print $content; |
|
166 | + if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') { |
|
167 | + print utf8_encode($content); |
|
168 | + } elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') { |
|
169 | + print utf8_decode($content); |
|
170 | + } else { |
|
171 | + print $content; |
|
172 | + } |
|
161 | 173 | return true; |
174 | + } else { |
|
175 | + dol_syslog('functions2::dol_print_file not found', LOG_DEBUG); |
|
162 | 176 | } |
163 | - else dol_syslog('functions2::dol_print_file not found', LOG_DEBUG); |
|
164 | 177 | |
165 | 178 | if ($searchalt) { |
166 | 179 | // Test si fichier dans repertoire de la langue alternative |
167 | - if ($langs->defaultlang != "en_US") $formfilealt = $searchdir."/langs/en_US/".$filename; |
|
168 | - else $formfilealt = $searchdir."/langs/fr_FR/".$filename; |
|
180 | + if ($langs->defaultlang != "en_US") { |
|
181 | + $formfilealt = $searchdir."/langs/en_US/".$filename; |
|
182 | + } else { |
|
183 | + $formfilealt = $searchdir."/langs/fr_FR/".$filename; |
|
184 | + } |
|
169 | 185 | dol_syslog('functions2::dol_print_file search alt file '.$formfilealt, LOG_DEBUG); |
170 | 186 | //print 'getcwd='.getcwd().' htmlfilealt='.$formfilealt.' X '.file_exists(getcwd().'/'.$formfilealt); |
171 | 187 | if (is_readable($formfilealt)) |
172 | 188 | { |
173 | 189 | $content=file_get_contents($formfilealt); |
174 | 190 | $isutf8=utf8_check($content); |
175 | - if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') print utf8_encode($content); |
|
176 | - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') print utf8_decode($content); |
|
177 | - else print $content; |
|
191 | + if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') { |
|
192 | + print utf8_encode($content); |
|
193 | + } elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') { |
|
194 | + print utf8_decode($content); |
|
195 | + } else { |
|
196 | + print $content; |
|
197 | + } |
|
178 | 198 | return true; |
199 | + } else { |
|
200 | + dol_syslog('functions2::dol_print_file not found', LOG_DEBUG); |
|
179 | 201 | } |
180 | - else dol_syslog('functions2::dol_print_file not found', LOG_DEBUG); |
|
181 | 202 | } |
182 | 203 | } |
183 | 204 | |
@@ -207,279 +228,460 @@ discard block |
||
207 | 228 | $deltadateforuser=round($deltadateforclient-$deltadateforserver); |
208 | 229 | //print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser; |
209 | 230 | |
210 | - if ($usetable) print '<table class="border centpercent">'; |
|
231 | + if ($usetable) { |
|
232 | + print '<table class="border centpercent">'; |
|
233 | + } |
|
211 | 234 | |
212 | 235 | // Import key |
213 | 236 | if (! empty($object->import_key)) |
214 | 237 | { |
215 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
238 | + if ($usetable) { |
|
239 | + print '<tr><td class="titlefield">'; |
|
240 | + } |
|
216 | 241 | print $langs->trans("ImportedWithSet"); |
217 | - if ($usetable) print '</td><td>'; |
|
218 | - else print ': '; |
|
242 | + if ($usetable) { |
|
243 | + print '</td><td>'; |
|
244 | + } else { |
|
245 | + print ': '; |
|
246 | + } |
|
219 | 247 | print $object->import_key; |
220 | - if ($usetable) print '</td></tr>'; |
|
221 | - else print '<br>'; |
|
248 | + if ($usetable) { |
|
249 | + print '</td></tr>'; |
|
250 | + } else { |
|
251 | + print '<br>'; |
|
252 | + } |
|
222 | 253 | } |
223 | 254 | |
224 | 255 | // User creation (old method using already loaded object and not id is kept for backward compatibility) |
225 | 256 | if (! empty($object->user_creation) || ! empty($object->user_creation_id)) |
226 | 257 | { |
227 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
258 | + if ($usetable) { |
|
259 | + print '<tr><td class="titlefield">'; |
|
260 | + } |
|
228 | 261 | print $langs->trans("CreatedBy"); |
229 | - if ($usetable) print '</td><td>'; |
|
230 | - else print ': '; |
|
262 | + if ($usetable) { |
|
263 | + print '</td><td>'; |
|
264 | + } else { |
|
265 | + print ': '; |
|
266 | + } |
|
231 | 267 | if (is_object($object->user_creation)) |
232 | 268 | { |
233 | - if ($object->user_creation->id) print $object->user_creation->getNomUrl(1, '', 0, 0, 0); |
|
234 | - else print $langs->trans("Unknown"); |
|
235 | - } |
|
236 | - else |
|
269 | + if ($object->user_creation->id) { |
|
270 | + print $object->user_creation->getNomUrl(1, '', 0, 0, 0); |
|
271 | + } else { |
|
272 | + print $langs->trans("Unknown"); |
|
273 | + } |
|
274 | + } else |
|
237 | 275 | { |
238 | 276 | $userstatic=new User($db); |
239 | 277 | $userstatic->fetch($object->user_creation_id ? $object->user_creation_id : $object->user_creation); |
240 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
241 | - else print $langs->trans("Unknown"); |
|
278 | + if ($userstatic->id) { |
|
279 | + print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
280 | + } else { |
|
281 | + print $langs->trans("Unknown"); |
|
282 | + } |
|
283 | + } |
|
284 | + if ($usetable) { |
|
285 | + print '</td></tr>'; |
|
286 | + } else { |
|
287 | + print '<br>'; |
|
242 | 288 | } |
243 | - if ($usetable) print '</td></tr>'; |
|
244 | - else print '<br>'; |
|
245 | 289 | } |
246 | 290 | |
247 | 291 | // Date creation |
248 | 292 | if (! empty($object->date_creation)) |
249 | 293 | { |
250 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
294 | + if ($usetable) { |
|
295 | + print '<tr><td class="titlefield">'; |
|
296 | + } |
|
251 | 297 | print $langs->trans("DateCreation"); |
252 | - if ($usetable) print '</td><td>'; |
|
253 | - else print ': '; |
|
298 | + if ($usetable) { |
|
299 | + print '</td><td>'; |
|
300 | + } else { |
|
301 | + print ': '; |
|
302 | + } |
|
254 | 303 | print dol_print_date($object->date_creation, 'dayhour'); |
255 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_creation+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
256 | - if ($usetable) print '</td></tr>'; |
|
257 | - else print '<br>'; |
|
304 | + if ($deltadateforuser) { |
|
305 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_creation+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
306 | + } |
|
307 | + if ($usetable) { |
|
308 | + print '</td></tr>'; |
|
309 | + } else { |
|
310 | + print '<br>'; |
|
311 | + } |
|
258 | 312 | } |
259 | 313 | |
260 | 314 | // User change (old method using already loaded object and not id is kept for backward compatibility) |
261 | 315 | if (! empty($object->user_modification) || ! empty($object->user_modification_id)) |
262 | 316 | { |
263 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
317 | + if ($usetable) { |
|
318 | + print '<tr><td class="titlefield">'; |
|
319 | + } |
|
264 | 320 | print $langs->trans("ModifiedBy"); |
265 | - if ($usetable) print '</td><td>'; |
|
266 | - else print ': '; |
|
321 | + if ($usetable) { |
|
322 | + print '</td><td>'; |
|
323 | + } else { |
|
324 | + print ': '; |
|
325 | + } |
|
267 | 326 | if (is_object($object->user_modification)) |
268 | 327 | { |
269 | - if ($object->user_modification->id) print $object->user_modification->getNomUrl(1, '', 0, 0, 0); |
|
270 | - else print $langs->trans("Unknown"); |
|
271 | - } |
|
272 | - else |
|
328 | + if ($object->user_modification->id) { |
|
329 | + print $object->user_modification->getNomUrl(1, '', 0, 0, 0); |
|
330 | + } else { |
|
331 | + print $langs->trans("Unknown"); |
|
332 | + } |
|
333 | + } else |
|
273 | 334 | { |
274 | 335 | $userstatic=new User($db); |
275 | 336 | $userstatic->fetch($object->user_modification_id ? $object->user_modification_id : $object->user_modification); |
276 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
277 | - else print $langs->trans("Unknown"); |
|
337 | + if ($userstatic->id) { |
|
338 | + print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
339 | + } else { |
|
340 | + print $langs->trans("Unknown"); |
|
341 | + } |
|
342 | + } |
|
343 | + if ($usetable) { |
|
344 | + print '</td></tr>'; |
|
345 | + } else { |
|
346 | + print '<br>'; |
|
278 | 347 | } |
279 | - if ($usetable) print '</td></tr>'; |
|
280 | - else print '<br>'; |
|
281 | 348 | } |
282 | 349 | |
283 | 350 | // Date change |
284 | 351 | if (! empty($object->date_modification)) |
285 | 352 | { |
286 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
353 | + if ($usetable) { |
|
354 | + print '<tr><td class="titlefield">'; |
|
355 | + } |
|
287 | 356 | print $langs->trans("DateLastModification"); |
288 | - if ($usetable) print '</td><td>'; |
|
289 | - else print ': '; |
|
357 | + if ($usetable) { |
|
358 | + print '</td><td>'; |
|
359 | + } else { |
|
360 | + print ': '; |
|
361 | + } |
|
290 | 362 | print dol_print_date($object->date_modification, 'dayhour'); |
291 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_modification+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
292 | - if ($usetable) print '</td></tr>'; |
|
293 | - else print '<br>'; |
|
363 | + if ($deltadateforuser) { |
|
364 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_modification+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
365 | + } |
|
366 | + if ($usetable) { |
|
367 | + print '</td></tr>'; |
|
368 | + } else { |
|
369 | + print '<br>'; |
|
370 | + } |
|
294 | 371 | } |
295 | 372 | |
296 | 373 | // User validation (old method using already loaded object and not id is kept for backward compatibility) |
297 | 374 | if (! empty($object->user_validation) || ! empty($object->user_validation_id)) |
298 | 375 | { |
299 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
376 | + if ($usetable) { |
|
377 | + print '<tr><td class="titlefield">'; |
|
378 | + } |
|
300 | 379 | print $langs->trans("ValidatedBy"); |
301 | - if ($usetable) print '</td><td>'; |
|
302 | - else print ': '; |
|
380 | + if ($usetable) { |
|
381 | + print '</td><td>'; |
|
382 | + } else { |
|
383 | + print ': '; |
|
384 | + } |
|
303 | 385 | if (is_object($object->user_validation)) |
304 | 386 | { |
305 | - if ($object->user_validation->id) print $object->user_validation->getNomUrl(1, '', 0, 0, 0); |
|
306 | - else print $langs->trans("Unknown"); |
|
307 | - } |
|
308 | - else |
|
387 | + if ($object->user_validation->id) { |
|
388 | + print $object->user_validation->getNomUrl(1, '', 0, 0, 0); |
|
389 | + } else { |
|
390 | + print $langs->trans("Unknown"); |
|
391 | + } |
|
392 | + } else |
|
309 | 393 | { |
310 | 394 | $userstatic=new User($db); |
311 | 395 | $userstatic->fetch($object->user_validation_id ? $object->user_validation_id : $object->user_validation); |
312 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
313 | - else print $langs->trans("Unknown"); |
|
396 | + if ($userstatic->id) { |
|
397 | + print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
398 | + } else { |
|
399 | + print $langs->trans("Unknown"); |
|
400 | + } |
|
401 | + } |
|
402 | + if ($usetable) { |
|
403 | + print '</td></tr>'; |
|
404 | + } else { |
|
405 | + print '<br>'; |
|
314 | 406 | } |
315 | - if ($usetable) print '</td></tr>'; |
|
316 | - else print '<br>'; |
|
317 | 407 | } |
318 | 408 | |
319 | 409 | // Date validation |
320 | 410 | if (! empty($object->date_validation)) |
321 | 411 | { |
322 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
412 | + if ($usetable) { |
|
413 | + print '<tr><td class="titlefield">'; |
|
414 | + } |
|
323 | 415 | print $langs->trans("DateValidation"); |
324 | - if ($usetable) print '</td><td>'; |
|
325 | - else print ': '; |
|
416 | + if ($usetable) { |
|
417 | + print '</td><td>'; |
|
418 | + } else { |
|
419 | + print ': '; |
|
420 | + } |
|
326 | 421 | print dol_print_date($object->date_validation, 'dayhour'); |
327 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_validation+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
328 | - if ($usetable) print '</td></tr>'; |
|
329 | - else print '<br>'; |
|
422 | + if ($deltadateforuser) { |
|
423 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_validation+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
424 | + } |
|
425 | + if ($usetable) { |
|
426 | + print '</td></tr>'; |
|
427 | + } else { |
|
428 | + print '<br>'; |
|
429 | + } |
|
330 | 430 | } |
331 | 431 | |
332 | 432 | // User approve (old method using already loaded object and not id is kept for backward compatibility) |
333 | 433 | if (! empty($object->user_approve) || ! empty($object->user_approve_id)) |
334 | 434 | { |
335 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
435 | + if ($usetable) { |
|
436 | + print '<tr><td class="titlefield">'; |
|
437 | + } |
|
336 | 438 | print $langs->trans("ApprovedBy"); |
337 | - if ($usetable) print '</td><td>'; |
|
338 | - else print ': '; |
|
439 | + if ($usetable) { |
|
440 | + print '</td><td>'; |
|
441 | + } else { |
|
442 | + print ': '; |
|
443 | + } |
|
339 | 444 | if (is_object($object->user_approve)) |
340 | 445 | { |
341 | - if ($object->user_approve->id) print $object->user_approve->getNomUrl(1, '', 0, 0, 0); |
|
342 | - else print $langs->trans("Unknown"); |
|
343 | - } |
|
344 | - else |
|
446 | + if ($object->user_approve->id) { |
|
447 | + print $object->user_approve->getNomUrl(1, '', 0, 0, 0); |
|
448 | + } else { |
|
449 | + print $langs->trans("Unknown"); |
|
450 | + } |
|
451 | + } else |
|
345 | 452 | { |
346 | 453 | $userstatic=new User($db); |
347 | 454 | $userstatic->fetch($object->user_approve_id ? $object->user_approve_id : $object->user_approve); |
348 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
349 | - else print $langs->trans("Unknown"); |
|
455 | + if ($userstatic->id) { |
|
456 | + print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
457 | + } else { |
|
458 | + print $langs->trans("Unknown"); |
|
459 | + } |
|
460 | + } |
|
461 | + if ($usetable) { |
|
462 | + print '</td></tr>'; |
|
463 | + } else { |
|
464 | + print '<br>'; |
|
350 | 465 | } |
351 | - if ($usetable) print '</td></tr>'; |
|
352 | - else print '<br>'; |
|
353 | 466 | } |
354 | 467 | |
355 | 468 | // Date approve |
356 | 469 | if (! empty($object->date_approve)) |
357 | 470 | { |
358 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
471 | + if ($usetable) { |
|
472 | + print '<tr><td class="titlefield">'; |
|
473 | + } |
|
359 | 474 | print $langs->trans("DateApprove"); |
360 | - if ($usetable) print '</td><td>'; |
|
361 | - else print ': '; |
|
475 | + if ($usetable) { |
|
476 | + print '</td><td>'; |
|
477 | + } else { |
|
478 | + print ': '; |
|
479 | + } |
|
362 | 480 | print dol_print_date($object->date_approve, 'dayhour'); |
363 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_approve+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
364 | - if ($usetable) print '</td></tr>'; |
|
365 | - else print '<br>'; |
|
481 | + if ($deltadateforuser) { |
|
482 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_approve+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
483 | + } |
|
484 | + if ($usetable) { |
|
485 | + print '</td></tr>'; |
|
486 | + } else { |
|
487 | + print '<br>'; |
|
488 | + } |
|
366 | 489 | } |
367 | 490 | |
368 | 491 | // User approve |
369 | 492 | if (! empty($object->user_approve_id2)) |
370 | 493 | { |
371 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
494 | + if ($usetable) { |
|
495 | + print '<tr><td class="titlefield">'; |
|
496 | + } |
|
372 | 497 | print $langs->trans("ApprovedBy"); |
373 | - if ($usetable) print '</td><td>'; |
|
374 | - else print ': '; |
|
498 | + if ($usetable) { |
|
499 | + print '</td><td>'; |
|
500 | + } else { |
|
501 | + print ': '; |
|
502 | + } |
|
375 | 503 | $userstatic=new User($db); |
376 | 504 | $userstatic->fetch($object->user_approve_id2); |
377 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
378 | - else print $langs->trans("Unknown"); |
|
379 | - if ($usetable) print '</td></tr>'; |
|
380 | - else print '<br>'; |
|
505 | + if ($userstatic->id) { |
|
506 | + print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
507 | + } else { |
|
508 | + print $langs->trans("Unknown"); |
|
509 | + } |
|
510 | + if ($usetable) { |
|
511 | + print '</td></tr>'; |
|
512 | + } else { |
|
513 | + print '<br>'; |
|
514 | + } |
|
381 | 515 | } |
382 | 516 | |
383 | 517 | // Date approve |
384 | 518 | if (! empty($object->date_approve2)) |
385 | 519 | { |
386 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
520 | + if ($usetable) { |
|
521 | + print '<tr><td class="titlefield">'; |
|
522 | + } |
|
387 | 523 | print $langs->trans("DateApprove2"); |
388 | - if ($usetable) print '</td><td>'; |
|
389 | - else print ': '; |
|
524 | + if ($usetable) { |
|
525 | + print '</td><td>'; |
|
526 | + } else { |
|
527 | + print ': '; |
|
528 | + } |
|
390 | 529 | print dol_print_date($object->date_approve2, 'dayhour'); |
391 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_approve2+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
392 | - if ($usetable) print '</td></tr>'; |
|
393 | - else print '<br>'; |
|
530 | + if ($deltadateforuser) { |
|
531 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_approve2+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
532 | + } |
|
533 | + if ($usetable) { |
|
534 | + print '</td></tr>'; |
|
535 | + } else { |
|
536 | + print '<br>'; |
|
537 | + } |
|
394 | 538 | } |
395 | 539 | |
396 | 540 | // User close |
397 | 541 | if (! empty($object->user_cloture)) |
398 | 542 | { |
399 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
543 | + if ($usetable) { |
|
544 | + print '<tr><td class="titlefield">'; |
|
545 | + } |
|
400 | 546 | print $langs->trans("ClosedBy"); |
401 | - if ($usetable) print '</td><td>'; |
|
402 | - else print ': '; |
|
547 | + if ($usetable) { |
|
548 | + print '</td><td>'; |
|
549 | + } else { |
|
550 | + print ': '; |
|
551 | + } |
|
403 | 552 | if (is_object($object->user_cloture)) |
404 | 553 | { |
405 | - if ($object->user_cloture->id) print $object->user_cloture->getNomUrl(1, '', 0, 0, 0); |
|
406 | - else print $langs->trans("Unknown"); |
|
407 | - } |
|
408 | - else |
|
554 | + if ($object->user_cloture->id) { |
|
555 | + print $object->user_cloture->getNomUrl(1, '', 0, 0, 0); |
|
556 | + } else { |
|
557 | + print $langs->trans("Unknown"); |
|
558 | + } |
|
559 | + } else |
|
409 | 560 | { |
410 | 561 | $userstatic=new User($db); |
411 | 562 | $userstatic->fetch($object->user_cloture); |
412 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
413 | - else print $langs->trans("Unknown"); |
|
563 | + if ($userstatic->id) { |
|
564 | + print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
565 | + } else { |
|
566 | + print $langs->trans("Unknown"); |
|
567 | + } |
|
568 | + } |
|
569 | + if ($usetable) { |
|
570 | + print '</td></tr>'; |
|
571 | + } else { |
|
572 | + print '<br>'; |
|
414 | 573 | } |
415 | - if ($usetable) print '</td></tr>'; |
|
416 | - else print '<br>'; |
|
417 | 574 | } |
418 | 575 | |
419 | 576 | // Date close |
420 | 577 | if (! empty($object->date_cloture)) |
421 | 578 | { |
422 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
579 | + if ($usetable) { |
|
580 | + print '<tr><td class="titlefield">'; |
|
581 | + } |
|
423 | 582 | print $langs->trans("DateClosing"); |
424 | - if ($usetable) print '</td><td>'; |
|
425 | - else print ': '; |
|
583 | + if ($usetable) { |
|
584 | + print '</td><td>'; |
|
585 | + } else { |
|
586 | + print ': '; |
|
587 | + } |
|
426 | 588 | print dol_print_date($object->date_cloture, 'dayhour'); |
427 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_cloture+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
428 | - if ($usetable) print '</td></tr>'; |
|
429 | - else print '<br>'; |
|
589 | + if ($deltadateforuser) { |
|
590 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_cloture+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
591 | + } |
|
592 | + if ($usetable) { |
|
593 | + print '</td></tr>'; |
|
594 | + } else { |
|
595 | + print '<br>'; |
|
596 | + } |
|
430 | 597 | } |
431 | 598 | |
432 | 599 | // User conciliate |
433 | 600 | if (! empty($object->user_rappro)) |
434 | 601 | { |
435 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
602 | + if ($usetable) { |
|
603 | + print '<tr><td class="titlefield">'; |
|
604 | + } |
|
436 | 605 | print $langs->trans("ConciliatedBy"); |
437 | - if ($usetable) print '</td><td>'; |
|
438 | - else print ': '; |
|
606 | + if ($usetable) { |
|
607 | + print '</td><td>'; |
|
608 | + } else { |
|
609 | + print ': '; |
|
610 | + } |
|
439 | 611 | if (is_object($object->user_rappro)) |
440 | 612 | { |
441 | - if ($object->user_rappro->id) print $object->user_rappro->getNomUrl(1, '', 0, 0, 0); |
|
442 | - else print $langs->trans("Unknown"); |
|
443 | - } |
|
444 | - else |
|
613 | + if ($object->user_rappro->id) { |
|
614 | + print $object->user_rappro->getNomUrl(1, '', 0, 0, 0); |
|
615 | + } else { |
|
616 | + print $langs->trans("Unknown"); |
|
617 | + } |
|
618 | + } else |
|
445 | 619 | { |
446 | 620 | $userstatic=new User($db); |
447 | 621 | $userstatic->fetch($object->user_rappro); |
448 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
449 | - else print $langs->trans("Unknown"); |
|
622 | + if ($userstatic->id) { |
|
623 | + print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
624 | + } else { |
|
625 | + print $langs->trans("Unknown"); |
|
626 | + } |
|
627 | + } |
|
628 | + if ($usetable) { |
|
629 | + print '</td></tr>'; |
|
630 | + } else { |
|
631 | + print '<br>'; |
|
450 | 632 | } |
451 | - if ($usetable) print '</td></tr>'; |
|
452 | - else print '<br>'; |
|
453 | 633 | } |
454 | 634 | |
455 | 635 | // Date conciliate |
456 | 636 | if (! empty($object->date_rappro)) |
457 | 637 | { |
458 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
638 | + if ($usetable) { |
|
639 | + print '<tr><td class="titlefield">'; |
|
640 | + } |
|
459 | 641 | print $langs->trans("DateConciliating"); |
460 | - if ($usetable) print '</td><td>'; |
|
461 | - else print ': '; |
|
642 | + if ($usetable) { |
|
643 | + print '</td><td>'; |
|
644 | + } else { |
|
645 | + print ': '; |
|
646 | + } |
|
462 | 647 | print dol_print_date($object->date_rappro, 'dayhour'); |
463 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_rappro+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
464 | - if ($usetable) print '</td></tr>'; |
|
465 | - else print '<br>'; |
|
648 | + if ($deltadateforuser) { |
|
649 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_rappro+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
650 | + } |
|
651 | + if ($usetable) { |
|
652 | + print '</td></tr>'; |
|
653 | + } else { |
|
654 | + print '<br>'; |
|
655 | + } |
|
466 | 656 | } |
467 | 657 | |
468 | 658 | // Date send |
469 | 659 | if (! empty($object->date_envoi)) |
470 | 660 | { |
471 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
661 | + if ($usetable) { |
|
662 | + print '<tr><td class="titlefield">'; |
|
663 | + } |
|
472 | 664 | print $langs->trans("DateLastSend"); |
473 | - if ($usetable) print '</td><td>'; |
|
474 | - else print ': '; |
|
665 | + if ($usetable) { |
|
666 | + print '</td><td>'; |
|
667 | + } else { |
|
668 | + print ': '; |
|
669 | + } |
|
475 | 670 | print dol_print_date($object->date_envoi, 'dayhour'); |
476 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_envoi+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
477 | - if ($usetable) print '</td></tr>'; |
|
478 | - else print '<br>'; |
|
671 | + if ($deltadateforuser) { |
|
672 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_envoi+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
673 | + } |
|
674 | + if ($usetable) { |
|
675 | + print '</td></tr>'; |
|
676 | + } else { |
|
677 | + print '<br>'; |
|
678 | + } |
|
479 | 679 | } |
480 | 680 | |
481 | - if ($usetable) print '</table>'; |
|
482 | -} |
|
681 | + if ($usetable) { |
|
682 | + print '</table>'; |
|
683 | + } |
|
684 | + } |
|
483 | 685 | |
484 | 686 | |
485 | 687 | /** |
@@ -508,8 +710,7 @@ discard block |
||
508 | 710 | if (checkdnsrr($domain, "MX")) |
509 | 711 | { |
510 | 712 | return true; |
511 | - } |
|
512 | - else |
|
713 | + } else |
|
513 | 714 | { |
514 | 715 | return false; |
515 | 716 | } |
@@ -534,10 +735,14 @@ discard block |
||
534 | 735 | $urlregex = ''; |
535 | 736 | |
536 | 737 | // SCHEME |
537 | - if ($http) $urlregex .= "^(http:\/\/|https:\/\/)"; |
|
738 | + if ($http) { |
|
739 | + $urlregex .= "^(http:\/\/|https:\/\/)"; |
|
740 | + } |
|
538 | 741 | |
539 | 742 | // USER AND PASS |
540 | - if ($pass) $urlregex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)"; |
|
743 | + if ($pass) { |
|
744 | + $urlregex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)"; |
|
745 | + } |
|
541 | 746 | |
542 | 747 | // HOSTNAME OR IP |
543 | 748 | //$urlregex .= "[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*"; // x allowed (ex. http://localhost, http://routerlogin) |
@@ -546,13 +751,21 @@ discard block |
||
546 | 751 | //use only one of the above |
547 | 752 | |
548 | 753 | // PORT |
549 | - if ($port) $urlregex .= "(\:[0-9]{2,5})"; |
|
754 | + if ($port) { |
|
755 | + $urlregex .= "(\:[0-9]{2,5})"; |
|
756 | + } |
|
550 | 757 | // PATH |
551 | - if ($path) $urlregex .= "(\/([a-z0-9+\$_-]\.?)+)*\/"; |
|
758 | + if ($path) { |
|
759 | + $urlregex .= "(\/([a-z0-9+\$_-]\.?)+)*\/"; |
|
760 | + } |
|
552 | 761 | // GET Query |
553 | - if ($query) $urlregex .= "(\?[a-z+&\$_.-][a-z0-9;:@\/&%=+\$_.-]*)"; |
|
762 | + if ($query) { |
|
763 | + $urlregex .= "(\?[a-z+&\$_.-][a-z0-9;:@\/&%=+\$_.-]*)"; |
|
764 | + } |
|
554 | 765 | // ANCHOR |
555 | - if ($anchor) $urlregex .= "(#[a-z_.-][a-z0-9+\$_.-]*)$"; |
|
766 | + if ($anchor) { |
|
767 | + $urlregex .= "(#[a-z_.-][a-z0-9+\$_.-]*)$"; |
|
768 | + } |
|
556 | 769 | |
557 | 770 | // check |
558 | 771 | if (preg_match('/'.$urlregex.'/i', $url)) |
@@ -600,9 +813,10 @@ discard block |
||
600 | 813 | $CleanUrl = preg_replace('/^'.preg_quote($proto.$domain,'/').'/i', $newproto.strtolower($domain), $url); |
601 | 814 | |
602 | 815 | return $CleanUrl; |
816 | + } else { |
|
817 | + return $url; |
|
818 | + } |
|
603 | 819 | } |
604 | - else return $url; |
|
605 | -} |
|
606 | 820 | |
607 | 821 | |
608 | 822 | |
@@ -619,7 +833,9 @@ discard block |
||
619 | 833 | */ |
620 | 834 | function dolObfuscateEmail($mail, $replace="*", $nbreplace=8, $nbdisplaymail=4, $nbdisplaydomain=3, $displaytld=true) |
621 | 835 | { |
622 | - if(!isValidEmail($mail))return ''; |
|
836 | + if(!isValidEmail($mail)) { |
|
837 | + return ''; |
|
838 | + } |
|
623 | 839 | $tab = explode('@', $mail); |
624 | 840 | $tab2 = explode('.',$tab[1]); |
625 | 841 | $string_replace = ''; |
@@ -681,7 +897,9 @@ discard block |
||
681 | 897 | function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdoptions='') |
682 | 898 | { |
683 | 899 | $text='' ; |
684 | - if($tableMarkup) $text = '<table '.$tableoptions.'>' ; |
|
900 | + if($tableMarkup) { |
|
901 | + $text = '<table '.$tableoptions.'>' ; |
|
902 | + } |
|
685 | 903 | foreach($data as $key => $item){ |
686 | 904 | if(is_array($item)){ |
687 | 905 | $text.=array2tr($item,$troptions,$tdoptions); |
@@ -692,7 +910,9 @@ discard block |
||
692 | 910 | $text.= '</tr>' ; |
693 | 911 | } |
694 | 912 | } |
695 | - if($tableMarkup) $text.= '</table>' ; |
|
913 | + if($tableMarkup) { |
|
914 | + $text.= '</table>' ; |
|
915 | + } |
|
696 | 916 | return $text ; |
697 | 917 | } |
698 | 918 | |
@@ -716,15 +936,25 @@ discard block |
||
716 | 936 | { |
717 | 937 | global $conf,$user; |
718 | 938 | |
719 | - if (! is_object($objsoc)) $valueforccc=$objsoc; |
|
720 | - else if ($table == "commande_fournisseur" || $table == "facture_fourn" ) $valueforccc=$objsoc->code_fournisseur; |
|
721 | - else $valueforccc=$objsoc->code_client; |
|
939 | + if (! is_object($objsoc)) { |
|
940 | + $valueforccc=$objsoc; |
|
941 | + } else if ($table == "commande_fournisseur" || $table == "facture_fourn" ) { |
|
942 | + $valueforccc=$objsoc->code_fournisseur; |
|
943 | + } else { |
|
944 | + $valueforccc=$objsoc->code_client; |
|
945 | + } |
|
722 | 946 | |
723 | 947 | $sharetable = $table; |
724 | - if ($table == 'facture' || $table == 'invoice') $sharetable = 'invoicenumber'; // for getEntity function |
|
948 | + if ($table == 'facture' || $table == 'invoice') { |
|
949 | + $sharetable = 'invoicenumber'; |
|
950 | + } |
|
951 | + // for getEntity function |
|
725 | 952 | |
726 | 953 | // Clean parameters |
727 | - if ($date == '') $date=dol_now(); // We use local year and month of PHP server to search numbers |
|
954 | + if ($date == '') { |
|
955 | + $date=dol_now(); |
|
956 | + } |
|
957 | + // We use local year and month of PHP server to search numbers |
|
728 | 958 | // but we should use local year and month of user |
729 | 959 | |
730 | 960 | // For debugging |
@@ -741,8 +971,7 @@ discard block |
||
741 | 971 | $masktri=$reg[1].(! empty($reg[2])?$reg[2]:'').(! empty($reg[3])?$reg[3]:''); |
742 | 972 | $maskcounter=$reg[1]; |
743 | 973 | $hasglobalcounter=true; |
744 | - } |
|
745 | - else |
|
974 | + } else |
|
746 | 975 | { |
747 | 976 | // setting some defaults so the rest of the code won't fail if there is a third party counter |
748 | 977 | $masktri='00000'; |
@@ -752,7 +981,9 @@ discard block |
||
752 | 981 | $maskraz=-1; |
753 | 982 | $maskoffset=0; |
754 | 983 | $resetEveryMonth=false; |
755 | - if (dol_strlen($maskcounter) < 3 && empty($conf->global->MAIN_COUNTER_WITH_LESS_3_DIGITS)) return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
984 | + if (dol_strlen($maskcounter) < 3 && empty($conf->global->MAIN_COUNTER_WITH_LESS_3_DIGITS)) { |
|
985 | + return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
986 | + } |
|
756 | 987 | |
757 | 988 | // Extract value for third party mask counter |
758 | 989 | if (preg_match('/\{(c+)(0*)\}/i',$mask,$regClientRef)) |
@@ -764,9 +995,12 @@ discard block |
||
764 | 995 | $maskrefclient_clientcode=substr($valueforccc,0,dol_strlen($maskrefclient_maskclientcode));//get n first characters of client code where n is length in mask |
765 | 996 | $maskrefclient_clientcode=str_pad($maskrefclient_clientcode,dol_strlen($maskrefclient_maskclientcode),"#",STR_PAD_RIGHT);//padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode |
766 | 997 | $maskrefclient_clientcode=dol_string_nospecial($maskrefclient_clientcode);//sanitize maskrefclient_clientcode for sql insert and sql select like |
767 | - if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
998 | + if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) { |
|
999 | + return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
1000 | + } |
|
1001 | + } else { |
|
1002 | + $maskrefclient=''; |
|
768 | 1003 | } |
769 | - else $maskrefclient=''; |
|
770 | 1004 | |
771 | 1005 | // fail if there is neither a global nor a third party counter |
772 | 1006 | if (! $hasglobalcounter && ($maskrefclient_maskcounter == '')) |
@@ -780,8 +1014,7 @@ discard block |
||
780 | 1014 | $masktype=$regType[1]; |
781 | 1015 | $masktype_value=substr(preg_replace('/^TE_/','',$objsoc->typent_code),0,dol_strlen($regType[1]));// get n first characters of thirdpaty typent_code (where n is length in mask) |
782 | 1016 | $masktype_value=str_pad($masktype_value,dol_strlen($regType[1]),"#",STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask |
783 | - } |
|
784 | - else |
|
1017 | + } else |
|
785 | 1018 | { |
786 | 1019 | $masktype=''; |
787 | 1020 | $masktype_value=''; |
@@ -791,13 +1024,14 @@ discard block |
||
791 | 1024 | if (preg_match('/\{(u+)\}/i',$mask,$regType)) |
792 | 1025 | { |
793 | 1026 | $lastname = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; |
794 | - if (is_object($objuser)) $lastname = $objuser->lastname; |
|
1027 | + if (is_object($objuser)) { |
|
1028 | + $lastname = $objuser->lastname; |
|
1029 | + } |
|
795 | 1030 | |
796 | 1031 | $maskuser=$regType[1]; |
797 | 1032 | $maskuser_value=substr($lastname,0,dol_strlen($regType[1]));// get n first characters of user firstname (where n is length in mask) |
798 | 1033 | $maskuser_value=str_pad($maskuser_value,dol_strlen($regType[1]),"#",STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask |
799 | - } |
|
800 | - else |
|
1034 | + } else |
|
801 | 1035 | { |
802 | 1036 | $maskuser=''; |
803 | 1037 | $maskuser_value=''; |
@@ -844,8 +1078,12 @@ discard block |
||
844 | 1078 | //var_dump($reg); |
845 | 1079 | |
846 | 1080 | // If an offset is asked |
847 | - if (! empty($reg[2]) && preg_match('/^\+/',$reg[2])) $maskoffset=preg_replace('/^\+/','',$reg[2]); |
|
848 | - if (! empty($reg[3]) && preg_match('/^\+/',$reg[3])) $maskoffset=preg_replace('/^\+/','',$reg[3]); |
|
1081 | + if (! empty($reg[2]) && preg_match('/^\+/',$reg[2])) { |
|
1082 | + $maskoffset=preg_replace('/^\+/','',$reg[2]); |
|
1083 | + } |
|
1084 | + if (! empty($reg[3]) && preg_match('/^\+/',$reg[3])) { |
|
1085 | + $maskoffset=preg_replace('/^\+/','',$reg[3]); |
|
1086 | + } |
|
849 | 1087 | |
850 | 1088 | // Define $sqlwhere |
851 | 1089 | $sqlwhere=''; |
@@ -853,14 +1091,21 @@ discard block |
||
853 | 1091 | $yearoffsettype=false; // false: no reset, 0,-,=,+: reset at offset SOCIETE_FISCAL_MONTH_START, x=reset at offset x |
854 | 1092 | |
855 | 1093 | // If a restore to zero after a month is asked we check if there is already a value for this year. |
856 | - if (! empty($reg[2]) && preg_match('/^@/',$reg[2])) $yearoffsettype = preg_replace('/^@/','',$reg[2]); |
|
857 | - if (! empty($reg[3]) && preg_match('/^@/',$reg[3])) $yearoffsettype = preg_replace('/^@/','',$reg[3]); |
|
1094 | + if (! empty($reg[2]) && preg_match('/^@/',$reg[2])) { |
|
1095 | + $yearoffsettype = preg_replace('/^@/','',$reg[2]); |
|
1096 | + } |
|
1097 | + if (! empty($reg[3]) && preg_match('/^@/',$reg[3])) { |
|
1098 | + $yearoffsettype = preg_replace('/^@/','',$reg[3]); |
|
1099 | + } |
|
858 | 1100 | |
859 | 1101 | //print "yearoffset=".$yearoffset." yearoffsettype=".$yearoffsettype; |
860 | - if (is_numeric($yearoffsettype) && $yearoffsettype >= 1) |
|
861 | - $maskraz=$yearoffsettype; // For backward compatibility |
|
862 | - else if ($yearoffsettype === '0' || (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1)) |
|
863 | - $maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START; |
|
1102 | + if (is_numeric($yearoffsettype) && $yearoffsettype >= 1) { |
|
1103 | + $maskraz=$yearoffsettype; |
|
1104 | + } |
|
1105 | + // For backward compatibility |
|
1106 | + else if ($yearoffsettype === '0' || (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1)) { |
|
1107 | + $maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START; |
|
1108 | + } |
|
864 | 1109 | //print "maskraz=".$maskraz; // -1=no reset |
865 | 1110 | |
866 | 1111 | if ($maskraz > 0) { // A reset is required |
@@ -868,23 +1113,28 @@ discard block |
||
868 | 1113 | $maskraz = date('m', $date); |
869 | 1114 | $resetEveryMonth = true; |
870 | 1115 | } |
871 | - if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; |
|
1116 | + if ($maskraz > 12) { |
|
1117 | + return 'ErrorBadMaskBadRazMonth'; |
|
1118 | + } |
|
872 | 1119 | |
873 | 1120 | // Define posy, posm and reg |
874 | - if ($maskraz > 1) // if reset is not first month, we need month and year into mask |
|
1121 | + if ($maskraz > 1) { |
|
1122 | + // if reset is not first month, we need month and year into mask |
|
875 | 1123 | { |
876 | - if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; } |
|
877 | - elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; } |
|
878 | - else return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; |
|
879 | - |
|
880 | - if (dol_strlen($reg[$posy]) < 2) return 'ErrorCantUseRazWithYearOnOneDigit'; |
|
1124 | + if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; |
|
881 | 1125 | } |
882 | - else // if reset is for a specific month in year, we need year |
|
1126 | + $posm=3; } elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; } else { |
|
1127 | + return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; |
|
1128 | + } |
|
1129 | + |
|
1130 | + if (dol_strlen($reg[$posy]) < 2) { |
|
1131 | + return 'ErrorCantUseRazWithYearOnOneDigit'; |
|
1132 | + } |
|
1133 | + } else // if reset is for a specific month in year, we need year |
|
883 | 1134 | { |
884 | - if (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; } |
|
885 | - else if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; } |
|
886 | - else if (preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=0; } |
|
887 | - else return 'ErrorCantUseRazIfNoYearInMask'; |
|
1135 | + if (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; } else if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; } else if (preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=0; } else { |
|
1136 | + return 'ErrorCantUseRazIfNoYearInMask'; |
|
1137 | + } |
|
888 | 1138 | } |
889 | 1139 | // Define length |
890 | 1140 | $yearlen = $posy?dol_strlen($reg[$posy]):0; |
@@ -902,9 +1152,11 @@ discard block |
||
902 | 1152 | $monthcomp=$maskraz; |
903 | 1153 | $yearcomp=0; |
904 | 1154 | |
905 | - if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') // $yearoffsettype is - or + |
|
1155 | + if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') { |
|
1156 | + // $yearoffsettype is - or + |
|
906 | 1157 | { |
907 | 1158 | $currentyear=date("Y", $date); |
1159 | + } |
|
908 | 1160 | $fiscaldate=dol_mktime('0','0','0',$maskraz,'1',$currentyear); |
909 | 1161 | $newyeardate=dol_mktime('0','0','0','1','1',$currentyear); |
910 | 1162 | $nextnewyeardate=dol_mktime('0','0','0','1','1',$currentyear+1); |
@@ -914,21 +1166,32 @@ discard block |
||
914 | 1166 | if ($date >= $fiscaldate) |
915 | 1167 | { |
916 | 1168 | // If before of next new year date |
917 | - if ($date < $nextnewyeardate && $yearoffsettype == '+') $yearoffset=1; |
|
1169 | + if ($date < $nextnewyeardate && $yearoffsettype == '+') { |
|
1170 | + $yearoffset=1; |
|
1171 | + } |
|
918 | 1172 | } |
919 | 1173 | // If after or equal of current new year date |
920 | - else if ($date >= $newyeardate && $yearoffsettype == '-') $yearoffset=-1; |
|
1174 | + else if ($date >= $newyeardate && $yearoffsettype == '-') { |
|
1175 | + $yearoffset=-1; |
|
1176 | + } |
|
921 | 1177 | } |
922 | 1178 | // For backward compatibility |
923 | 1179 | else if (date("m",$date) < $maskraz && empty($resetEveryMonth)) { $yearoffset=-1; } // If current month lower that month of return to zero, year is previous year |
924 | 1180 | |
925 | - if ($yearlen == 4) $yearcomp=sprintf("%04d",date("Y",$date)+$yearoffset); |
|
926 | - elseif ($yearlen == 2) $yearcomp=sprintf("%02d",date("y",$date)+$yearoffset); |
|
927 | - elseif ($yearlen == 1) $yearcomp=substr(date("y",$date),2,1)+$yearoffset; |
|
928 | - if ($monthcomp > 1 && empty($resetEveryMonth)) // Test with month is useless if monthcomp = 0 or 1 (0 is same as 1) (regis: $monthcomp can't equal 0) |
|
1181 | + if ($yearlen == 4) { |
|
1182 | + $yearcomp=sprintf("%04d",date("Y",$date)+$yearoffset); |
|
1183 | + } elseif ($yearlen == 2) { |
|
1184 | + $yearcomp=sprintf("%02d",date("y",$date)+$yearoffset); |
|
1185 | + } elseif ($yearlen == 1) { |
|
1186 | + $yearcomp=substr(date("y",$date),2,1)+$yearoffset; |
|
1187 | + } |
|
1188 | + if ($monthcomp > 1 && empty($resetEveryMonth)) { |
|
1189 | + // Test with month is useless if monthcomp = 0 or 1 (0 is same as 1) (regis: $monthcomp can't equal 0) |
|
929 | 1190 | { |
930 | 1191 | if ($yearlen == 4) $yearcomp1=sprintf("%04d",date("Y",$date)+$yearoffset+1); |
931 | - elseif ($yearlen == 2) $yearcomp1=sprintf("%02d",date("y",$date)+$yearoffset+1); |
|
1192 | + } elseif ($yearlen == 2) { |
|
1193 | + $yearcomp1=sprintf("%02d",date("y",$date)+$yearoffset+1); |
|
1194 | + } |
|
932 | 1195 | |
933 | 1196 | $sqlwhere.="("; |
934 | 1197 | $sqlwhere.=" (SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'"; |
@@ -937,13 +1200,11 @@ discard block |
||
937 | 1200 | $sqlwhere.=" (SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp1."'"; |
938 | 1201 | $sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") < '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."') "; |
939 | 1202 | $sqlwhere.=')'; |
940 | - } |
|
941 | - else if ($resetEveryMonth) |
|
1203 | + } else if ($resetEveryMonth) |
|
942 | 1204 | { |
943 | 1205 | $sqlwhere.="(SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'"; |
944 | 1206 | $sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") = '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."')"; |
945 | - } |
|
946 | - else // reset is done on january |
|
1207 | + } else // reset is done on january |
|
947 | 1208 | { |
948 | 1209 | $sqlwhere.='(SUBSTRING('.$field.', '.$yearpos.', '.$yearlen.") = '".$yearcomp."')"; |
949 | 1210 | } |
@@ -955,12 +1216,13 @@ discard block |
||
955 | 1216 | if (function_exists('mb_strrpos')) |
956 | 1217 | { |
957 | 1218 | $posnumstart=mb_strrpos($maskwithnocode,$maskcounter, 'UTF-8'); |
958 | - } |
|
959 | - else |
|
1219 | + } else |
|
960 | 1220 | { |
961 | 1221 | $posnumstart=strrpos($maskwithnocode,$maskcounter); |
962 | 1222 | } // Pos of counter in final string (from 0 to ...) |
963 | - if ($posnumstart < 0) return 'ErrorBadMaskFailedToLocatePosOfSequence'; |
|
1223 | + if ($posnumstart < 0) { |
|
1224 | + return 'ErrorBadMaskFailedToLocatePosOfSequence'; |
|
1225 | + } |
|
964 | 1226 | $sqlstring='SUBSTRING('.$field.', '.($posnumstart+1).', '.dol_strlen($maskcounter).')'; |
965 | 1227 | |
966 | 1228 | // Define $maskLike |
@@ -973,9 +1235,15 @@ discard block |
||
973 | 1235 | $maskLike = preg_replace('/\{mm\}/i','__',$maskLike); |
974 | 1236 | $maskLike = preg_replace('/\{dd\}/i','__',$maskLike); |
975 | 1237 | $maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'),str_pad("",dol_strlen($maskcounter),"_"),$maskLike); |
976 | - if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",dol_strlen($maskrefclient),"_"),$maskLike); |
|
977 | - if ($masktype) $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'),$masktype_value,$maskLike); |
|
978 | - if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'),$maskuser_value,$maskLike); |
|
1238 | + if ($maskrefclient) { |
|
1239 | + $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",dol_strlen($maskrefclient),"_"),$maskLike); |
|
1240 | + } |
|
1241 | + if ($masktype) { |
|
1242 | + $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'),$masktype_value,$maskLike); |
|
1243 | + } |
|
1244 | + if ($maskuser) { |
|
1245 | + $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'),$maskuser_value,$maskLike); |
|
1246 | + } |
|
979 | 1247 | foreach($maskperso as $key => $val) |
980 | 1248 | { |
981 | 1249 | $maskLike = str_replace(dol_string_nospecial($maskperso[$key]),$maskpersonew[$key],$maskLike); |
@@ -987,12 +1255,18 @@ discard block |
||
987 | 1255 | $sql.= " FROM ".MAIN_DB_PREFIX.$table; |
988 | 1256 | $sql.= " WHERE ".$field." LIKE '".$maskLike."'"; |
989 | 1257 | $sql.= " AND ".$field." NOT LIKE '(PROV%)'"; |
990 | - if ($bentityon) // only if entity enable |
|
1258 | + if ($bentityon) { |
|
1259 | + // only if entity enable |
|
991 | 1260 | $sql.= " AND entity IN (".getEntity($sharetable).")"; |
992 | - else if (! empty($forceentity)) |
|
993 | - $sql.= " AND entity IN (".$forceentity.")"; |
|
994 | - if ($where) $sql.=$where; |
|
995 | - if ($sqlwhere) $sql.=' AND '.$sqlwhere; |
|
1261 | + } else if (! empty($forceentity)) { |
|
1262 | + $sql.= " AND entity IN (".$forceentity.")"; |
|
1263 | + } |
|
1264 | + if ($where) { |
|
1265 | + $sql.=$where; |
|
1266 | + } |
|
1267 | + if ($sqlwhere) { |
|
1268 | + $sql.=' AND '.$sqlwhere; |
|
1269 | + } |
|
996 | 1270 | |
997 | 1271 | //print $sql.'<br>'; |
998 | 1272 | dol_syslog("functions2::get_next_value mode=".$mode."", LOG_DEBUG); |
@@ -1001,21 +1275,26 @@ discard block |
||
1001 | 1275 | { |
1002 | 1276 | $obj = $db->fetch_object($resql); |
1003 | 1277 | $counter = $obj->val; |
1278 | + } else { |
|
1279 | + dol_print_error($db); |
|
1004 | 1280 | } |
1005 | - else dol_print_error($db); |
|
1006 | 1281 | |
1007 | 1282 | // Check if we must force counter to maskoffset |
1008 | - if (empty($counter)) $counter=$maskoffset; |
|
1009 | - else if (preg_match('/[^0-9]/i',$counter)) |
|
1283 | + if (empty($counter)) { |
|
1284 | + $counter=$maskoffset; |
|
1285 | + } else if (preg_match('/[^0-9]/i',$counter)) |
|
1010 | 1286 | { |
1011 | 1287 | $counter=0; |
1012 | 1288 | dol_syslog("Error, the last counter found is '".$counter."' so is not a numeric value. We will restart to 1.", LOG_ERR); |
1289 | + } else if ($counter < $maskoffset && empty($conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) { |
|
1290 | + $counter=$maskoffset; |
|
1013 | 1291 | } |
1014 | - else if ($counter < $maskoffset && empty($conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) $counter=$maskoffset; |
|
1015 | 1292 | |
1016 | - if ($mode == 'last') // We found value for counter = last counter value. Now need to get corresponding ref of invoice. |
|
1293 | + if ($mode == 'last') { |
|
1294 | + // We found value for counter = last counter value. Now need to get corresponding ref of invoice. |
|
1017 | 1295 | { |
1018 | 1296 | $counterpadded=str_pad($counter,dol_strlen($maskcounter),"0",STR_PAD_LEFT); |
1297 | + } |
|
1019 | 1298 | |
1020 | 1299 | // Define $maskLike |
1021 | 1300 | $maskLike = dol_string_nospecial($mask); |
@@ -1027,34 +1306,48 @@ discard block |
||
1027 | 1306 | $maskLike = preg_replace('/\{mm\}/i','__',$maskLike); |
1028 | 1307 | $maskLike = preg_replace('/\{dd\}/i','__',$maskLike); |
1029 | 1308 | $maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'),$counterpadded,$maskLike); |
1030 | - if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",dol_strlen($maskrefclient),"_"),$maskLike); |
|
1031 | - if ($masktype) $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'),$masktype_value,$maskLike); |
|
1032 | - if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'),$maskuser_value,$maskLike); |
|
1309 | + if ($maskrefclient) { |
|
1310 | + $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",dol_strlen($maskrefclient),"_"),$maskLike); |
|
1311 | + } |
|
1312 | + if ($masktype) { |
|
1313 | + $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'),$masktype_value,$maskLike); |
|
1314 | + } |
|
1315 | + if ($maskuser) { |
|
1316 | + $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'),$maskuser_value,$maskLike); |
|
1317 | + } |
|
1033 | 1318 | |
1034 | 1319 | $ref=''; |
1035 | 1320 | $sql = "SELECT ".$field." as ref"; |
1036 | 1321 | $sql.= " FROM ".MAIN_DB_PREFIX.$table; |
1037 | 1322 | $sql.= " WHERE ".$field." LIKE '".$maskLike."'"; |
1038 | 1323 | $sql.= " AND ".$field." NOT LIKE '%PROV%'"; |
1039 | - if ($bentityon) // only if entity enable |
|
1324 | + if ($bentityon) { |
|
1325 | + // only if entity enable |
|
1040 | 1326 | $sql.= " AND entity IN (".getEntity($sharetable).")"; |
1041 | - else if (! empty($forceentity)) |
|
1042 | - $sql.= " AND entity IN (".$forceentity.")"; |
|
1043 | - if ($where) $sql.=$where; |
|
1044 | - if ($sqlwhere) $sql.=' AND '.$sqlwhere; |
|
1327 | + } else if (! empty($forceentity)) { |
|
1328 | + $sql.= " AND entity IN (".$forceentity.")"; |
|
1329 | + } |
|
1330 | + if ($where) { |
|
1331 | + $sql.=$where; |
|
1332 | + } |
|
1333 | + if ($sqlwhere) { |
|
1334 | + $sql.=' AND '.$sqlwhere; |
|
1335 | + } |
|
1045 | 1336 | |
1046 | 1337 | dol_syslog("functions2::get_next_value mode=".$mode."", LOG_DEBUG); |
1047 | 1338 | $resql=$db->query($sql); |
1048 | 1339 | if ($resql) |
1049 | 1340 | { |
1050 | 1341 | $obj = $db->fetch_object($resql); |
1051 | - if ($obj) $ref = $obj->ref; |
|
1342 | + if ($obj) { |
|
1343 | + $ref = $obj->ref; |
|
1344 | + } |
|
1345 | + } else { |
|
1346 | + dol_print_error($db); |
|
1052 | 1347 | } |
1053 | - else dol_print_error($db); |
|
1054 | 1348 | |
1055 | 1349 | $numFinal=$ref; |
1056 | - } |
|
1057 | - else if ($mode == 'next') |
|
1350 | + } else if ($mode == 'next') |
|
1058 | 1351 | { |
1059 | 1352 | $counter++; |
1060 | 1353 | |
@@ -1070,7 +1363,9 @@ discard block |
||
1070 | 1363 | |
1071 | 1364 | // Define $sqlstring |
1072 | 1365 | $maskrefclient_posnumstart=strpos($maskwithnocode,$maskrefclient_maskcounter,strpos($maskwithnocode,$maskrefclient)); // Pos of counter in final string (from 0 to ...) |
1073 | - if ($maskrefclient_posnumstart <= 0) return 'ErrorBadMask'; |
|
1366 | + if ($maskrefclient_posnumstart <= 0) { |
|
1367 | + return 'ErrorBadMask'; |
|
1368 | + } |
|
1074 | 1369 | $maskrefclient_sqlstring='SUBSTRING('.$field.', '.($maskrefclient_posnumstart+1).', '.dol_strlen($maskrefclient_maskcounter).')'; |
1075 | 1370 | //print "x".$sqlstring; |
1076 | 1371 | |
@@ -1092,12 +1387,20 @@ discard block |
||
1092 | 1387 | $maskrefclient_sql.= " FROM ".MAIN_DB_PREFIX.$table; |
1093 | 1388 | //$sql.= " WHERE ".$field." not like '(%'"; |
1094 | 1389 | $maskrefclient_sql.= " WHERE ".$field." LIKE '".$maskrefclient_maskLike."'"; |
1095 | - if ($bentityon) // only if entity enable |
|
1390 | + if ($bentityon) { |
|
1391 | + // only if entity enable |
|
1096 | 1392 | $maskrefclient_sql.= " AND entity IN (".getEntity($sharetable).")"; |
1097 | - else if (! empty($forceentity)) |
|
1098 | - $sql.= " AND entity IN (".$forceentity.")"; |
|
1099 | - if ($where) $maskrefclient_sql.=$where; //use the same optional where as general mask |
|
1100 | - if ($sqlwhere) $maskrefclient_sql.=' AND '.$sqlwhere; //use the same sqlwhere as general mask |
|
1393 | + } else if (! empty($forceentity)) { |
|
1394 | + $sql.= " AND entity IN (".$forceentity.")"; |
|
1395 | + } |
|
1396 | + if ($where) { |
|
1397 | + $maskrefclient_sql.=$where; |
|
1398 | + } |
|
1399 | + //use the same optional where as general mask |
|
1400 | + if ($sqlwhere) { |
|
1401 | + $maskrefclient_sql.=' AND '.$sqlwhere; |
|
1402 | + } |
|
1403 | + //use the same sqlwhere as general mask |
|
1101 | 1404 | $maskrefclient_sql.=' AND (SUBSTRING('.$field.', '.(strpos($maskwithnocode,$maskrefclient)+1).', '.dol_strlen($maskrefclient_maskclientcode).")='".$maskrefclient_clientcode."')"; |
1102 | 1405 | |
1103 | 1406 | dol_syslog("functions2::get_next_value maskrefclient", LOG_DEBUG); |
@@ -1106,10 +1409,13 @@ discard block |
||
1106 | 1409 | { |
1107 | 1410 | $maskrefclient_obj = $db->fetch_object($maskrefclient_resql); |
1108 | 1411 | $maskrefclient_counter = $maskrefclient_obj->val; |
1412 | + } else { |
|
1413 | + dol_print_error($db); |
|
1109 | 1414 | } |
1110 | - else dol_print_error($db); |
|
1111 | 1415 | |
1112 | - if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i',$maskrefclient_counter)) $maskrefclient_counter=$maskrefclient_maskoffset; |
|
1416 | + if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i',$maskrefclient_counter)) { |
|
1417 | + $maskrefclient_counter=$maskrefclient_maskoffset; |
|
1418 | + } |
|
1113 | 1419 | $maskrefclient_counter++; |
1114 | 1420 | } |
1115 | 1421 | |
@@ -1117,13 +1423,14 @@ discard block |
||
1117 | 1423 | $numFinal = $mask; |
1118 | 1424 | |
1119 | 1425 | // We replace special codes except refclient |
1120 | - if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') // yearoffsettype is - or +, so we don't want current year |
|
1426 | + if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') { |
|
1427 | + // yearoffsettype is - or +, so we don't want current year |
|
1121 | 1428 | { |
1122 | 1429 | $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date)+$yearoffset, $numFinal); |
1430 | + } |
|
1123 | 1431 | $numFinal = preg_replace('/\{yy\}/i', date("y",$date)+$yearoffset, $numFinal); |
1124 | 1432 | $numFinal = preg_replace('/\{y\}/i', substr(date("y",$date),1,1)+$yearoffset, $numFinal); |
1125 | - } |
|
1126 | - else // we want yyyy to be current year |
|
1433 | + } else // we want yyyy to be current year |
|
1127 | 1434 | { |
1128 | 1435 | $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date), $numFinal); |
1129 | 1436 | $numFinal = preg_replace('/\{yy\}/i', date("y",$date), $numFinal); |
@@ -1180,7 +1487,9 @@ discard block |
||
1180 | 1487 | { |
1181 | 1488 | $string = " ".$string; |
1182 | 1489 | $ini = strpos($string,$start); |
1183 | - if ($ini == 0) return ""; |
|
1490 | + if ($ini == 0) { |
|
1491 | + return ""; |
|
1492 | + } |
|
1184 | 1493 | $ini += strlen($start); |
1185 | 1494 | $len = strpos($string,$end,$ini) - $ini; |
1186 | 1495 | return substr($string,$ini,$len); |
@@ -1204,8 +1513,7 @@ discard block |
||
1204 | 1513 | $masktri=$reg[1].(isset($reg[2])?$reg[2]:'').(isset($reg[3])?$reg[3]:''); |
1205 | 1514 | $maskcounter=$reg[1]; |
1206 | 1515 | $hasglobalcounter=true; |
1207 | - } |
|
1208 | - else |
|
1516 | + } else |
|
1209 | 1517 | { |
1210 | 1518 | // setting some defaults so the rest of the code won't fail if there is a third party counter |
1211 | 1519 | $masktri='00000'; |
@@ -1214,7 +1522,9 @@ discard block |
||
1214 | 1522 | |
1215 | 1523 | $maskraz=-1; |
1216 | 1524 | $maskoffset=0; |
1217 | - if (dol_strlen($maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
1525 | + if (dol_strlen($maskcounter) < 3) { |
|
1526 | + return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
1527 | + } |
|
1218 | 1528 | |
1219 | 1529 | // Extract value for third party mask counter |
1220 | 1530 | if (preg_match('/\{(c+)(0*)\}/i',$mask,$regClientRef)) |
@@ -1226,9 +1536,12 @@ discard block |
||
1226 | 1536 | $maskrefclient_clientcode=substr('',0,dol_strlen($maskrefclient_maskclientcode));//get n first characters of client code to form maskrefclient_clientcode |
1227 | 1537 | $maskrefclient_clientcode=str_pad($maskrefclient_clientcode,dol_strlen($maskrefclient_maskclientcode),"#",STR_PAD_RIGHT);//padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode |
1228 | 1538 | $maskrefclient_clientcode=dol_string_nospecial($maskrefclient_clientcode);//sanitize maskrefclient_clientcode for sql insert and sql select like |
1229 | - if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
1539 | + if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) { |
|
1540 | + return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
1541 | + } |
|
1542 | + } else { |
|
1543 | + $maskrefclient=''; |
|
1230 | 1544 | } |
1231 | - else $maskrefclient=''; |
|
1232 | 1545 | |
1233 | 1546 | // fail if there is neither a global nor a third party counter |
1234 | 1547 | if (! $hasglobalcounter && ($maskrefclient_maskcounter == '')) |
@@ -1250,21 +1563,35 @@ discard block |
||
1250 | 1563 | //print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n<br>"; |
1251 | 1564 | |
1252 | 1565 | // If an offset is asked |
1253 | - if (! empty($reg[2]) && preg_match('/^\+/',$reg[2])) $maskoffset=preg_replace('/^\+/','',$reg[2]); |
|
1254 | - if (! empty($reg[3]) && preg_match('/^\+/',$reg[3])) $maskoffset=preg_replace('/^\+/','',$reg[3]); |
|
1566 | + if (! empty($reg[2]) && preg_match('/^\+/',$reg[2])) { |
|
1567 | + $maskoffset=preg_replace('/^\+/','',$reg[2]); |
|
1568 | + } |
|
1569 | + if (! empty($reg[3]) && preg_match('/^\+/',$reg[3])) { |
|
1570 | + $maskoffset=preg_replace('/^\+/','',$reg[3]); |
|
1571 | + } |
|
1255 | 1572 | |
1256 | 1573 | // Define $sqlwhere |
1257 | 1574 | |
1258 | 1575 | // If a restore to zero after a month is asked we check if there is already a value for this year. |
1259 | - if (! empty($reg[2]) && preg_match('/^@/',$reg[2])) $maskraz=preg_replace('/^@/','',$reg[2]); |
|
1260 | - if (! empty($reg[3]) && preg_match('/^@/',$reg[3])) $maskraz=preg_replace('/^@/','',$reg[3]); |
|
1576 | + if (! empty($reg[2]) && preg_match('/^@/',$reg[2])) { |
|
1577 | + $maskraz=preg_replace('/^@/','',$reg[2]); |
|
1578 | + } |
|
1579 | + if (! empty($reg[3]) && preg_match('/^@/',$reg[3])) { |
|
1580 | + $maskraz=preg_replace('/^@/','',$reg[3]); |
|
1581 | + } |
|
1261 | 1582 | if ($maskraz >= 0) |
1262 | 1583 | { |
1263 | - if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; |
|
1584 | + if ($maskraz > 12) { |
|
1585 | + return 'ErrorBadMaskBadRazMonth'; |
|
1586 | + } |
|
1264 | 1587 | |
1265 | 1588 | // Define reg |
1266 | - if ($maskraz > 1 && ! preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; |
|
1267 | - if ($maskraz <= 1 && ! preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) return 'ErrorCantUseRazIfNoYearInMask'; |
|
1589 | + if ($maskraz > 1 && ! preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { |
|
1590 | + return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; |
|
1591 | + } |
|
1592 | + if ($maskraz <= 1 && ! preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) { |
|
1593 | + return 'ErrorCantUseRazIfNoYearInMask'; |
|
1594 | + } |
|
1268 | 1595 | //print "x".$maskwithonlyymcode." ".$maskraz; |
1269 | 1596 | } |
1270 | 1597 | //print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset."<br>\n"; |
@@ -1274,7 +1601,9 @@ discard block |
||
1274 | 1601 | |
1275 | 1602 | // Check length |
1276 | 1603 | $len=dol_strlen($maskwithnocode); |
1277 | - if (dol_strlen($value) != $len) $result=-1; |
|
1604 | + if (dol_strlen($value) != $len) { |
|
1605 | + $result=-1; |
|
1606 | + } |
|
1278 | 1607 | |
1279 | 1608 | // Define $maskLike |
1280 | 1609 | /* seems not used |
@@ -1355,29 +1684,37 @@ discard block |
||
1355 | 1684 | */ |
1356 | 1685 | |
1357 | 1686 | // Definition du Jeudi de la semaine |
1358 | - if (date("w",mktime(12,0,0,$mois,$jour,$annee))==0) // Dimanche |
|
1687 | + if (date("w",mktime(12,0,0,$mois,$jour,$annee))==0) { |
|
1688 | + // Dimanche |
|
1359 | 1689 | $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-3*24*60*60; |
1360 | - else if (date("w",mktime(12,0,0,$mois,$jour,$annee))<4) // du Lundi au Mercredi |
|
1690 | + } else if (date("w",mktime(12,0,0,$mois,$jour,$annee))<4) { |
|
1691 | + // du Lundi au Mercredi |
|
1361 | 1692 | $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)+(4-date("w",mktime(12,0,0,$mois,$jour,$annee)))*24*60*60; |
1362 | - else if (date("w",mktime(12,0,0,$mois,$jour,$annee))>4) // du Vendredi au Samedi |
|
1693 | + } else if (date("w",mktime(12,0,0,$mois,$jour,$annee))>4) { |
|
1694 | + // du Vendredi au Samedi |
|
1363 | 1695 | $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-(date("w",mktime(12,0,0,$mois,$jour,$annee))-4)*24*60*60; |
1364 | - else // Jeudi |
|
1696 | + } else { |
|
1697 | + // Jeudi |
|
1365 | 1698 | $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee); |
1699 | + } |
|
1366 | 1700 | |
1367 | 1701 | // Definition du premier Jeudi de l'annee |
1368 | - if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==0) // Dimanche |
|
1702 | + if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==0) { |
|
1703 | + // Dimanche |
|
1369 | 1704 | { |
1370 | 1705 | $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+4*24*60*60; |
1371 | 1706 | } |
1372 | - else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))<4) // du Lundi au Mercredi |
|
1707 | + } else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))<4) { |
|
1708 | + // du Lundi au Mercredi |
|
1373 | 1709 | { |
1374 | 1710 | $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+(4-date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine))))*24*60*60; |
1375 | 1711 | } |
1376 | - else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))>4) // du Vendredi au Samedi |
|
1712 | + } else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))>4) { |
|
1713 | + // du Vendredi au Samedi |
|
1377 | 1714 | { |
1378 | 1715 | $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+(7-(date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))-4))*24*60*60; |
1379 | 1716 | } |
1380 | - else // Jeudi |
|
1717 | + } else // Jeudi |
|
1381 | 1718 | { |
1382 | 1719 | $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine)); |
1383 | 1720 | } |
@@ -1398,8 +1735,7 @@ discard block |
||
1398 | 1735 | if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==4 || (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==3 && date("z",mktime(12,0,0,12,31,date("Y",$jeudiSemaine)))==365)) |
1399 | 1736 | { |
1400 | 1737 | $numeroSemaine = 53; |
1401 | - } |
|
1402 | - else |
|
1738 | + } else |
|
1403 | 1739 | { |
1404 | 1740 | $numeroSemaine = 1; |
1405 | 1741 | } |
@@ -1458,7 +1794,9 @@ discard block |
||
1458 | 1794 | function dol_set_user_param($db, $conf, &$user, $tab) |
1459 | 1795 | { |
1460 | 1796 | // Verification parametres |
1461 | - if (count($tab) < 1) return -1; |
|
1797 | + if (count($tab) < 1) { |
|
1798 | + return -1; |
|
1799 | + } |
|
1462 | 1800 | |
1463 | 1801 | $db->begin(); |
1464 | 1802 | |
@@ -1470,7 +1808,9 @@ discard block |
||
1470 | 1808 | $i=0; |
1471 | 1809 | foreach ($tab as $key => $value) |
1472 | 1810 | { |
1473 | - if ($i > 0) $sql.=','; |
|
1811 | + if ($i > 0) { |
|
1812 | + $sql.=','; |
|
1813 | + } |
|
1474 | 1814 | $sql.="'".$db->escape($key)."'"; |
1475 | 1815 | $i++; |
1476 | 1816 | } |
@@ -1504,8 +1844,7 @@ discard block |
||
1504 | 1844 | } |
1505 | 1845 | $user->conf->$key = $value; |
1506 | 1846 | //print "key=".$key." user->conf->key=".$user->conf->$key; |
1507 | - } |
|
1508 | - else |
|
1847 | + } else |
|
1509 | 1848 | { |
1510 | 1849 | unset($user->conf->$key); |
1511 | 1850 | } |
@@ -1528,8 +1867,7 @@ discard block |
||
1528 | 1867 | if ($reduction == 100) |
1529 | 1868 | { |
1530 | 1869 | $string = $langs->transnoentities("Offered"); |
1531 | - } |
|
1532 | - else |
|
1870 | + } else |
|
1533 | 1871 | { |
1534 | 1872 | $string = vatrate($reduction,true); |
1535 | 1873 | } |
@@ -1616,9 +1954,11 @@ discard block |
||
1616 | 1954 | |
1617 | 1955 | // If this generation module needs to scan a directory, then description field is filled |
1618 | 1956 | // with the constant that contains list of directories to scan (COMPANY_ADDON_PDF_ODT_PATH, ...). |
1619 | - if (! empty($obj->description)) // A list of directories to scan is defined |
|
1957 | + if (! empty($obj->description)) { |
|
1958 | + // A list of directories to scan is defined |
|
1620 | 1959 | { |
1621 | 1960 | include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
1961 | + } |
|
1622 | 1962 | |
1623 | 1963 | $const=$obj->description; |
1624 | 1964 | //irtoscan.=($dirtoscan?',':'').preg_replace('/[\r\n]+/',',',trim($conf->global->$const)); |
@@ -1637,7 +1977,9 @@ discard block |
||
1637 | 1977 | { |
1638 | 1978 | // all type of template is allowed |
1639 | 1979 | $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0); |
1640 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
1980 | + if (count($tmpfiles)) { |
|
1981 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
1982 | + } |
|
1641 | 1983 | } |
1642 | 1984 | } |
1643 | 1985 | |
@@ -1648,40 +1990,41 @@ discard block |
||
1648 | 1990 | $max=($maxfilenamelength?$maxfilenamelength:28); |
1649 | 1991 | $liste[$obj->id.':'.$record['fullname']]=dol_trunc($record['name'],$max,'middle'); |
1650 | 1992 | } |
1651 | - } |
|
1652 | - else |
|
1993 | + } else |
|
1653 | 1994 | { |
1654 | 1995 | $liste[0]=$obj->label.': '.$langs->trans("None"); |
1655 | 1996 | } |
1656 | - } |
|
1657 | - else |
|
1997 | + } else |
|
1658 | 1998 | { |
1659 | - if ($type == 'member' && $obj->lib == 'standard') // Special case, if member template, we add variant per format |
|
1999 | + if ($type == 'member' && $obj->lib == 'standard') { |
|
2000 | + // Special case, if member template, we add variant per format |
|
1660 | 2001 | { |
1661 | 2002 | global $_Avery_Labels; |
2003 | + } |
|
1662 | 2004 | include_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; |
1663 | 2005 | foreach($_Avery_Labels as $key => $val) |
1664 | 2006 | { |
1665 | 2007 | $liste[$obj->id.':'.$key]=($obj->label?$obj->label:$obj->lib).' '.$val['name']; |
1666 | 2008 | } |
1667 | - } |
|
1668 | - else // Common usage |
|
2009 | + } else // Common usage |
|
1669 | 2010 | { |
1670 | 2011 | $liste[$obj->id]=$obj->label?$obj->label:$obj->lib; |
1671 | 2012 | } |
1672 | 2013 | } |
1673 | 2014 | $i++; |
1674 | 2015 | } |
1675 | - } |
|
1676 | - else |
|
2016 | + } else |
|
1677 | 2017 | { |
1678 | 2018 | dol_print_error($db); |
1679 | 2019 | return -1; |
1680 | 2020 | } |
1681 | 2021 | |
1682 | - if ($found) return $liste; |
|
1683 | - else return 0; |
|
1684 | -} |
|
2022 | + if ($found) { |
|
2023 | + return $liste; |
|
2024 | + } else { |
|
2025 | + return 0; |
|
2026 | + } |
|
2027 | + } |
|
1685 | 2028 | |
1686 | 2029 | /** |
1687 | 2030 | * This function evaluates a string that should be a valid IPv4 |
@@ -1696,10 +2039,14 @@ discard block |
||
1696 | 2039 | if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
1697 | 2040 | |
1698 | 2041 | // Then we test if it is a private range |
1699 | - if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) return 2; |
|
2042 | + if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) { |
|
2043 | + return 2; |
|
2044 | + } |
|
1700 | 2045 | |
1701 | 2046 | // Then we test if it is a reserved range |
1702 | - if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) return 0; |
|
2047 | + if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) { |
|
2048 | + return 0; |
|
2049 | + } |
|
1703 | 2050 | |
1704 | 2051 | return 1; |
1705 | 2052 | } |
@@ -1752,8 +2099,7 @@ discard block |
||
1752 | 2099 | 'proxy_password' => $proxypass, |
1753 | 2100 | 'trace' => 1 |
1754 | 2101 | ); |
1755 | - } |
|
1756 | - else |
|
2102 | + } else |
|
1757 | 2103 | { |
1758 | 2104 | $params=array('connection_timeout'=>$timeout, |
1759 | 2105 | 'response_timeout'=>$response_timeout, |
@@ -1860,14 +2206,12 @@ discard block |
||
1860 | 2206 | $classname='FactureFournisseur'; |
1861 | 2207 | $classpath = 'fourn/class'; |
1862 | 2208 | $module='fournisseur'; |
1863 | - } |
|
1864 | - elseif ($objecttype == 'order_supplier') { |
|
2209 | + } elseif ($objecttype == 'order_supplier') { |
|
1865 | 2210 | $classfile = 'fournisseur.commande'; |
1866 | 2211 | $classname='CommandeFournisseur'; |
1867 | 2212 | $classpath = 'fourn/class'; |
1868 | 2213 | $module='fournisseur'; |
1869 | - } |
|
1870 | - elseif ($objecttype == 'stock') { |
|
2214 | + } elseif ($objecttype == 'stock') { |
|
1871 | 2215 | $classpath = 'product/stock/class'; |
1872 | 2216 | $classfile='entrepot'; |
1873 | 2217 | $classname='Entrepot'; |
@@ -1887,8 +2231,9 @@ discard block |
||
1887 | 2231 | $ret=$langs->trans('Deleted'); |
1888 | 2232 | } |
1889 | 2233 | unset($object); |
2234 | + } else { |
|
2235 | + dol_syslog("Class with classname ".$classname." is unknown even after the include", LOG_ERR); |
|
1890 | 2236 | } |
1891 | - else dol_syslog("Class with classname ".$classname." is unknown even after the include", LOG_ERR); |
|
1892 | 2237 | } |
1893 | 2238 | } |
1894 | 2239 | return $ret; |
@@ -1920,11 +2265,12 @@ discard block |
||
1920 | 2265 | { |
1921 | 2266 | $obj = $db->fetch_object($resql); |
1922 | 2267 | $listofid[]=$obj->rowid; |
1923 | - if ($obj->parent_id > 0) $listofparentid[$obj->rowid]=$obj->parent_id; |
|
2268 | + if ($obj->parent_id > 0) { |
|
2269 | + $listofparentid[$obj->rowid]=$obj->parent_id; |
|
2270 | + } |
|
1924 | 2271 | $i++; |
1925 | 2272 | } |
1926 | - } |
|
1927 | - else |
|
2273 | + } else |
|
1928 | 2274 | { |
1929 | 2275 | dol_print_error($db); |
1930 | 2276 | } |
@@ -1959,9 +2305,11 @@ discard block |
||
1959 | 2305 | while ($cursor > 0) |
1960 | 2306 | { |
1961 | 2307 | $arrayidparsed[$cursor]=1; |
1962 | - if ($arrayidparsed[$listofparentid[$cursor]]) // We detect a loop. A record with a parent that was already into child |
|
2308 | + if ($arrayidparsed[$listofparentid[$cursor]]) { |
|
2309 | + // We detect a loop. A record with a parent that was already into child |
|
1963 | 2310 | { |
1964 | 2311 | print 'Found a loop between id '.$id.' - '.$cursor.'<br>'; |
2312 | + } |
|
1965 | 2313 | unset($arrayidparsed); |
1966 | 2314 | $listofidtoclean[$cursor]=$id; |
1967 | 2315 | break; |
@@ -1969,7 +2317,9 @@ discard block |
||
1969 | 2317 | $cursor=$listofparentid[$cursor]; |
1970 | 2318 | } |
1971 | 2319 | |
1972 | - if (count($listofidtoclean)) break; |
|
2320 | + if (count($listofidtoclean)) { |
|
2321 | + break; |
|
2322 | + } |
|
1973 | 2323 | } |
1974 | 2324 | |
1975 | 2325 | $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree; |
@@ -2116,9 +2466,15 @@ discard block |
||
2116 | 2466 | $classfile='fournisseur.facture'; |
2117 | 2467 | } |
2118 | 2468 | |
2119 | - if (!isset($classfile)) $classfile = strtolower($subelement); |
|
2120 | - if (!isset($classname)) $classname = ucfirst($subelement); |
|
2121 | - if (!isset($classpath)) $classpath = $module.'/class'; |
|
2469 | + if (!isset($classfile)) { |
|
2470 | + $classfile = strtolower($subelement); |
|
2471 | + } |
|
2472 | + if (!isset($classname)) { |
|
2473 | + $classname = ucfirst($subelement); |
|
2474 | + } |
|
2475 | + if (!isset($classpath)) { |
|
2476 | + $classpath = $module.'/class'; |
|
2477 | + } |
|
2122 | 2478 | |
2123 | 2479 | $element_properties = array( |
2124 | 2480 | 'module' => $module, |
@@ -2172,8 +2528,12 @@ discard block |
||
2172 | 2528 | */ |
2173 | 2529 | function colorArrayToHex($arraycolor,$colorifnotfound='888888') |
2174 | 2530 | { |
2175 | - if (! is_array($arraycolor)) return $colorifnotfound; |
|
2176 | - if (empty($arraycolor)) return $colorifnotfound; |
|
2531 | + if (! is_array($arraycolor)) { |
|
2532 | + return $colorifnotfound; |
|
2533 | + } |
|
2534 | + if (empty($arraycolor)) { |
|
2535 | + return $colorifnotfound; |
|
2536 | + } |
|
2177 | 2537 | return sprintf("%02s",dechex($arraycolor[0])).sprintf("%02s",dechex($arraycolor[1])).sprintf("%02s",dechex($arraycolor[2])); |
2178 | 2538 | } |
2179 | 2539 | |
@@ -2189,12 +2549,17 @@ discard block |
||
2189 | 2549 | */ |
2190 | 2550 | function colorStringToArray($stringcolor,$colorifnotfound=array(88,88,88)) |
2191 | 2551 | { |
2192 | - if (is_array($stringcolor)) return $stringcolor; // If already into correct output format, we return as is |
|
2552 | + if (is_array($stringcolor)) { |
|
2553 | + return $stringcolor; |
|
2554 | + } |
|
2555 | + // If already into correct output format, we return as is |
|
2193 | 2556 | $tmp=preg_match('/^#?([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])$/',$stringcolor,$reg); |
2194 | 2557 | if (! $tmp) |
2195 | 2558 | { |
2196 | 2559 | $tmp=explode(',',$stringcolor); |
2197 | - if (count($tmp) < 3) return $colorifnotfound; |
|
2560 | + if (count($tmp) < 3) { |
|
2561 | + return $colorifnotfound; |
|
2562 | + } |
|
2198 | 2563 | return $tmp; |
2199 | 2564 | } |
2200 | 2565 | return array(hexdec($reg[1]),hexdec($reg[2]),hexdec($reg[3])); |
@@ -2240,69 +2605,51 @@ discard block |
||
2240 | 2605 | function getModuleDirForApiClass($module) |
2241 | 2606 | { |
2242 | 2607 | $moduledirforclass=$module; |
2243 | - if ($moduledirforclass != 'api') $moduledirforclass = preg_replace('/api$/i','',$moduledirforclass); |
|
2608 | + if ($moduledirforclass != 'api') { |
|
2609 | + $moduledirforclass = preg_replace('/api$/i','',$moduledirforclass); |
|
2610 | + } |
|
2244 | 2611 | |
2245 | 2612 | if ($module == 'contracts') { |
2246 | 2613 | $moduledirforclass = 'contrat'; |
2247 | - } |
|
2248 | - elseif (in_array($module, array('admin', 'login', 'setup', 'access', 'status', 'tools', 'documents'))) { |
|
2614 | + } elseif (in_array($module, array('admin', 'login', 'setup', 'access', 'status', 'tools', 'documents'))) { |
|
2249 | 2615 | $moduledirforclass = 'api'; |
2250 | - } |
|
2251 | - elseif ($module == 'contact' || $module == 'contacts' || $module == 'customer' || $module == 'thirdparty' || $module == 'thirdparties') { |
|
2616 | + } elseif ($module == 'contact' || $module == 'contacts' || $module == 'customer' || $module == 'thirdparty' || $module == 'thirdparties') { |
|
2252 | 2617 | $moduledirforclass = 'societe'; |
2253 | - } |
|
2254 | - elseif ($module == 'propale' || $module == 'proposals') { |
|
2618 | + } elseif ($module == 'propale' || $module == 'proposals') { |
|
2255 | 2619 | $moduledirforclass = 'comm/propal'; |
2256 | - } |
|
2257 | - elseif ($module == 'agenda' || $module == 'agendaevents') { |
|
2620 | + } elseif ($module == 'agenda' || $module == 'agendaevents') { |
|
2258 | 2621 | $moduledirforclass = 'comm/action'; |
2259 | - } |
|
2260 | - elseif ($module == 'adherent' || $module == 'members' || $module == 'memberstypes' || $module == 'subscriptions') { |
|
2622 | + } elseif ($module == 'adherent' || $module == 'members' || $module == 'memberstypes' || $module == 'subscriptions') { |
|
2261 | 2623 | $moduledirforclass = 'adherents'; |
2262 | - } |
|
2263 | - elseif ($module == 'banque' || $module == 'bankaccounts') { |
|
2624 | + } elseif ($module == 'banque' || $module == 'bankaccounts') { |
|
2264 | 2625 | $moduledirforclass = 'compta/bank'; |
2265 | - } |
|
2266 | - elseif ($module == 'category' || $module == 'categorie') { |
|
2626 | + } elseif ($module == 'category' || $module == 'categorie') { |
|
2267 | 2627 | $moduledirforclass = 'categories'; |
2268 | - } |
|
2269 | - elseif ($module == 'order' || $module == 'orders') { |
|
2628 | + } elseif ($module == 'order' || $module == 'orders') { |
|
2270 | 2629 | $moduledirforclass = 'commande'; |
2271 | - } |
|
2272 | - elseif ($module == 'shipments') { |
|
2630 | + } elseif ($module == 'shipments') { |
|
2273 | 2631 | $moduledirforclass = 'expedition'; |
2274 | - } |
|
2275 | - elseif ($module == 'facture' || $module == 'invoice' || $module == 'invoices') { |
|
2632 | + } elseif ($module == 'facture' || $module == 'invoice' || $module == 'invoices') { |
|
2276 | 2633 | $moduledirforclass = 'compta/facture'; |
2277 | - } |
|
2278 | - elseif ($module == 'products') { |
|
2634 | + } elseif ($module == 'products') { |
|
2279 | 2635 | $moduledirforclass = 'product'; |
2280 | - } |
|
2281 | - elseif ($module == 'project' || $module == 'projects' || $module == 'tasks') { |
|
2636 | + } elseif ($module == 'project' || $module == 'projects' || $module == 'tasks') { |
|
2282 | 2637 | $moduledirforclass = 'projet'; |
2283 | - } |
|
2284 | - elseif ($module == 'task') { |
|
2638 | + } elseif ($module == 'task') { |
|
2285 | 2639 | $moduledirforclass = 'projet'; |
2286 | - } |
|
2287 | - elseif ($module == 'stock' || $module == 'stockmovements' || $module == 'warehouses') { |
|
2640 | + } elseif ($module == 'stock' || $module == 'stockmovements' || $module == 'warehouses') { |
|
2288 | 2641 | $moduledirforclass = 'product/stock'; |
2289 | - } |
|
2290 | - elseif ($module == 'supplierproposals' || $module == 'supplierproposal' || $module == 'supplier_proposal') { |
|
2642 | + } elseif ($module == 'supplierproposals' || $module == 'supplierproposal' || $module == 'supplier_proposal') { |
|
2291 | 2643 | $moduledirforclass = 'supplier_proposal'; |
2292 | - } |
|
2293 | - elseif ($module == 'fournisseur' || $module == 'supplierinvoices' || $module == 'supplierorders') { |
|
2644 | + } elseif ($module == 'fournisseur' || $module == 'supplierinvoices' || $module == 'supplierorders') { |
|
2294 | 2645 | $moduledirforclass = 'fourn'; |
2295 | - } |
|
2296 | - elseif ($module == 'expensereports') { |
|
2646 | + } elseif ($module == 'expensereports') { |
|
2297 | 2647 | $moduledirforclass = 'expensereport'; |
2298 | - } |
|
2299 | - elseif ($module == 'users') { |
|
2648 | + } elseif ($module == 'users') { |
|
2300 | 2649 | $moduledirforclass = 'user'; |
2301 | - } |
|
2302 | - elseif ($module == 'ficheinter' || $module == 'interventions') { |
|
2650 | + } elseif ($module == 'ficheinter' || $module == 'interventions') { |
|
2303 | 2651 | $moduledirforclass = 'fichinter'; |
2304 | - } |
|
2305 | - elseif ($module == 'tickets') { |
|
2652 | + } elseif ($module == 'tickets') { |
|
2306 | 2653 | $moduledirforclass = 'ticket'; |
2307 | 2654 | } |
2308 | 2655 |