@@ -74,7 +74,9 @@ discard block |
||
74 | 74 | if ($found) return $result; |
75 | 75 | }*/ |
76 | 76 | |
77 | - if (isset($class::$member)) return $class::$member; |
|
77 | + if (isset($class::$member)) { |
|
78 | + return $class::$member; |
|
79 | + } |
|
78 | 80 | dol_print_error('','Try to get a static member "'.$member.'" in class "'.$class.'" that does not exists or is not static.'); |
79 | 81 | return null; |
80 | 82 | } |
@@ -122,19 +124,26 @@ discard block |
||
122 | 124 | global $conf, $mc; |
123 | 125 | |
124 | 126 | // For backward compatibilty |
125 | - if ($element == 'actioncomm') $element='agenda'; |
|
126 | - if ($element == 'fichinter') $element='intervention'; |
|
127 | - if ($element == 'categorie') $element='category'; |
|
127 | + if ($element == 'actioncomm') { |
|
128 | + $element='agenda'; |
|
129 | + } |
|
130 | + if ($element == 'fichinter') { |
|
131 | + $element='intervention'; |
|
132 | + } |
|
133 | + if ($element == 'categorie') { |
|
134 | + $element='category'; |
|
135 | + } |
|
128 | 136 | |
129 | 137 | if (is_object($mc)) |
130 | 138 | { |
131 | 139 | return $mc->getEntity($element, $shared, $forceentity); |
132 | - } |
|
133 | - else |
|
140 | + } else |
|
134 | 141 | { |
135 | 142 | $out=''; |
136 | 143 | $addzero = array('user', 'usergroup', 'c_email_templates', 'email_template', 'default_values'); |
137 | - if (in_array($element, $addzero)) $out.= '0,'; |
|
144 | + if (in_array($element, $addzero)) { |
|
145 | + $out.= '0,'; |
|
146 | + } |
|
138 | 147 | $out.= $conf->entity; |
139 | 148 | return $out; |
140 | 149 | } |
@@ -194,20 +203,12 @@ discard block |
||
194 | 203 | } |
195 | 204 | |
196 | 205 | // OS |
197 | - if (preg_match('/linux/i', $user_agent)) { $os='linux'; } |
|
198 | - elseif (preg_match('/macintosh/i', $user_agent)) { $os='macintosh'; } |
|
199 | - elseif (preg_match('/windows/i', $user_agent)) { $os='windows'; } |
|
206 | + if (preg_match('/linux/i', $user_agent)) { $os='linux'; } elseif (preg_match('/macintosh/i', $user_agent)) { $os='macintosh'; } elseif (preg_match('/windows/i', $user_agent)) { $os='windows'; } |
|
200 | 207 | |
201 | 208 | // Name |
202 | - if (preg_match('/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='firefox'; $version=$reg[2]; } |
|
203 | - elseif (preg_match('/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='edge'; $version=$reg[2]; } |
|
204 | - elseif (preg_match('/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) { $name='chrome'; $version=$reg[2]; } // we can have 'chrome (Mozilla...) chrome x.y' in one string |
|
205 | - elseif (preg_match('/chrome/i', $user_agent, $reg)) { $name='chrome'; } |
|
206 | - elseif (preg_match('/iceweasel/i', $user_agent)) { $name='iceweasel'; } |
|
207 | - elseif (preg_match('/epiphany/i', $user_agent)) { $name='epiphany'; } |
|
208 | - elseif (preg_match('/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='safari'; $version=$reg[2]; } // Safari is often present in string for mobile but its not. |
|
209 | - elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='opera'; $version=$reg[2]; } |
|
210 | - elseif (preg_match('/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name='ie'; $version=end($reg); } // MS products at end |
|
209 | + if (preg_match('/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='firefox'; $version=$reg[2]; } elseif (preg_match('/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='edge'; $version=$reg[2]; } elseif (preg_match('/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) { $name='chrome'; $version=$reg[2]; } // we can have 'chrome (Mozilla...) chrome x.y' in one string |
|
210 | + elseif (preg_match('/chrome/i', $user_agent, $reg)) { $name='chrome'; } elseif (preg_match('/iceweasel/i', $user_agent)) { $name='iceweasel'; } elseif (preg_match('/epiphany/i', $user_agent)) { $name='epiphany'; } elseif (preg_match('/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='safari'; $version=$reg[2]; } // Safari is often present in string for mobile but its not. |
|
211 | + elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='opera'; $version=$reg[2]; } elseif (preg_match('/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name='ie'; $version=end($reg); } // MS products at end |
|
211 | 212 | elseif (preg_match('/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name='ie'; $version=end($reg); } // MS products at end |
212 | 213 | elseif (preg_match('/l(i|y)n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) { $name='lynxlinks'; $version=$reg[4]; } |
213 | 214 | |
@@ -280,7 +281,9 @@ discard block |
||
280 | 281 | { |
281 | 282 | global $mysoc,$user,$conf; |
282 | 283 | |
283 | - if (empty($paramname)) return 'BadFirstParameterForGETPOST'; |
|
284 | + if (empty($paramname)) { |
|
285 | + return 'BadFirstParameterForGETPOST'; |
|
286 | + } |
|
284 | 287 | if (empty($check)) |
285 | 288 | { |
286 | 289 | dol_syslog("Deprecated use of GETPOST, called with 1st param = ".$paramname." and 2nd param is '', when calling page ".$_SERVER["PHP_SELF"], LOG_WARNING); |
@@ -288,19 +291,28 @@ discard block |
||
288 | 291 | //var_dump(debug_backtrace()[0]); |
289 | 292 | } |
290 | 293 | |
291 | - if (empty($method)) $out = isset($_GET[$paramname])?$_GET[$paramname]:(isset($_POST[$paramname])?$_POST[$paramname]:''); |
|
292 | - elseif ($method==1) $out = isset($_GET[$paramname])?$_GET[$paramname]:''; |
|
293 | - elseif ($method==2) $out = isset($_POST[$paramname])?$_POST[$paramname]:''; |
|
294 | - elseif ($method==3) $out = isset($_POST[$paramname])?$_POST[$paramname]:(isset($_GET[$paramname])?$_GET[$paramname]:''); |
|
295 | - elseif ($method==4) $out = isset($_POST[$paramname])?$_POST[$paramname]:(isset($_GET[$paramname])?$_GET[$paramname]:(isset($_COOKIE[$paramname])?$_COOKIE[$paramname]:'')); |
|
296 | - else return 'BadThirdParameterForGETPOST'; |
|
294 | + if (empty($method)) { |
|
295 | + $out = isset($_GET[$paramname])?$_GET[$paramname]:(isset($_POST[$paramname])?$_POST[$paramname]:''); |
|
296 | + } elseif ($method==1) { |
|
297 | + $out = isset($_GET[$paramname])?$_GET[$paramname]:''; |
|
298 | + } elseif ($method==2) { |
|
299 | + $out = isset($_POST[$paramname])?$_POST[$paramname]:''; |
|
300 | + } elseif ($method==3) { |
|
301 | + $out = isset($_POST[$paramname])?$_POST[$paramname]:(isset($_GET[$paramname])?$_GET[$paramname]:''); |
|
302 | + } elseif ($method==4) { |
|
303 | + $out = isset($_POST[$paramname])?$_POST[$paramname]:(isset($_GET[$paramname])?$_GET[$paramname]:(isset($_COOKIE[$paramname])?$_COOKIE[$paramname]:'')); |
|
304 | + } else { |
|
305 | + return 'BadThirdParameterForGETPOST'; |
|
306 | + } |
|
297 | 307 | |
298 | 308 | if (empty($method) || $method == 3 || $method == 4) |
299 | 309 | { |
300 | 310 | |
301 | 311 | $relativepathstring = $_SERVER["PHP_SELF"]; |
302 | 312 | // Clean $relativepathstring |
303 | - if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); |
|
313 | + if (constant('DOL_URL_ROOT')) { |
|
314 | + $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); |
|
315 | + } |
|
304 | 316 | $relativepathstring = preg_replace('/^\//', '', $relativepathstring); |
305 | 317 | $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); |
306 | 318 | //var_dump($relativepathstring); |
@@ -308,9 +320,11 @@ discard block |
||
308 | 320 | |
309 | 321 | // Code for search criteria persistence. |
310 | 322 | // Retrieve values if restore_lastsearch_values is set and there is saved values |
311 | - if (! empty($_GET['restore_lastsearch_values']) && ! empty($_SESSION['lastsearch_values_'.$relativepathstring])) // Keep $_GET here |
|
323 | + if (! empty($_GET['restore_lastsearch_values']) && ! empty($_SESSION['lastsearch_values_'.$relativepathstring])) { |
|
324 | + // Keep $_GET here |
|
312 | 325 | { |
313 | 326 | $tmp=json_decode($_SESSION['lastsearch_values_'.$relativepathstring], true); |
327 | + } |
|
314 | 328 | if (is_array($tmp)) |
315 | 329 | { |
316 | 330 | foreach($tmp as $key => $val) |
@@ -324,12 +338,14 @@ discard block |
||
324 | 338 | } |
325 | 339 | } |
326 | 340 | // Else, retreive default values if we are not doing a sort |
327 | - elseif (! isset($_GET['sortfield'])) // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_ENABLE_DEFAULT_VALUES is not set |
|
341 | + elseif (! isset($_GET['sortfield'])) { |
|
342 | + // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_ENABLE_DEFAULT_VALUES is not set |
|
328 | 343 | { |
329 | 344 | if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) |
330 | 345 | { |
331 | 346 | // Search default value from $object->field |
332 | 347 | global $object; |
348 | + } |
|
333 | 349 | if (is_object($object) && isset($object->fields[$paramname]['default'])) |
334 | 350 | { |
335 | 351 | $out = $object->fields[$paramname]['default']; |
@@ -340,13 +356,15 @@ discard block |
||
340 | 356 | if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) |
341 | 357 | { |
342 | 358 | // Now search in setup to overwrite default values |
343 | - if (! empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values' |
|
359 | + if (! empty($user->default_values)) { |
|
360 | + // $user->default_values defined from menu 'Setup - Default values' |
|
344 | 361 | { |
345 | 362 | if (isset($user->default_values[$relativepathstring]['createform'])) |
346 | 363 | { |
347 | 364 | foreach($user->default_values[$relativepathstring]['createform'] as $defkey => $defval) |
348 | 365 | { |
349 | 366 | $qualified = 0; |
367 | + } |
|
350 | 368 | if ($defkey != '_noquery_') |
351 | 369 | { |
352 | 370 | $tmpqueryarraytohave=explode('&', $defkey); |
@@ -354,12 +372,17 @@ discard block |
||
354 | 372 | $foundintru=0; |
355 | 373 | foreach($tmpqueryarraytohave as $tmpquerytohave) |
356 | 374 | { |
357 | - if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1; |
|
375 | + if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
376 | + $foundintru=1; |
|
377 | + } |
|
378 | + } |
|
379 | + if (! $foundintru) { |
|
380 | + $qualified=1; |
|
358 | 381 | } |
359 | - if (! $foundintru) $qualified=1; |
|
360 | 382 | //var_dump($defkey.'-'.$qualified); |
383 | + } else { |
|
384 | + $qualified = 1; |
|
361 | 385 | } |
362 | - else $qualified = 1; |
|
363 | 386 | |
364 | 387 | if ($qualified) |
365 | 388 | { |
@@ -378,7 +401,8 @@ discard block |
||
378 | 401 | //elseif (preg_match('/list.php$/', $_SERVER["PHP_SELF"]) && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) |
379 | 402 | elseif (! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) |
380 | 403 | { |
381 | - if (! empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values' |
|
404 | + if (! empty($user->default_values)) { |
|
405 | + // $user->default_values defined from menu 'Setup - Default values' |
|
382 | 406 | { |
383 | 407 | //var_dump($user->default_values[$relativepathstring]); |
384 | 408 | if ($paramname == 'sortfield' || $paramname == 'sortorder') // Sorted on which fields ? ASC or DESC ? |
@@ -388,6 +412,7 @@ discard block |
||
388 | 412 | foreach($user->default_values[$relativepathstring]['sortorder'] as $defkey => $defval) |
389 | 413 | { |
390 | 414 | $qualified = 0; |
415 | + } |
|
391 | 416 | if ($defkey != '_noquery_') |
392 | 417 | { |
393 | 418 | $tmpqueryarraytohave=explode('&', $defkey); |
@@ -395,19 +420,26 @@ discard block |
||
395 | 420 | $foundintru=0; |
396 | 421 | foreach($tmpqueryarraytohave as $tmpquerytohave) |
397 | 422 | { |
398 | - if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1; |
|
423 | + if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
424 | + $foundintru=1; |
|
425 | + } |
|
426 | + } |
|
427 | + if (! $foundintru) { |
|
428 | + $qualified=1; |
|
399 | 429 | } |
400 | - if (! $foundintru) $qualified=1; |
|
401 | 430 | //var_dump($defkey.'-'.$qualified); |
431 | + } else { |
|
432 | + $qualified = 1; |
|
402 | 433 | } |
403 | - else $qualified = 1; |
|
404 | 434 | |
405 | 435 | if ($qualified) |
406 | 436 | { |
407 | 437 | $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and , |
408 | 438 | foreach($user->default_values[$relativepathstring]['sortorder'][$defkey] as $key => $val) |
409 | 439 | { |
410 | - if ($out) $out.=', '; |
|
440 | + if ($out) { |
|
441 | + $out.=', '; |
|
442 | + } |
|
411 | 443 | if ($paramname == 'sortfield') |
412 | 444 | { |
413 | 445 | $out.=dol_string_nospecial($key, '', $forbidden_chars_to_replace); |
@@ -421,8 +453,7 @@ discard block |
||
421 | 453 | } |
422 | 454 | } |
423 | 455 | } |
424 | - } |
|
425 | - elseif (isset($user->default_values[$relativepathstring]['filters'])) |
|
456 | + } elseif (isset($user->default_values[$relativepathstring]['filters'])) |
|
426 | 457 | { |
427 | 458 | foreach($user->default_values[$relativepathstring]['filters'] as $defkey => $defval) |
428 | 459 | { |
@@ -434,12 +465,17 @@ discard block |
||
434 | 465 | $foundintru=0; |
435 | 466 | foreach($tmpqueryarraytohave as $tmpquerytohave) |
436 | 467 | { |
437 | - if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1; |
|
468 | + if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
469 | + $foundintru=1; |
|
470 | + } |
|
471 | + } |
|
472 | + if (! $foundintru) { |
|
473 | + $qualified=1; |
|
438 | 474 | } |
439 | - if (! $foundintru) $qualified=1; |
|
440 | 475 | //var_dump($defkey.'-'.$qualified); |
476 | + } else { |
|
477 | + $qualified = 1; |
|
441 | 478 | } |
442 | - else $qualified = 1; |
|
443 | 479 | |
444 | 480 | if ($qualified) |
445 | 481 | { |
@@ -451,8 +487,7 @@ discard block |
||
451 | 487 | $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and , |
452 | 488 | $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace); |
453 | 489 | } |
454 | - } |
|
455 | - else |
|
490 | + } else |
|
456 | 491 | { |
457 | 492 | $forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and , |
458 | 493 | $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace); |
@@ -473,36 +508,29 @@ discard block |
||
473 | 508 | if (! is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) |
474 | 509 | { |
475 | 510 | $maxloop=20; $loopnb=0; // Protection against infinite loop |
476 | - while (preg_match('/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) // Detect '__ABCDEF__' as key 'ABCDEF' and '__ABC_DEF__' as key 'ABC_DEF'. Detection is also correct when 2 vars are side by side. |
|
477 | - { |
|
478 | - $loopnb++; $newout = ''; |
|
479 | - |
|
480 | - if ($reg[1] == 'DAY') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mday']; } |
|
481 | - elseif ($reg[1] == 'MONTH') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mon']; } |
|
482 | - elseif ($reg[1] == 'YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['year']; } |
|
483 | - elseif ($reg[1] == 'PREVIOUS_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } |
|
484 | - elseif ($reg[1] == 'PREVIOUS_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_month($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } |
|
485 | - elseif ($reg[1] == 'PREVIOUS_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] - 1); } |
|
486 | - elseif ($reg[1] == 'NEXT_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } |
|
487 | - elseif ($reg[1] == 'NEXT_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_month($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } |
|
488 | - elseif ($reg[1] == 'NEXT_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] + 1); } |
|
489 | - elseif ($reg[1] == 'MYCOMPANY_COUNTRY_ID' || $reg[1] == 'MYCOUNTRY_ID' || $reg[1] == 'MYCOUNTRYID') |
|
511 | + while (preg_match('/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) { |
|
512 | + // Detect '__ABCDEF__' as key 'ABCDEF' and '__ABC_DEF__' as key 'ABC_DEF'. Detection is also correct when 2 vars are side by side. |
|
513 | + { |
|
514 | + $loopnb++; |
|
515 | + } |
|
516 | + $newout = ''; |
|
517 | + |
|
518 | + if ($reg[1] == 'DAY') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mday']; } elseif ($reg[1] == 'MONTH') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mon']; } elseif ($reg[1] == 'YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['year']; } elseif ($reg[1] == 'PREVIOUS_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } elseif ($reg[1] == 'PREVIOUS_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_month($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } elseif ($reg[1] == 'PREVIOUS_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] - 1); } elseif ($reg[1] == 'NEXT_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } elseif ($reg[1] == 'NEXT_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_month($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } elseif ($reg[1] == 'NEXT_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] + 1); } elseif ($reg[1] == 'MYCOMPANY_COUNTRY_ID' || $reg[1] == 'MYCOUNTRY_ID' || $reg[1] == 'MYCOUNTRYID') |
|
490 | 519 | { |
491 | 520 | $newout = $mysoc->country_id; |
492 | - } |
|
493 | - elseif ($reg[1] == 'USER_ID' || $reg[1] == 'USERID') |
|
521 | + } elseif ($reg[1] == 'USER_ID' || $reg[1] == 'USERID') |
|
494 | 522 | { |
495 | 523 | $newout = $user->id; |
496 | - } |
|
497 | - elseif ($reg[1] == 'USER_SUPERVISOR_ID' || $reg[1] == 'SUPERVISOR_ID' || $reg[1] == 'SUPERVISORID') |
|
524 | + } elseif ($reg[1] == 'USER_SUPERVISOR_ID' || $reg[1] == 'SUPERVISOR_ID' || $reg[1] == 'SUPERVISORID') |
|
498 | 525 | { |
499 | 526 | $newout = $user->fk_user; |
500 | - } |
|
501 | - elseif ($reg[1] == 'ENTITY_ID' || $reg[1] == 'ENTITYID') |
|
527 | + } elseif ($reg[1] == 'ENTITY_ID' || $reg[1] == 'ENTITYID') |
|
502 | 528 | { |
503 | 529 | $newout = $conf->entity; |
530 | + } else { |
|
531 | + $newout = ''; |
|
504 | 532 | } |
505 | - else $newout = ''; // Key not found, we replace with empty string |
|
533 | + // Key not found, we replace with empty string |
|
506 | 534 | //var_dump('__'.$reg[1].'__ -> '.$newout); |
507 | 535 | $out = preg_replace('/__'.preg_quote($reg[1],'/').'__/', $newout, $out); |
508 | 536 | } |
@@ -517,7 +545,9 @@ discard block |
||
517 | 545 | if (! is_numeric($out)) { $out=''; } |
518 | 546 | break; |
519 | 547 | case 'intcomma': |
520 | - if (preg_match('/[^0-9,-]+/i',$out)) $out=''; |
|
548 | + if (preg_match('/[^0-9,-]+/i',$out)) { |
|
549 | + $out=''; |
|
550 | + } |
|
521 | 551 | break; |
522 | 552 | case 'alpha': |
523 | 553 | if (! is_array($out)) |
@@ -525,8 +555,11 @@ discard block |
||
525 | 555 | $out=trim($out); |
526 | 556 | // '"' is dangerous because param in url can close the href= or src= and add javascript functions. |
527 | 557 | // '../' is dangerous because it allows dir transversals |
528 | - if (preg_match('/"/',$out)) $out=''; |
|
529 | - else if (preg_match('/\.\.\//',$out)) $out=''; |
|
558 | + if (preg_match('/"/',$out)) { |
|
559 | + $out=''; |
|
560 | + } else if (preg_match('/\.\.\//',$out)) { |
|
561 | + $out=''; |
|
562 | + } |
|
530 | 563 | } |
531 | 564 | break; |
532 | 565 | case 'san_alpha': |
@@ -536,18 +569,24 @@ discard block |
||
536 | 569 | if (! is_array($out)) |
537 | 570 | { |
538 | 571 | $out=trim($out); |
539 | - if (preg_match('/[^a-z]+/i',$out)) $out=''; |
|
572 | + if (preg_match('/[^a-z]+/i',$out)) { |
|
573 | + $out=''; |
|
574 | + } |
|
540 | 575 | } |
541 | 576 | break; |
542 | 577 | case 'aZ09': |
543 | 578 | if (! is_array($out)) |
544 | 579 | { |
545 | 580 | $out=trim($out); |
546 | - if (preg_match('/[^a-z0-9_\-\.]+/i',$out)) $out=''; |
|
581 | + if (preg_match('/[^a-z0-9_\-\.]+/i',$out)) { |
|
582 | + $out=''; |
|
583 | + } |
|
547 | 584 | } |
548 | 585 | break; |
549 | 586 | case 'array': |
550 | - if (! is_array($out) || empty($out)) $out=array(); |
|
587 | + if (! is_array($out) || empty($out)) { |
|
588 | + $out=array(); |
|
589 | + } |
|
551 | 590 | break; |
552 | 591 | case 'nohtml': |
553 | 592 | $out=dol_string_nohtmltag($out, 0); |
@@ -558,13 +597,18 @@ discard block |
||
558 | 597 | $out=trim($out); |
559 | 598 | // '"' is dangerous because param in url can close the href= or src= and add javascript functions. |
560 | 599 | // '../' is dangerous because it allows dir transversals |
561 | - if (preg_match('/"/',$out)) $out=''; |
|
562 | - else if (preg_match('/\.\.\//',$out)) $out=''; |
|
600 | + if (preg_match('/"/',$out)) { |
|
601 | + $out=''; |
|
602 | + } else if (preg_match('/\.\.\//',$out)) { |
|
603 | + $out=''; |
|
604 | + } |
|
563 | 605 | $out=dol_string_nohtmltag($out); |
564 | 606 | } |
565 | 607 | break; |
566 | 608 | case 'custom': |
567 | - if (empty($filter)) return 'BadFourthParameterForGETPOST'; |
|
609 | + if (empty($filter)) { |
|
610 | + return 'BadFourthParameterForGETPOST'; |
|
611 | + } |
|
568 | 612 | $out=filter_var($out, $filter, $options); |
569 | 613 | break; |
570 | 614 | } |
@@ -612,8 +656,11 @@ discard block |
||
612 | 656 | // If MAIL_PREFIX_FOR_EMAIL_ID is set and prefix is for email |
613 | 657 | if ($mode == 'email' && ! empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) |
614 | 658 | { |
615 | - if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME') return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID; |
|
616 | - else if (isset($_SERVER["SERVER_NAME"])) return $_SERVER["SERVER_NAME"]; |
|
659 | + if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME') { |
|
660 | + return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID; |
|
661 | + } else if (isset($_SERVER["SERVER_NAME"])) { |
|
662 | + return $_SERVER["SERVER_NAME"]; |
|
663 | + } |
|
617 | 664 | } |
618 | 665 | |
619 | 666 | if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["DOCUMENT_ROOT"])) |
@@ -621,8 +668,9 @@ discard block |
||
621 | 668 | return dol_hash($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT); |
622 | 669 | // Use this for a "readable" cookie name |
623 | 670 | //return dol_sanitizeFileName($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT); |
671 | + } else { |
|
672 | + return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT); |
|
624 | 673 | } |
625 | - else return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT); |
|
626 | 674 | } |
627 | 675 | } |
628 | 676 | |
@@ -671,41 +719,57 @@ discard block |
||
671 | 719 | |
672 | 720 | $path=preg_replace('/^\//','',$path); |
673 | 721 | |
674 | - if (empty($type)) // For a filesystem path |
|
722 | + if (empty($type)) { |
|
723 | + // For a filesystem path |
|
675 | 724 | { |
676 | - $res = DOL_DOCUMENT_ROOT.'/'.$path; // Standard default path |
|
677 | - foreach ($conf->file->dol_document_root as $key => $dirroot) // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...) |
|
725 | + $res = DOL_DOCUMENT_ROOT.'/'.$path; |
|
726 | + } |
|
727 | + // Standard default path |
|
728 | + foreach ($conf->file->dol_document_root as $key => $dirroot) { |
|
729 | + // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...) |
|
678 | 730 | { |
679 | 731 | if ($key == 'main') continue; |
732 | + } |
|
680 | 733 | if (file_exists($dirroot.'/'.$path)) |
681 | 734 | { |
682 | 735 | $res=$dirroot.'/'.$path; |
683 | 736 | return $res; |
684 | 737 | } |
685 | 738 | } |
686 | - if ($returnemptyifnotfound) // Not found into alternate dir |
|
739 | + if ($returnemptyifnotfound) { |
|
740 | + // Not found into alternate dir |
|
687 | 741 | { |
688 | 742 | if ($returnemptyifnotfound == 1 || ! file_exists($res)) return ''; |
689 | 743 | } |
690 | - } |
|
691 | - else // For an url path |
|
744 | + } |
|
745 | + } else // For an url path |
|
692 | 746 | { |
693 | 747 | // We try to get local path of file on filesystem from url |
694 | 748 | // Note that trying to know if a file on disk exist by forging path on disk from url |
695 | 749 | // works only for some web server and some setup. This is bugged when |
696 | 750 | // using proxy, rewriting, virtual path, etc... |
697 | 751 | $res=''; |
698 | - if ($type == 1) $res = DOL_URL_ROOT.'/'.$path; // Standard value |
|
699 | - if ($type == 2) $res = DOL_MAIN_URL_ROOT.'/'.$path; // Standard value |
|
700 | - if ($type == 3) $res = DOL_URL_ROOT.'/'.$path; |
|
752 | + if ($type == 1) { |
|
753 | + $res = DOL_URL_ROOT.'/'.$path; |
|
754 | + } |
|
755 | + // Standard value |
|
756 | + if ($type == 2) { |
|
757 | + $res = DOL_MAIN_URL_ROOT.'/'.$path; |
|
758 | + } |
|
759 | + // Standard value |
|
760 | + if ($type == 3) { |
|
761 | + $res = DOL_URL_ROOT.'/'.$path; |
|
762 | + } |
|
701 | 763 | |
702 | - foreach ($conf->file->dol_document_root as $key => $dirroot) // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...) |
|
764 | + foreach ($conf->file->dol_document_root as $key => $dirroot) { |
|
765 | + // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...) |
|
703 | 766 | { |
704 | 767 | if ($key == 'main') |
705 | 768 | { |
706 | 769 | if ($type == 3) |
707 | 770 | { |
708 | 771 | global $dolibarr_main_url_root; |
772 | + } |
|
709 | 773 | |
710 | 774 | // Define $urlwithroot |
711 | 775 | $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); |
@@ -767,8 +831,7 @@ discard block |
||
767 | 831 | if (empty($native)) |
768 | 832 | { |
769 | 833 | $myclone=unserialize(serialize($object)); |
770 | - } |
|
771 | - else |
|
834 | + } else |
|
772 | 835 | { |
773 | 836 | $myclone = clone $object; // PHP clone is a shallow copy only, not a real clone, so properties of references will keep references (refer to the same target/variable) |
774 | 837 | } |
@@ -788,10 +851,15 @@ discard block |
||
788 | 851 | function dol_size($size,$type='') |
789 | 852 | { |
790 | 853 | global $conf; |
791 | - if (empty($conf->dol_optimize_smallscreen)) return $size; |
|
792 | - if ($type == 'width' && $size > 250) return 250; |
|
793 | - else return 10; |
|
794 | -} |
|
854 | + if (empty($conf->dol_optimize_smallscreen)) { |
|
855 | + return $size; |
|
856 | + } |
|
857 | + if ($type == 'width' && $size > 250) { |
|
858 | + return 250; |
|
859 | + } else { |
|
860 | + return 10; |
|
861 | + } |
|
862 | + } |
|
795 | 863 | |
796 | 864 | |
797 | 865 | /** |
@@ -857,8 +925,7 @@ discard block |
||
857 | 925 | ); |
858 | 926 | $string=strtr($string, $replacements); |
859 | 927 | return rawurldecode($string); |
860 | - } |
|
861 | - else |
|
928 | + } else |
|
862 | 929 | { |
863 | 930 | // See http://www.ascii-code.com/ |
864 | 931 | $string = strtr( |
@@ -896,7 +963,9 @@ discard block |
||
896 | 963 | { |
897 | 964 | $forbidden_chars_to_replace=array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ",", ";", "=", '°'); // more complete than dol_sanitizeFileName |
898 | 965 | $forbidden_chars_to_remove=array(); |
899 | - if (is_array($badcharstoreplace)) $forbidden_chars_to_replace=$badcharstoreplace; |
|
966 | + if (is_array($badcharstoreplace)) { |
|
967 | + $forbidden_chars_to_replace=$badcharstoreplace; |
|
968 | + } |
|
900 | 969 | //$forbidden_chars_to_remove=array("(",")"); |
901 | 970 | |
902 | 971 | return str_replace($forbidden_chars_to_replace,$newstr,str_replace($forbidden_chars_to_remove,"",$str)); |
@@ -928,10 +997,9 @@ discard block |
||
928 | 997 | $substitjs=array("'"=>"\\'","\r"=>'\\r'); |
929 | 998 | //$substitjs['</']='<\/'; // We removed this. Should be useless. |
930 | 999 | if (empty($noescapebackslashn)) { $substitjs["\n"]='\\n'; $substitjs['\\']='\\\\'; } |
931 | - if (empty($mode)) { $substitjs["'"]="\\'"; $substitjs['"']="\\'"; } |
|
932 | - else if ($mode == 1) $substitjs["'"]="\\'"; |
|
933 | - else if ($mode == 2) { $substitjs['"']='\\"'; } |
|
934 | - else if ($mode == 3) { $substitjs["'"]="\\'"; $substitjs['"']="\\\""; } |
|
1000 | + if (empty($mode)) { $substitjs["'"]="\\'"; $substitjs['"']="\\'"; } else if ($mode == 1) { |
|
1001 | + $substitjs["'"]="\\'"; |
|
1002 | + } else if ($mode == 2) { $substitjs['"']='\\"'; } else if ($mode == 3) { $substitjs["'"]="\\'"; $substitjs['"']="\\\""; } |
|
935 | 1003 | return strtr($stringtoescape, $substitjs); |
936 | 1004 | } |
937 | 1005 | |
@@ -949,8 +1017,12 @@ discard block |
||
949 | 1017 | { |
950 | 1018 | // escape quotes and backslashes, newlines, etc. |
951 | 1019 | $tmp=html_entity_decode($stringtoescape, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars_decode instead, that make only required change for html tags |
952 | - if (! $keepb) $tmp=strtr($tmp, array("<b>"=>'','</b>'=>'')); |
|
953 | - if (! $keepn) $tmp=strtr($tmp, array("\r"=>'\\r',"\n"=>'\\n')); |
|
1020 | + if (! $keepb) { |
|
1021 | + $tmp=strtr($tmp, array("<b>"=>'','</b>'=>'')); |
|
1022 | + } |
|
1023 | + if (! $keepn) { |
|
1024 | + $tmp=strtr($tmp, array("\r"=>'\\r',"\n"=>'\\n')); |
|
1025 | + } |
|
954 | 1026 | return htmlentities($tmp, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars instead, that make only required change for html tags |
955 | 1027 | } |
956 | 1028 | |
@@ -1003,7 +1075,9 @@ discard block |
||
1003 | 1075 | global $conf, $user; |
1004 | 1076 | |
1005 | 1077 | // If syslog module enabled |
1006 | - if (empty($conf->syslog->enabled)) return; |
|
1078 | + if (empty($conf->syslog->enabled)) { |
|
1079 | + return; |
|
1080 | + } |
|
1007 | 1081 | |
1008 | 1082 | if (! empty($message)) |
1009 | 1083 | { |
@@ -1013,13 +1087,17 @@ discard block |
||
1013 | 1087 | { |
1014 | 1088 | throw new Exception('Incorrect log level'); |
1015 | 1089 | } |
1016 | - if ($level > $conf->global->SYSLOG_LEVEL) return; |
|
1090 | + if ($level > $conf->global->SYSLOG_LEVEL) { |
|
1091 | + return; |
|
1092 | + } |
|
1017 | 1093 | |
1018 | 1094 | // If adding log inside HTML page is required |
1019 | - if (! empty($_REQUEST['logtohtml']) && (! empty($conf->global->MAIN_ENABLE_LOG_TO_HTML) || ! empty($conf->global->MAIN_LOGTOHTML))) // MAIN_LOGTOHTML kept for backward compatibility |
|
1095 | + if (! empty($_REQUEST['logtohtml']) && (! empty($conf->global->MAIN_ENABLE_LOG_TO_HTML) || ! empty($conf->global->MAIN_LOGTOHTML))) { |
|
1096 | + // MAIN_LOGTOHTML kept for backward compatibility |
|
1020 | 1097 | { |
1021 | 1098 | $conf->logbuffer[] = dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".$message; |
1022 | 1099 | } |
1100 | + } |
|
1023 | 1101 | |
1024 | 1102 | //TODO: Remove this. MAIN_ENABLE_LOG_INLINE_HTML should be deprecated and use a log handler dedicated to HTML output |
1025 | 1103 | // If enable html log tag enabled and url parameter log defined, we show output log on HTML comments |
@@ -1039,19 +1117,31 @@ discard block |
||
1039 | 1117 | ); |
1040 | 1118 | |
1041 | 1119 | // This is when server run behind a reverse proxy |
1042 | - if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'].(empty($_SERVER["REMOTE_ADDR"])?'':'->'.$_SERVER['REMOTE_ADDR']); |
|
1120 | + if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
1121 | + $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'].(empty($_SERVER["REMOTE_ADDR"])?'':'->'.$_SERVER['REMOTE_ADDR']); |
|
1122 | + } |
|
1043 | 1123 | // This is when server run normally on a server |
1044 | - else if (! empty($_SERVER["REMOTE_ADDR"])) $data['ip'] = $_SERVER['REMOTE_ADDR']; |
|
1124 | + else if (! empty($_SERVER["REMOTE_ADDR"])) { |
|
1125 | + $data['ip'] = $_SERVER['REMOTE_ADDR']; |
|
1126 | + } |
|
1045 | 1127 | // This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache) |
1046 | - else if (! empty($_SERVER['SERVER_ADDR'])) $data['ip'] = $_SERVER['SERVER_ADDR']; |
|
1128 | + else if (! empty($_SERVER['SERVER_ADDR'])) { |
|
1129 | + $data['ip'] = $_SERVER['SERVER_ADDR']; |
|
1130 | + } |
|
1047 | 1131 | // This is when PHP session is ran outside a web server, like from Windows command line (Not always defined, but useful if OS defined it). |
1048 | - else if (! empty($_SERVER['COMPUTERNAME'])) $data['ip'] = $_SERVER['COMPUTERNAME'].(empty($_SERVER['USERNAME'])?'':'@'.$_SERVER['USERNAME']); |
|
1132 | + else if (! empty($_SERVER['COMPUTERNAME'])) { |
|
1133 | + $data['ip'] = $_SERVER['COMPUTERNAME'].(empty($_SERVER['USERNAME'])?'':'@'.$_SERVER['USERNAME']); |
|
1134 | + } |
|
1049 | 1135 | // This is when PHP session is ran outside a web server, like from Linux command line (Not always defined, but usefull if OS defined it). |
1050 | - else if (! empty($_SERVER['LOGNAME'])) $data['ip'] = '???@'.$_SERVER['LOGNAME']; |
|
1136 | + else if (! empty($_SERVER['LOGNAME'])) { |
|
1137 | + $data['ip'] = '???@'.$_SERVER['LOGNAME']; |
|
1138 | + } |
|
1051 | 1139 | // Loop on each log handler and send output |
1052 | 1140 | foreach ($conf->loghandlers as $loghandlerinstance) |
1053 | 1141 | { |
1054 | - if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) continue; |
|
1142 | + if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) { |
|
1143 | + continue; |
|
1144 | + } |
|
1055 | 1145 | $loghandlerinstance->export($data,$suffixinfilename); |
1056 | 1146 | } |
1057 | 1147 | unset($data); |
@@ -1102,16 +1192,23 @@ discard block |
||
1102 | 1192 | |
1103 | 1193 | $out="\n".'<div class="tabs" data-role="controlgroup" data-type="horizontal">'."\n"; |
1104 | 1194 | |
1105 | - if ($morehtmlright) $out.='<div class="inline-block floatright tabsElem">'.$morehtmlright.'</div>'; // Output right area first so when space is missing, text is in front of tabs and not under. |
|
1195 | + if ($morehtmlright) { |
|
1196 | + $out.='<div class="inline-block floatright tabsElem">'.$morehtmlright.'</div>'; |
|
1197 | + } |
|
1198 | + // Output right area first so when space is missing, text is in front of tabs and not under. |
|
1106 | 1199 | |
1107 | 1200 | // Show title |
1108 | 1201 | $showtitle=1; |
1109 | - if (! empty($conf->dol_optimize_smallscreen)) $showtitle=0; |
|
1202 | + if (! empty($conf->dol_optimize_smallscreen)) { |
|
1203 | + $showtitle=0; |
|
1204 | + } |
|
1110 | 1205 | if (! empty($title) && $showtitle) |
1111 | 1206 | { |
1112 | 1207 | $limittitle=30; |
1113 | 1208 | $out.='<a class="tabTitle">'; |
1114 | - if ($picto) $out.=img_picto($title,($pictoisfullpath?'':'object_').$picto,'',$pictoisfullpath).' '; |
|
1209 | + if ($picto) { |
|
1210 | + $out.=img_picto($title,($pictoisfullpath?'':'object_').$picto,'',$pictoisfullpath).' '; |
|
1211 | + } |
|
1115 | 1212 | $out.='<span class="tabTitleText">'.dol_trunc($title,$limittitle).'</span>'; |
1116 | 1213 | $out.='</a>'; |
1117 | 1214 | } |
@@ -1121,10 +1218,14 @@ discard block |
||
1121 | 1218 | if (is_array($links) && ! empty($links)) |
1122 | 1219 | { |
1123 | 1220 | $keys=array_keys($links); |
1124 | - if (count($keys)) $maxkey=max($keys); |
|
1221 | + if (count($keys)) { |
|
1222 | + $maxkey=max($keys); |
|
1223 | + } |
|
1125 | 1224 | } |
1126 | 1225 | |
1127 | - if (! empty($conf->dol_optimize_smallscreen)) $conf->global->MAIN_MAXTABS_IN_CARD=2; |
|
1226 | + if (! empty($conf->dol_optimize_smallscreen)) { |
|
1227 | + $conf->global->MAIN_MAXTABS_IN_CARD=2; |
|
1228 | + } |
|
1128 | 1229 | |
1129 | 1230 | // Show tabs |
1130 | 1231 | $bactive=false; |
@@ -1138,7 +1239,9 @@ discard block |
||
1138 | 1239 | if ((is_numeric($active) && $i == $active) || (! empty($links[$i][2]) && ! is_numeric($active) && $active == $links[$i][2])) |
1139 | 1240 | { |
1140 | 1241 | // If active tab is already present |
1141 | - if ($i >= $limittoshow) $limittoshow--; |
|
1242 | + if ($i >= $limittoshow) { |
|
1243 | + $limittoshow--; |
|
1244 | + } |
|
1142 | 1245 | } |
1143 | 1246 | } |
1144 | 1247 | |
@@ -1148,8 +1251,7 @@ discard block |
||
1148 | 1251 | { |
1149 | 1252 | $isactive=true; |
1150 | 1253 | $bactive=true; |
1151 | - } |
|
1152 | - else |
|
1254 | + } else |
|
1153 | 1255 | { |
1154 | 1256 | $isactive=false; |
1155 | 1257 | } |
@@ -1162,13 +1264,11 @@ discard block |
||
1162 | 1264 | if (!empty($links[$i][0])) |
1163 | 1265 | { |
1164 | 1266 | $out.='<a class="tabimage" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n"; |
1165 | - } |
|
1166 | - else |
|
1267 | + } else |
|
1167 | 1268 | { |
1168 | 1269 | $out.='<span class="tabspan">'.$links[$i][1].'</span>'."\n"; |
1169 | 1270 | } |
1170 | - } |
|
1171 | - else if (! empty($links[$i][1])) |
|
1271 | + } else if (! empty($links[$i][1])) |
|
1172 | 1272 | { |
1173 | 1273 | //print "x $i $active ".$links[$i][2]." z"; |
1174 | 1274 | if ($isactive) |
@@ -1176,8 +1276,7 @@ discard block |
||
1176 | 1276 | $out.='<a'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="tabactive tab inline-block" href="'.$links[$i][0].'">'; |
1177 | 1277 | $out.=$links[$i][1]; |
1178 | 1278 | $out.='</a>'."\n"; |
1179 | - } |
|
1180 | - else |
|
1279 | + } else |
|
1181 | 1280 | { |
1182 | 1281 | $out.='<a'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="tabunactive tab inline-block" href="'.$links[$i][0].'">'; |
1183 | 1282 | $out.=$links[$i][1]; |
@@ -1185,8 +1284,7 @@ discard block |
||
1185 | 1284 | } |
1186 | 1285 | } |
1187 | 1286 | $out.='</div>'; |
1188 | - } |
|
1189 | - else |
|
1287 | + } else |
|
1190 | 1288 | { |
1191 | 1289 | // The popup with the other tabs |
1192 | 1290 | if (! $popuptab) |
@@ -1197,13 +1295,13 @@ discard block |
||
1197 | 1295 | $outmore.='<div class="popuptab wordwrap" style="display:inherit;">'; |
1198 | 1296 | if (isset($links[$i][2]) && $links[$i][2] == 'image') |
1199 | 1297 | { |
1200 | - if (!empty($links[$i][0])) |
|
1201 | - $outmore.='<a class="tabimage" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n"; |
|
1202 | - else |
|
1203 | - $outmore.='<span class="tabspan">'.$links[$i][1].'</span>'."\n"; |
|
1298 | + if (!empty($links[$i][0])) { |
|
1299 | + $outmore.='<a class="tabimage" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n"; |
|
1300 | + } else { |
|
1301 | + $outmore.='<span class="tabspan">'.$links[$i][1].'</span>'."\n"; |
|
1302 | + } |
|
1204 | 1303 | |
1205 | - } |
|
1206 | - else if (! empty($links[$i][1])) |
|
1304 | + } else if (! empty($links[$i][1])) |
|
1207 | 1305 | { |
1208 | 1306 | $outmore.='<a'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="wordwrap inline-block" href="'.$links[$i][0].'">'; |
1209 | 1307 | $outmore.=preg_replace('/([a-z])\/([a-z])/i', '\\1 / \\2', $links[$i][1]); // Replace x/y with x / y to allow wrap on long composed texts. |
@@ -1215,7 +1313,9 @@ discard block |
||
1215 | 1313 | } |
1216 | 1314 | $displaytab=$i; |
1217 | 1315 | } |
1218 | - if ($popuptab) $outmore.='</div>'; |
|
1316 | + if ($popuptab) { |
|
1317 | + $outmore.='</div>'; |
|
1318 | + } |
|
1219 | 1319 | |
1220 | 1320 | if ($displaytab > $limittoshow) |
1221 | 1321 | { |
@@ -1239,7 +1339,9 @@ discard block |
||
1239 | 1339 | |
1240 | 1340 | $out.="</div>\n"; |
1241 | 1341 | |
1242 | - if (! $notab || $notab == -1) $out.="\n".'<div class="tabBar'.($notab == -1 ? '' : ' tabBarWithBottom').'">'."\n"; |
|
1342 | + if (! $notab || $notab == -1) { |
|
1343 | + $out.="\n".'<div class="tabBar'.($notab == -1 ? '' : ' tabBarWithBottom').'">'."\n"; |
|
1344 | + } |
|
1243 | 1345 | |
1244 | 1346 | $parameters=array('tabname' => $active, 'out' => $out); |
1245 | 1347 | $reshook=$hookmanager->executeHooks('printTabsHead',$parameters); // This hook usage is called just before output the head of tabs. Take also a look at "completeTabsHead" |
@@ -1270,9 +1372,12 @@ discard block |
||
1270 | 1372 | */ |
1271 | 1373 | function dol_get_fiche_end($notab=0) |
1272 | 1374 | { |
1273 | - if (! $notab || $notab == -1) return "\n</div>\n"; |
|
1274 | - else return ''; |
|
1275 | -} |
|
1375 | + if (! $notab || $notab == -1) { |
|
1376 | + return "\n</div>\n"; |
|
1377 | + } else { |
|
1378 | + return ''; |
|
1379 | + } |
|
1380 | + } |
|
1276 | 1381 | |
1277 | 1382 | /** |
1278 | 1383 | * Show tab footer of a card. |
@@ -1302,26 +1407,56 @@ discard block |
||
1302 | 1407 | $maxvisiblephotos=1; |
1303 | 1408 | $showimage=1; |
1304 | 1409 | $showbarcode=empty($conf->barcode->enabled)?0:($object->barcode?1:0); |
1305 | - if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; |
|
1410 | + if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { |
|
1411 | + $showbarcode=0; |
|
1412 | + } |
|
1306 | 1413 | $modulepart='unknown'; |
1307 | 1414 | |
1308 | - if ($object->element == 'societe') $modulepart='societe'; |
|
1309 | - if ($object->element == 'contact') $modulepart='contact'; |
|
1310 | - if ($object->element == 'member') $modulepart='memberphoto'; |
|
1311 | - if ($object->element == 'user') $modulepart='userphoto'; |
|
1312 | - if ($object->element == 'product') $modulepart='product'; |
|
1415 | + if ($object->element == 'societe') { |
|
1416 | + $modulepart='societe'; |
|
1417 | + } |
|
1418 | + if ($object->element == 'contact') { |
|
1419 | + $modulepart='contact'; |
|
1420 | + } |
|
1421 | + if ($object->element == 'member') { |
|
1422 | + $modulepart='memberphoto'; |
|
1423 | + } |
|
1424 | + if ($object->element == 'user') { |
|
1425 | + $modulepart='userphoto'; |
|
1426 | + } |
|
1427 | + if ($object->element == 'product') { |
|
1428 | + $modulepart='product'; |
|
1429 | + } |
|
1313 | 1430 | |
1314 | 1431 | if (class_exists("Imagick")) |
1315 | 1432 | { |
1316 | - if ($object->element == 'propal') $modulepart='propal'; |
|
1317 | - if ($object->element == 'commande') $modulepart='commande'; |
|
1318 | - if ($object->element == 'facture') $modulepart='facture'; |
|
1319 | - if ($object->element == 'fichinter') $modulepart='ficheinter'; |
|
1320 | - if ($object->element == 'contrat') $modulepart='contract'; |
|
1321 | - if ($object->element == 'supplier_proposal') $modulepart='supplier_proposal'; |
|
1322 | - if ($object->element == 'order_supplier') $modulepart='supplier_order'; |
|
1323 | - if ($object->element == 'invoice_supplier') $modulepart='supplier_invoice'; |
|
1324 | - if ($object->element == 'expensereport') $modulepart='expensereport'; |
|
1433 | + if ($object->element == 'propal') { |
|
1434 | + $modulepart='propal'; |
|
1435 | + } |
|
1436 | + if ($object->element == 'commande') { |
|
1437 | + $modulepart='commande'; |
|
1438 | + } |
|
1439 | + if ($object->element == 'facture') { |
|
1440 | + $modulepart='facture'; |
|
1441 | + } |
|
1442 | + if ($object->element == 'fichinter') { |
|
1443 | + $modulepart='ficheinter'; |
|
1444 | + } |
|
1445 | + if ($object->element == 'contrat') { |
|
1446 | + $modulepart='contract'; |
|
1447 | + } |
|
1448 | + if ($object->element == 'supplier_proposal') { |
|
1449 | + $modulepart='supplier_proposal'; |
|
1450 | + } |
|
1451 | + if ($object->element == 'order_supplier') { |
|
1452 | + $modulepart='supplier_order'; |
|
1453 | + } |
|
1454 | + if ($object->element == 'invoice_supplier') { |
|
1455 | + $modulepart='supplier_invoice'; |
|
1456 | + } |
|
1457 | + if ($object->element == 'expensereport') { |
|
1458 | + $modulepart='expensereport'; |
|
1459 | + } |
|
1325 | 1460 | } |
1326 | 1461 | |
1327 | 1462 | if ($object->element == 'product') |
@@ -1329,9 +1464,12 @@ discard block |
||
1329 | 1464 | $width=80; $cssclass='photoref'; |
1330 | 1465 | $showimage=$object->is_photo_available($conf->product->multidir_output[$object->entity]); |
1331 | 1466 | $maxvisiblephotos=(isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO)?$conf->global->PRODUCT_MAX_VISIBLE_PHOTO:5); |
1332 | - if ($conf->browser->phone) $maxvisiblephotos=1; |
|
1333 | - if ($showimage) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos($conf->product->multidir_output[$object->entity],'small',$maxvisiblephotos,0,0,0,$width,0).'</div>'; |
|
1334 | - else |
|
1467 | + if ($conf->browser->phone) { |
|
1468 | + $maxvisiblephotos=1; |
|
1469 | + } |
|
1470 | + if ($showimage) { |
|
1471 | + $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos($conf->product->multidir_output[$object->entity],'small',$maxvisiblephotos,0,0,0,$width,0).'</div>'; |
|
1472 | + } else |
|
1335 | 1473 | { |
1336 | 1474 | if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) { |
1337 | 1475 | $nophoto=''; |
@@ -1342,8 +1480,7 @@ discard block |
||
1342 | 1480 | $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo'.$modulepart.($cssclass?' '.$cssclass:'').'" alt="No photo" border="0"'.($width?' width="'.$width.'"':'').' src="'.DOL_URL_ROOT.$nophoto.'"></div>'; |
1343 | 1481 | //} |
1344 | 1482 | } |
1345 | - } |
|
1346 | - else |
|
1483 | + } else |
|
1347 | 1484 | { |
1348 | 1485 | if ($showimage) |
1349 | 1486 | { |
@@ -1358,8 +1495,7 @@ discard block |
||
1358 | 1495 | if (in_array($modulepart, array('invoice_supplier', 'supplier_invoice'))) |
1359 | 1496 | { |
1360 | 1497 | $subdir = get_exdir($object->id, 2, 0, 0, $object, $modulepart).$objectref; // the objectref dir is not include into get_exdir when used with level=2, so we add it here |
1361 | - } |
|
1362 | - else |
|
1498 | + } else |
|
1363 | 1499 | { |
1364 | 1500 | $subdir = get_exdir($object->id, 0, 0, 0, $object, $modulepart); |
1365 | 1501 | } |
@@ -1382,15 +1518,21 @@ discard block |
||
1382 | 1518 | && (! file_exists($fileimagebis) || (filemtime($fileimagebis) < filemtime($file))) |
1383 | 1519 | ) |
1384 | 1520 | { |
1385 | - if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) // If you experienc trouble with pdf thumb generation and imagick, you can disable here. |
|
1521 | + if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) { |
|
1522 | + // If you experienc trouble with pdf thumb generation and imagick, you can disable here. |
|
1386 | 1523 | { |
1387 | 1524 | $ret = dol_convert_file($file, 'png', $fileimage); |
1388 | - if ($ret < 0) $error++; |
|
1525 | + } |
|
1526 | + if ($ret < 0) { |
|
1527 | + $error++; |
|
1528 | + } |
|
1389 | 1529 | } |
1390 | 1530 | } |
1391 | 1531 | |
1392 | 1532 | $heightforphotref=70; |
1393 | - if (! empty($conf->dol_optimize_smallscreen)) $heightforphotref=60; |
|
1533 | + if (! empty($conf->dol_optimize_smallscreen)) { |
|
1534 | + $heightforphotref=60; |
|
1535 | + } |
|
1394 | 1536 | // Si fichier png PDF d'1 page trouve |
1395 | 1537 | if (file_exists($fileimage)) |
1396 | 1538 | { |
@@ -1407,8 +1549,7 @@ discard block |
||
1407 | 1549 | $phototoshow.= '</div></div>'; |
1408 | 1550 | } |
1409 | 1551 | } |
1410 | - } |
|
1411 | - else if (! $phototoshow) |
|
1552 | + } else if (! $phototoshow) |
|
1412 | 1553 | { |
1413 | 1554 | $phototoshow = $form->showphoto($modulepart,$object,0,0,0,'photoref','small',1,0,$maxvisiblephotos); |
1414 | 1555 | } |
@@ -1421,20 +1562,24 @@ discard block |
||
1421 | 1562 | } |
1422 | 1563 | } |
1423 | 1564 | |
1424 | - if (! $phototoshow) // Show No photo link (picto of pbject) |
|
1565 | + if (! $phototoshow) { |
|
1566 | + // Show No photo link (picto of pbject) |
|
1425 | 1567 | { |
1426 | 1568 | $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'; |
1569 | + } |
|
1427 | 1570 | if ($object->element == 'action') |
1428 | 1571 | { |
1429 | 1572 | $width=80; |
1430 | 1573 | $cssclass='photorefcenter'; |
1431 | 1574 | $nophoto=img_picto('', 'title_agenda', '', false, 1); |
1432 | - } |
|
1433 | - else |
|
1575 | + } else |
|
1434 | 1576 | { |
1435 | 1577 | $width=14; $cssclass='photorefcenter'; |
1436 | 1578 | $picto = $object->picto; |
1437 | - if ($object->element == 'project' && ! $object->public) $picto = 'project'; // instead of projectpub |
|
1579 | + if ($object->element == 'project' && ! $object->public) { |
|
1580 | + $picto = 'project'; |
|
1581 | + } |
|
1582 | + // instead of projectpub |
|
1438 | 1583 | $nophoto=img_picto('', 'object_'.$picto, '', false, 1); |
1439 | 1584 | } |
1440 | 1585 | $morehtmlleft.='<!-- No photo to show -->'; |
@@ -1445,19 +1590,19 @@ discard block |
||
1445 | 1590 | } |
1446 | 1591 | } |
1447 | 1592 | |
1448 | - if ($showbarcode) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode($object).'</div>'; |
|
1593 | + if ($showbarcode) { |
|
1594 | + $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode($object).'</div>'; |
|
1595 | + } |
|
1449 | 1596 | |
1450 | 1597 | if ($object->element == 'societe') |
1451 | 1598 | { |
1452 | 1599 | if (! empty($conf->use_javascript_ajax) && $user->rights->societe->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) |
1453 | 1600 | { |
1454 | 1601 | $morehtmlstatus.=ajax_object_onoff($object, 'status', 'status', 'InActivity', 'ActivityCeased'); |
1455 | - } |
|
1456 | - else { |
|
1602 | + } else { |
|
1457 | 1603 | $morehtmlstatus.=$object->getLibStatut(6); |
1458 | 1604 | } |
1459 | - } |
|
1460 | - elseif ($object->element == 'product') |
|
1605 | + } elseif ($object->element == 'product') |
|
1461 | 1606 | { |
1462 | 1607 | //$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Sell").') '; |
1463 | 1608 | if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { |
@@ -1472,26 +1617,32 @@ discard block |
||
1472 | 1617 | } else { |
1473 | 1618 | $morehtmlstatus.='<span class="statusrefbuy">'.$object->getLibStatut(5,1).'</span>'; |
1474 | 1619 | } |
1475 | - } |
|
1476 | - elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan'))) |
|
1620 | + } elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan'))) |
|
1477 | 1621 | { |
1478 | 1622 | $tmptxt=$object->getLibStatut(6, $object->totalpaye); |
1479 | - if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye); |
|
1623 | + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') { |
|
1624 | + $tmptxt=$object->getLibStatut(5, $object->totalpaye); |
|
1625 | + } |
|
1480 | 1626 | $morehtmlstatus.=$tmptxt; |
1481 | - } |
|
1482 | - elseif ($object->element == 'contrat' || $object->element == 'contract') |
|
1627 | + } elseif ($object->element == 'contrat' || $object->element == 'contract') |
|
1483 | 1628 | { |
1484 | - if ($object->statut == 0) $morehtmlstatus.=$object->getLibStatut(5); |
|
1485 | - else $morehtmlstatus.=$object->getLibStatut(4); |
|
1486 | - } |
|
1487 | - elseif ($object->element == 'facturerec') |
|
1629 | + if ($object->statut == 0) { |
|
1630 | + $morehtmlstatus.=$object->getLibStatut(5); |
|
1631 | + } else { |
|
1632 | + $morehtmlstatus.=$object->getLibStatut(4); |
|
1633 | + } |
|
1634 | + } elseif ($object->element == 'facturerec') |
|
1488 | 1635 | { |
1489 | - if ($object->frequency == 0) $morehtmlstatus.=$object->getLibStatut(2); |
|
1490 | - else $morehtmlstatus.=$object->getLibStatut(5); |
|
1491 | - } |
|
1492 | - else { // Generic case |
|
1636 | + if ($object->frequency == 0) { |
|
1637 | + $morehtmlstatus.=$object->getLibStatut(2); |
|
1638 | + } else { |
|
1639 | + $morehtmlstatus.=$object->getLibStatut(5); |
|
1640 | + } |
|
1641 | + } else { // Generic case |
|
1493 | 1642 | $tmptxt=$object->getLibStatut(6); |
1494 | - if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5); |
|
1643 | + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') { |
|
1644 | + $tmptxt=$object->getLibStatut(5); |
|
1645 | + } |
|
1495 | 1646 | $morehtmlstatus.=$tmptxt; |
1496 | 1647 | } |
1497 | 1648 | |
@@ -1507,12 +1658,16 @@ discard block |
||
1507 | 1658 | } |
1508 | 1659 | |
1509 | 1660 | // Add alias for thirdparty |
1510 | - if (! empty($object->name_alias)) $morehtmlref.='<div class="refidno">'.$object->name_alias.'</div>'; |
|
1661 | + if (! empty($object->name_alias)) { |
|
1662 | + $morehtmlref.='<div class="refidno">'.$object->name_alias.'</div>'; |
|
1663 | + } |
|
1511 | 1664 | |
1512 | 1665 | // Add label |
1513 | 1666 | if ($object->element == 'product' || $object->element == 'bank_account' || $object->element == 'project_task') |
1514 | 1667 | { |
1515 | - if (! empty($object->label)) $morehtmlref.='<div class="refidno">'.$object->label.'</div>'; |
|
1668 | + if (! empty($object->label)) { |
|
1669 | + $morehtmlref.='<div class="refidno">'.$object->label.'</div>'; |
|
1670 | + } |
|
1516 | 1671 | } |
1517 | 1672 | |
1518 | 1673 | if (method_exists($object, 'getBannerAddress') && $object->element != 'product' && $object->element != 'bookmark' && $object->element != 'ecm_directories' && $object->element != 'ecm_files') |
@@ -1546,11 +1701,19 @@ discard block |
||
1546 | 1701 | { |
1547 | 1702 | global $conf, $langs; |
1548 | 1703 | $ret=''; |
1549 | - if ($fieldrequired) $ret.='<span class="fieldrequired">'; |
|
1550 | - if (($conf->dol_use_jmobile != 4)) $ret.='<label for="'.$fieldkey.'">'; |
|
1704 | + if ($fieldrequired) { |
|
1705 | + $ret.='<span class="fieldrequired">'; |
|
1706 | + } |
|
1707 | + if (($conf->dol_use_jmobile != 4)) { |
|
1708 | + $ret.='<label for="'.$fieldkey.'">'; |
|
1709 | + } |
|
1551 | 1710 | $ret.=$langs->trans($langkey); |
1552 | - if (($conf->dol_use_jmobile != 4)) $ret.='</label>'; |
|
1553 | - if ($fieldrequired) $ret.='</span>'; |
|
1711 | + if (($conf->dol_use_jmobile != 4)) { |
|
1712 | + $ret.='</label>'; |
|
1713 | + } |
|
1714 | + if ($fieldrequired) { |
|
1715 | + $ret.='</span>'; |
|
1716 | + } |
|
1554 | 1717 | return $ret; |
1555 | 1718 | } |
1556 | 1719 | |
@@ -1565,7 +1728,9 @@ discard block |
||
1565 | 1728 | { |
1566 | 1729 | global $bc; |
1567 | 1730 | $ret=' '.$bc[$var]; |
1568 | - if ($moreclass) $ret=preg_replace('/class=\"/','class="'.$moreclass.' ',$ret); |
|
1731 | + if ($moreclass) { |
|
1732 | + $ret=preg_replace('/class=\"/','class="'.$moreclass.' ',$ret); |
|
1733 | + } |
|
1569 | 1734 | return $ret; |
1570 | 1735 | } |
1571 | 1736 | |
@@ -1592,40 +1757,48 @@ discard block |
||
1592 | 1757 | $ret .= $object->address; |
1593 | 1758 | } |
1594 | 1759 | // Zip/Town/State |
1595 | - if (in_array($object->country_code,array('AU', 'CA', 'US')) || ! empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)) // US: title firstname name \n address lines \n town, state, zip \n country |
|
1760 | + if (in_array($object->country_code,array('AU', 'CA', 'US')) || ! empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)) { |
|
1761 | + // US: title firstname name \n address lines \n town, state, zip \n country |
|
1596 | 1762 | { |
1597 | 1763 | $ret .= ($ret ? $sep : '' ).$object->town; |
1764 | + } |
|
1598 | 1765 | if ($object->state) |
1599 | 1766 | { |
1600 | 1767 | $ret.=($ret?", ":'').$object->state; |
1601 | 1768 | } |
1602 | - if ($object->zip) $ret .= ($ret?", ":'').$object->zip; |
|
1603 | - } |
|
1604 | - else if (in_array($object->country_code,array('GB','UK'))) // UK: title firstname name \n address lines \n town state \n zip \n country |
|
1769 | + if ($object->zip) { |
|
1770 | + $ret .= ($ret?", ":'').$object->zip; |
|
1771 | + } |
|
1772 | + } else if (in_array($object->country_code,array('GB','UK'))) { |
|
1773 | + // UK: title firstname name \n address lines \n town state \n zip \n country |
|
1605 | 1774 | { |
1606 | 1775 | $ret .= ($ret ? $sep : '' ).$object->town; |
1776 | + } |
|
1607 | 1777 | if ($object->state) |
1608 | 1778 | { |
1609 | 1779 | $ret.=($ret?", ":'').$object->state; |
1610 | 1780 | } |
1611 | - if ($object->zip) $ret .= ($ret ? $sep : '' ).$object->zip; |
|
1612 | - } |
|
1613 | - else if (in_array($object->country_code,array('ES','TR'))) // ES: title firstname name \n address lines \n zip town \n state \n country |
|
1781 | + if ($object->zip) { |
|
1782 | + $ret .= ($ret ? $sep : '' ).$object->zip; |
|
1783 | + } |
|
1784 | + } else if (in_array($object->country_code,array('ES','TR'))) { |
|
1785 | + // ES: title firstname name \n address lines \n zip town \n state \n country |
|
1614 | 1786 | { |
1615 | 1787 | $ret .= ($ret ? $sep : '' ).$object->zip; |
1788 | + } |
|
1616 | 1789 | $ret .= ($object->town?(($object->zip?' ':'').$object->town):''); |
1617 | 1790 | if ($object->state) |
1618 | 1791 | { |
1619 | 1792 | $ret.="\n".$object->state; |
1620 | 1793 | } |
1621 | - } |
|
1622 | - else if (in_array($object->country_code,array('IT'))) // IT: tile firstname name\n address lines \n zip (Code Departement) \n country |
|
1794 | + } else if (in_array($object->country_code,array('IT'))) { |
|
1795 | + // IT: tile firstname name\n address lines \n zip (Code Departement) \n country |
|
1623 | 1796 | { |
1624 | 1797 | $ret .= ($ret ? $sep : '' ).$object->zip; |
1798 | + } |
|
1625 | 1799 | $ret .= ($object->town?(($object->zip?' ':'').$object->town):''); |
1626 | 1800 | $ret .= ($object->departement_id?(' ('.($object->departement_id).')'):''); |
1627 | - } |
|
1628 | - else // Other: title firstname name \n address lines \n zip town \n country |
|
1801 | + } else // Other: title firstname name \n address lines \n zip town \n country |
|
1629 | 1802 | { |
1630 | 1803 | $ret .= $object->zip ? (($ret ? $sep : '' ).$object->zip) : ''; |
1631 | 1804 | $ret .= ($object->town?(($object->zip?' ':($ret ? $sep : '' )).$object->town):''); |
@@ -1634,8 +1807,12 @@ discard block |
||
1634 | 1807 | $ret.=($ret?", ":'').$object->state; |
1635 | 1808 | } |
1636 | 1809 | } |
1637 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
1638 | - if ($withcountry) $ret.=($object->country_code?($ret?$sep:'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->country_code)):''); |
|
1810 | + if (! is_object($outputlangs)) { |
|
1811 | + $outputlangs=$langs; |
|
1812 | + } |
|
1813 | + if ($withcountry) { |
|
1814 | + $ret.=($object->country_code?($ret?$sep:'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->country_code)):''); |
|
1815 | + } |
|
1639 | 1816 | |
1640 | 1817 | return $ret; |
1641 | 1818 | } |
@@ -1654,9 +1831,10 @@ discard block |
||
1654 | 1831 | { |
1655 | 1832 | if ((abs($ts) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range |
1656 | 1833 | return ($is_gmt)? @gmstrftime($fmt,$ts): @strftime($fmt,$ts); |
1834 | + } else { |
|
1835 | + return 'Error date into a not supported range'; |
|
1836 | + } |
|
1657 | 1837 | } |
1658 | - else return 'Error date into a not supported range'; |
|
1659 | -} |
|
1660 | 1838 | |
1661 | 1839 | /** |
1662 | 1840 | * Output date in a string format according to outputlangs (or langs if not defined). |
@@ -1697,8 +1875,7 @@ discard block |
||
1697 | 1875 | $offsettzstring=@date_default_timezone_get(); // Example 'Europe/Berlin' or 'Indian/Reunion' |
1698 | 1876 | $offsettz=0; |
1699 | 1877 | $offsetdst=0; |
1700 | - } |
|
1701 | - elseif ($tzoutput == 'tzuser' || $tzoutput == 'tzuserrel') |
|
1878 | + } elseif ($tzoutput == 'tzuser' || $tzoutput == 'tzuserrel') |
|
1702 | 1879 | { |
1703 | 1880 | $to_gmt=true; |
1704 | 1881 | $offsettzstring=(empty($_SESSION['dol_tz_string'])?'UTC':$_SESSION['dol_tz_string']); // Example 'Europe/Berlin' or 'Indian/Reunion' |
@@ -1707,31 +1884,57 @@ discard block |
||
1707 | 1884 | } |
1708 | 1885 | } |
1709 | 1886 | } |
1710 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
1711 | - if (! $format) $format='daytextshort'; |
|
1887 | + if (! is_object($outputlangs)) { |
|
1888 | + $outputlangs=$langs; |
|
1889 | + } |
|
1890 | + if (! $format) { |
|
1891 | + $format='daytextshort'; |
|
1892 | + } |
|
1712 | 1893 | $reduceformat=(! empty($conf->dol_optimize_smallscreen) && in_array($format,array('day','dayhour')))?1:0; |
1713 | 1894 | $formatwithoutreduce = preg_replace('/reduceformat/','',$format); |
1714 | 1895 | if ($formatwithoutreduce != $format) { $format = $formatwithoutreduce; $reduceformat=1; } // so format 'dayreduceformat' is processed like day |
1715 | 1896 | |
1716 | 1897 | // Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default. |
1717 | 1898 | // TODO Add format daysmallyear and dayhoursmallyear |
1718 | - if ($format == 'day') $format=($outputlangs->trans("FormatDateShort")!="FormatDateShort"?$outputlangs->trans("FormatDateShort"):$conf->format_date_short); |
|
1719 | - else if ($format == 'hour') $format=($outputlangs->trans("FormatHourShort")!="FormatHourShort"?$outputlangs->trans("FormatHourShort"):$conf->format_hour_short); |
|
1720 | - else if ($format == 'hourduration') $format=($outputlangs->trans("FormatHourShortDuration")!="FormatHourShortDuration"?$outputlangs->trans("FormatHourShortDuration"):$conf->format_hour_short_duration); |
|
1721 | - else if ($format == 'daytext') $format=($outputlangs->trans("FormatDateText")!="FormatDateText"?$outputlangs->trans("FormatDateText"):$conf->format_date_text); |
|
1722 | - else if ($format == 'daytextshort') $format=($outputlangs->trans("FormatDateTextShort")!="FormatDateTextShort"?$outputlangs->trans("FormatDateTextShort"):$conf->format_date_text_short); |
|
1723 | - else if ($format == 'dayhour') $format=($outputlangs->trans("FormatDateHourShort")!="FormatDateHourShort"?$outputlangs->trans("FormatDateHourShort"):$conf->format_date_hour_short); |
|
1724 | - else if ($format == 'dayhoursec') $format=($outputlangs->trans("FormatDateHourSecShort")!="FormatDateHourSecShort"?$outputlangs->trans("FormatDateHourSecShort"):$conf->format_date_hour_sec_short); |
|
1725 | - else if ($format == 'dayhourtext') $format=($outputlangs->trans("FormatDateHourText")!="FormatDateHourText"?$outputlangs->trans("FormatDateHourText"):$conf->format_date_hour_text); |
|
1726 | - else if ($format == 'dayhourtextshort') $format=($outputlangs->trans("FormatDateHourTextShort")!="FormatDateHourTextShort"?$outputlangs->trans("FormatDateHourTextShort"):$conf->format_date_hour_text_short); |
|
1899 | + if ($format == 'day') { |
|
1900 | + $format=($outputlangs->trans("FormatDateShort")!="FormatDateShort"?$outputlangs->trans("FormatDateShort"):$conf->format_date_short); |
|
1901 | + } else if ($format == 'hour') { |
|
1902 | + $format=($outputlangs->trans("FormatHourShort")!="FormatHourShort"?$outputlangs->trans("FormatHourShort"):$conf->format_hour_short); |
|
1903 | + } else if ($format == 'hourduration') { |
|
1904 | + $format=($outputlangs->trans("FormatHourShortDuration")!="FormatHourShortDuration"?$outputlangs->trans("FormatHourShortDuration"):$conf->format_hour_short_duration); |
|
1905 | + } else if ($format == 'daytext') { |
|
1906 | + $format=($outputlangs->trans("FormatDateText")!="FormatDateText"?$outputlangs->trans("FormatDateText"):$conf->format_date_text); |
|
1907 | + } else if ($format == 'daytextshort') { |
|
1908 | + $format=($outputlangs->trans("FormatDateTextShort")!="FormatDateTextShort"?$outputlangs->trans("FormatDateTextShort"):$conf->format_date_text_short); |
|
1909 | + } else if ($format == 'dayhour') { |
|
1910 | + $format=($outputlangs->trans("FormatDateHourShort")!="FormatDateHourShort"?$outputlangs->trans("FormatDateHourShort"):$conf->format_date_hour_short); |
|
1911 | + } else if ($format == 'dayhoursec') { |
|
1912 | + $format=($outputlangs->trans("FormatDateHourSecShort")!="FormatDateHourSecShort"?$outputlangs->trans("FormatDateHourSecShort"):$conf->format_date_hour_sec_short); |
|
1913 | + } else if ($format == 'dayhourtext') { |
|
1914 | + $format=($outputlangs->trans("FormatDateHourText")!="FormatDateHourText"?$outputlangs->trans("FormatDateHourText"):$conf->format_date_hour_text); |
|
1915 | + } else if ($format == 'dayhourtextshort') { |
|
1916 | + $format=($outputlangs->trans("FormatDateHourTextShort")!="FormatDateHourTextShort"?$outputlangs->trans("FormatDateHourTextShort"):$conf->format_date_hour_text_short); |
|
1917 | + } |
|
1727 | 1918 | // Format not sensitive to language |
1728 | - else if ($format == 'dayhourlog') $format='%Y%m%d%H%M%S'; |
|
1729 | - else if ($format == 'dayhourldap') $format='%Y%m%d%H%M%SZ'; |
|
1730 | - else if ($format == 'dayhourxcard') $format='%Y%m%dT%H%M%SZ'; |
|
1731 | - else if ($format == 'dayxcard') $format='%Y%m%d'; |
|
1732 | - else if ($format == 'dayrfc') $format='%Y-%m-%d'; // DATE_RFC3339 |
|
1733 | - else if ($format == 'dayhourrfc') $format='%Y-%m-%dT%H:%M:%SZ'; // DATETIME RFC3339 |
|
1734 | - else if ($format == 'standard') $format='%Y-%m-%d %H:%M:%S'; |
|
1919 | + else if ($format == 'dayhourlog') { |
|
1920 | + $format='%Y%m%d%H%M%S'; |
|
1921 | + } else if ($format == 'dayhourldap') { |
|
1922 | + $format='%Y%m%d%H%M%SZ'; |
|
1923 | + } else if ($format == 'dayhourxcard') { |
|
1924 | + $format='%Y%m%dT%H%M%SZ'; |
|
1925 | + } else if ($format == 'dayxcard') { |
|
1926 | + $format='%Y%m%d'; |
|
1927 | + } else if ($format == 'dayrfc') { |
|
1928 | + $format='%Y-%m-%d'; |
|
1929 | + } |
|
1930 | + // DATE_RFC3339 |
|
1931 | + else if ($format == 'dayhourrfc') { |
|
1932 | + $format='%Y-%m-%dT%H:%M:%SZ'; |
|
1933 | + } |
|
1934 | + // DATETIME RFC3339 |
|
1935 | + else if ($format == 'standard') { |
|
1936 | + $format='%Y-%m-%d %H:%M:%S'; |
|
1937 | + } |
|
1735 | 1938 | |
1736 | 1939 | if ($reduceformat) |
1737 | 1940 | { |
@@ -1740,29 +1943,38 @@ discard block |
||
1740 | 1943 | } |
1741 | 1944 | |
1742 | 1945 | // If date undefined or "", we return "" |
1743 | - if (dol_strlen($time) == 0) return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) |
|
1946 | + if (dol_strlen($time) == 0) { |
|
1947 | + return ''; |
|
1948 | + } |
|
1949 | + // $time=0 allowed (it means 01/01/1970 00:00:00) |
|
1744 | 1950 | |
1745 | 1951 | // Clean format |
1746 | - if (preg_match('/%b/i',$format)) // There is some text to translate |
|
1952 | + if (preg_match('/%b/i',$format)) { |
|
1953 | + // There is some text to translate |
|
1747 | 1954 | { |
1748 | 1955 | // We inhibate translation to text made by strftime functions. We will use trans instead later. |
1749 | 1956 | $format=str_replace('%b','__b__',$format); |
1957 | + } |
|
1750 | 1958 | $format=str_replace('%B','__B__',$format); |
1751 | 1959 | } |
1752 | - if (preg_match('/%a/i',$format)) // There is some text to translate |
|
1960 | + if (preg_match('/%a/i',$format)) { |
|
1961 | + // There is some text to translate |
|
1753 | 1962 | { |
1754 | 1963 | // We inhibate translation to text made by strftime functions. We will use trans instead later. |
1755 | 1964 | $format=str_replace('%a','__a__',$format); |
1965 | + } |
|
1756 | 1966 | $format=str_replace('%A','__A__',$format); |
1757 | 1967 | } |
1758 | 1968 | |
1759 | 1969 | // Analyze date |
1760 | 1970 | if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i',$time,$reg) |
1761 | - || preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i',$time,$reg)) // Deprecated. Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000 |
|
1971 | + || preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i',$time,$reg)) { |
|
1972 | + // Deprecated. Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000 |
|
1762 | 1973 | { |
1763 | 1974 | // TODO Remove this. |
1764 | 1975 | // This part of code should not be used. |
1765 | 1976 | dol_syslog("Functions.lib::dol_print_date function call with deprecated value of time in page ".$_SERVER["PHP_SELF"], LOG_ERR); |
1977 | + } |
|
1766 | 1978 | // Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' or 'YYYYMMDDHHMMSS' |
1767 | 1979 | $syear = (! empty($reg[1]) ? $reg[1] : ''); |
1768 | 1980 | $smonth = (! empty($reg[2]) ? $reg[2] : ''); |
@@ -1773,17 +1985,20 @@ discard block |
||
1773 | 1985 | |
1774 | 1986 | $time=dol_mktime($shour,$smin,$ssec,$smonth,$sday,$syear,true); |
1775 | 1987 | $ret=adodb_strftime($format, $time+$offsettz+$offsetdst, $to_gmt); |
1776 | - } |
|
1777 | - else |
|
1988 | + } else |
|
1778 | 1989 | { |
1779 | 1990 | // Date is a timestamps |
1780 | - if ($time < 100000000000) // Protection against bad date values |
|
1991 | + if ($time < 100000000000) { |
|
1992 | + // Protection against bad date values |
|
1781 | 1993 | { |
1782 | - $timetouse = $time+$offsettz+$offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. |
|
1994 | + $timetouse = $time+$offsettz+$offsetdst; |
|
1995 | + } |
|
1996 | + // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. |
|
1783 | 1997 | |
1784 | 1998 | $ret=adodb_strftime($format, $timetouse, $to_gmt); |
1999 | + } else { |
|
2000 | + $ret='Bad value '.$time.' for date'; |
|
1785 | 2001 | } |
1786 | - else $ret='Bad value '.$time.' for date'; |
|
1787 | 2002 | } |
1788 | 2003 | |
1789 | 2004 | if (preg_match('/__b__/i',$format)) |
@@ -1797,8 +2012,7 @@ discard block |
||
1797 | 2012 | { |
1798 | 2013 | $monthtext=$outputlangs->transnoentities('Month'.$month); |
1799 | 2014 | $monthtextshort=$outputlangs->transnoentities('MonthShort'.$month); |
1800 | - } |
|
1801 | - else |
|
2015 | + } else |
|
1802 | 2016 | { |
1803 | 2017 | $monthtext=$outputlangs->transnoentitiesnoconv('Month'.$month); |
1804 | 2018 | $monthtextshort=$outputlangs->transnoentitiesnoconv('MonthShort'.$month); |
@@ -1861,14 +2075,19 @@ discard block |
||
1861 | 2075 | global $conf; |
1862 | 2076 | |
1863 | 2077 | $usealternatemethod=false; |
1864 | - if ($timestamp <= 0) $usealternatemethod=true; // <= 1970 |
|
1865 | - if ($timestamp >= 2145913200) $usealternatemethod=true; // >= 2038 |
|
2078 | + if ($timestamp <= 0) { |
|
2079 | + $usealternatemethod=true; |
|
2080 | + } |
|
2081 | + // <= 1970 |
|
2082 | + if ($timestamp >= 2145913200) { |
|
2083 | + $usealternatemethod=true; |
|
2084 | + } |
|
2085 | + // >= 2038 |
|
1866 | 2086 | |
1867 | 2087 | if ($usealternatemethod) |
1868 | 2088 | { |
1869 | 2089 | $arrayinfo=adodb_getdate($timestamp,$fast); |
1870 | - } |
|
1871 | - else |
|
2090 | + } else |
|
1872 | 2091 | { |
1873 | 2092 | $arrayinfo=getdate($timestamp); |
1874 | 2093 | } |
@@ -1901,19 +2120,37 @@ discard block |
||
1901 | 2120 | //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -"; |
1902 | 2121 | |
1903 | 2122 | // Clean parameters |
1904 | - if ($hour == -1 || empty($hour)) $hour=0; |
|
1905 | - if ($minute == -1 || empty($minute)) $minute=0; |
|
1906 | - if ($second == -1 || empty($second)) $second=0; |
|
2123 | + if ($hour == -1 || empty($hour)) { |
|
2124 | + $hour=0; |
|
2125 | + } |
|
2126 | + if ($minute == -1 || empty($minute)) { |
|
2127 | + $minute=0; |
|
2128 | + } |
|
2129 | + if ($second == -1 || empty($second)) { |
|
2130 | + $second=0; |
|
2131 | + } |
|
1907 | 2132 | |
1908 | 2133 | // Check parameters |
1909 | 2134 | if ($check) |
1910 | 2135 | { |
1911 | - if (! $month || ! $day) return ''; |
|
1912 | - if ($day > 31) return ''; |
|
1913 | - if ($month > 12) return ''; |
|
1914 | - if ($hour < 0 || $hour > 24) return ''; |
|
1915 | - if ($minute< 0 || $minute > 60) return ''; |
|
1916 | - if ($second< 0 || $second > 60) return ''; |
|
2136 | + if (! $month || ! $day) { |
|
2137 | + return ''; |
|
2138 | + } |
|
2139 | + if ($day > 31) { |
|
2140 | + return ''; |
|
2141 | + } |
|
2142 | + if ($month > 12) { |
|
2143 | + return ''; |
|
2144 | + } |
|
2145 | + if ($hour < 0 || $hour > 24) { |
|
2146 | + return ''; |
|
2147 | + } |
|
2148 | + if ($minute< 0 || $minute > 60) { |
|
2149 | + return ''; |
|
2150 | + } |
|
2151 | + if ($second< 0 || $second > 60) { |
|
2152 | + return ''; |
|
2153 | + } |
|
1917 | 2154 | } |
1918 | 2155 | |
1919 | 2156 | if (method_exists('DateTime','getTimestamp')) |
@@ -1922,28 +2159,24 @@ discard block |
||
1922 | 2159 | { |
1923 | 2160 | $default_timezone=@date_default_timezone_get(); // Example 'Europe/Berlin' |
1924 | 2161 | $localtz = new DateTimeZone($default_timezone); |
1925 | - } |
|
1926 | - else if ($gm === 'user') |
|
2162 | + } else if ($gm === 'user') |
|
1927 | 2163 | { |
1928 | 2164 | // We use dol_tz_string first because it is more reliable. |
1929 | 2165 | $default_timezone=(empty($_SESSION["dol_tz_string"])?@date_default_timezone_get():$_SESSION["dol_tz_string"]); // Example 'Europe/Berlin' |
1930 | 2166 | try { |
1931 | 2167 | $localtz = new DateTimeZone($default_timezone); |
1932 | - } |
|
1933 | - catch(Exception $e) |
|
2168 | + } catch(Exception $e) |
|
1934 | 2169 | { |
1935 | 2170 | dol_syslog("Warning dol_tz_string contains an invalid value ".$_SESSION["dol_tz_string"], LOG_WARNING); |
1936 | 2171 | $default_timezone=@date_default_timezone_get(); |
1937 | 2172 | } |
1938 | - } |
|
1939 | - else if (strrpos($gm, "tz,") !== false) |
|
2173 | + } else if (strrpos($gm, "tz,") !== false) |
|
1940 | 2174 | { |
1941 | 2175 | $timezone=str_replace("tz,", "", $gm); // Example 'tz,Europe/Berlin' |
1942 | 2176 | try |
1943 | 2177 | { |
1944 | 2178 | $localtz = new DateTimeZone($timezone); |
1945 | - } |
|
1946 | - catch(Exception $e) |
|
2179 | + } catch(Exception $e) |
|
1947 | 2180 | { |
1948 | 2181 | dol_syslog("Warning passed timezone contains an invalid value ".$timezone, LOG_WARNING); |
1949 | 2182 | } |
@@ -1960,8 +2193,7 @@ discard block |
||
1960 | 2193 | $date=$dt->getTimestamp(); // should include daylight saving time |
1961 | 2194 | //var_dump($date); |
1962 | 2195 | return $date; |
1963 | - } |
|
1964 | - else |
|
2196 | + } else |
|
1965 | 2197 | { |
1966 | 2198 | dol_print_error('','PHP version must be 5.3+'); |
1967 | 2199 | return ''; |
@@ -1984,10 +2216,15 @@ discard block |
||
1984 | 2216 | |
1985 | 2217 | // Note that gmmktime and mktime return same value (GMT) when used without parameters |
1986 | 2218 | //if ($mode == 'gmt') $ret=gmmktime(); // Strict Standards: gmmktime(): You should be using the time() function instead |
1987 | - if ($mode == 'gmt') $ret=time(); // Time for now at greenwich. |
|
1988 | - else if ($mode == 'tzserver') // Time for now with PHP server timezone added |
|
2219 | + if ($mode == 'gmt') { |
|
2220 | + $ret=time(); |
|
2221 | + } |
|
2222 | + // Time for now at greenwich. |
|
2223 | + else if ($mode == 'tzserver') { |
|
2224 | + // Time for now with PHP server timezone added |
|
1989 | 2225 | { |
1990 | 2226 | require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
2227 | + } |
|
1991 | 2228 | $tzsecond=getServerTimeZoneInt('now'); // Contains tz+dayling saving time |
1992 | 2229 | $ret=(int) dol_now('gmt')+($tzsecond*3600); |
1993 | 2230 | } |
@@ -1997,10 +2234,12 @@ discard block |
||
1997 | 2234 | $tzsecond=getParentCompanyTimeZoneInt(); // Contains tz+dayling saving time |
1998 | 2235 | $ret=dol_now('gmt')+($tzsecond*3600); |
1999 | 2236 | }*/ |
2000 | - else if ($mode == 'tzuser') // Time for now with user timezone added |
|
2237 | + else if ($mode == 'tzuser') { |
|
2238 | + // Time for now with user timezone added |
|
2001 | 2239 | { |
2002 | 2240 | //print 'eeee'.time().'-'.mktime().'-'.gmmktime(); |
2003 | 2241 | $offsettz=(empty($_SESSION['dol_tz'])?0:$_SESSION['dol_tz'])*60*60; |
2242 | + } |
|
2004 | 2243 | $offsetdst=(empty($_SESSION['dol_dst'])?0:$_SESSION['dol_dst'])*60*60; |
2005 | 2244 | $ret=(int) dol_now('gmt')+($offsettz+$offsetdst); |
2006 | 2245 | } |
@@ -2022,7 +2261,9 @@ discard block |
||
2022 | 2261 | global $conf,$langs; |
2023 | 2262 | $level=1024; |
2024 | 2263 | |
2025 | - if (! empty($conf->dol_optimize_smallscreen)) $shortunit=1; |
|
2264 | + if (! empty($conf->dol_optimize_smallscreen)) { |
|
2265 | + $shortunit=1; |
|
2266 | + } |
|
2026 | 2267 | |
2027 | 2268 | // Set value text |
2028 | 2269 | if (empty($shortvalue) || $size < ($level*10)) |
@@ -2030,16 +2271,14 @@ discard block |
||
2030 | 2271 | $ret=$size; |
2031 | 2272 | $textunitshort=$langs->trans("b"); |
2032 | 2273 | $textunitlong=$langs->trans("Bytes"); |
2033 | - } |
|
2034 | - else |
|
2274 | + } else |
|
2035 | 2275 | { |
2036 | 2276 | $ret=round($size/$level,0); |
2037 | 2277 | $textunitshort=$langs->trans("Kb"); |
2038 | 2278 | $textunitlong=$langs->trans("KiloBytes"); |
2039 | 2279 | } |
2040 | 2280 | // Use long or short text unit |
2041 | - if (empty($shortunit)) { $ret.=' '.$textunitlong; } |
|
2042 | - else { $ret.=' '.$textunitshort; } |
|
2281 | + if (empty($shortunit)) { $ret.=' '.$textunitlong; } else { $ret.=' '.$textunitshort; } |
|
2043 | 2282 | |
2044 | 2283 | return $ret; |
2045 | 2284 | } |
@@ -2057,15 +2296,23 @@ discard block |
||
2057 | 2296 | { |
2058 | 2297 | global $langs; |
2059 | 2298 | |
2060 | - if (empty($url)) return ''; |
|
2299 | + if (empty($url)) { |
|
2300 | + return ''; |
|
2301 | + } |
|
2061 | 2302 | |
2062 | 2303 | $link='<a href="'; |
2063 | - if (! preg_match('/^http/i',$url)) $link.='http://'; |
|
2304 | + if (! preg_match('/^http/i',$url)) { |
|
2305 | + $link.='http://'; |
|
2306 | + } |
|
2064 | 2307 | $link.=$url; |
2065 | 2308 | $link.='"'; |
2066 | - if ($target) $link.=' target="'.$target.'"'; |
|
2309 | + if ($target) { |
|
2310 | + $link.=' target="'.$target.'"'; |
|
2311 | + } |
|
2067 | 2312 | $link.='>'; |
2068 | - if (! preg_match('/^http/i',$url)) $link.='http://'; |
|
2313 | + if (! preg_match('/^http/i',$url)) { |
|
2314 | + $link.='http://'; |
|
2315 | + } |
|
2069 | 2316 | $link.=dol_trunc($url,$max); |
2070 | 2317 | $link.='</a>'; |
2071 | 2318 | return '<div class="nospan float" style="margin-right: 10px">'.($withpicto?img_picto($langs->trans("Url"), 'object_globe.png').' ':'').$link.'</div>'; |
@@ -2089,12 +2336,16 @@ discard block |
||
2089 | 2336 | |
2090 | 2337 | $newemail=$email; |
2091 | 2338 | |
2092 | - if (empty($email)) return ' '; |
|
2339 | + if (empty($email)) { |
|
2340 | + return ' '; |
|
2341 | + } |
|
2093 | 2342 | |
2094 | 2343 | if (! empty($addlink)) |
2095 | 2344 | { |
2096 | 2345 | $newemail='<a style="text-overflow: ellipsis;" href="'; |
2097 | - if (! preg_match('/^mailto:/i',$email)) $newemail.='mailto:'; |
|
2346 | + if (! preg_match('/^mailto:/i',$email)) { |
|
2347 | + $newemail.='mailto:'; |
|
2348 | + } |
|
2098 | 2349 | $newemail.=$email; |
2099 | 2350 | $newemail.='">'; |
2100 | 2351 | $newemail.=dol_trunc($email,$max); |
@@ -2108,11 +2359,14 @@ discard block |
||
2108 | 2359 | if (($cid || $socid) && ! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) |
2109 | 2360 | { |
2110 | 2361 | $type='AC_EMAIL'; $link=''; |
2111 | - if (! empty($conf->global->AGENDA_ADDACTIONFOREMAIL)) $link='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&actioncode='.$type.'&contactid='.$cid.'&socid='.$socid.'">'.img_object($langs->trans("AddAction"),"calendar").'</a>'; |
|
2112 | - if ($link) $newemail='<div>'.$newemail.' '.$link.'</div>'; |
|
2362 | + if (! empty($conf->global->AGENDA_ADDACTIONFOREMAIL)) { |
|
2363 | + $link='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&actioncode='.$type.'&contactid='.$cid.'&socid='.$socid.'">'.img_object($langs->trans("AddAction"),"calendar").'</a>'; |
|
2364 | + } |
|
2365 | + if ($link) { |
|
2366 | + $newemail='<div>'.$newemail.' '.$link.'</div>'; |
|
2367 | + } |
|
2113 | 2368 | } |
2114 | - } |
|
2115 | - else |
|
2369 | + } else |
|
2116 | 2370 | { |
2117 | 2371 | if ($showinvalid && ! isValidEmail($email)) |
2118 | 2372 | { |
@@ -2139,7 +2393,9 @@ discard block |
||
2139 | 2393 | |
2140 | 2394 | $newskype=$skype; |
2141 | 2395 | |
2142 | - if (empty($skype)) return ' '; |
|
2396 | + if (empty($skype)) { |
|
2397 | + return ' '; |
|
2398 | + } |
|
2143 | 2399 | |
2144 | 2400 | if (! empty($addlink)) |
2145 | 2401 | { |
@@ -2160,11 +2416,12 @@ discard block |
||
2160 | 2416 | if (($cid || $socid) && ! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) |
2161 | 2417 | { |
2162 | 2418 | $type='AC_SKYPE'; $link=''; |
2163 | - if (! empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) $link='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&actioncode='.$type.'&contactid='.$cid.'&socid='.$socid.'">'.img_object($langs->trans("AddAction"),"calendar").'</a>'; |
|
2419 | + if (! empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) { |
|
2420 | + $link='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&actioncode='.$type.'&contactid='.$cid.'&socid='.$socid.'">'.img_object($langs->trans("AddAction"),"calendar").'</a>'; |
|
2421 | + } |
|
2164 | 2422 | $newskype='<div class="divskype nowrap">'.$newskype.($link?' '.$link:'').'</div>'; |
2165 | 2423 | } |
2166 | - } |
|
2167 | - else |
|
2424 | + } else |
|
2168 | 2425 | { |
2169 | 2426 | $langs->load("errors"); |
2170 | 2427 | $newskype.=img_warning($langs->trans("ErrorBadSkype",$skype)); |
@@ -2193,10 +2450,14 @@ discard block |
||
2193 | 2450 | // Clean phone parameter |
2194 | 2451 | $phone = preg_replace("/[\s.-]/","",trim($phone)); |
2195 | 2452 | if (empty($phone)) { return ''; } |
2196 | - if (empty($countrycode)) $countrycode=$mysoc->country_code; |
|
2453 | + if (empty($countrycode)) { |
|
2454 | + $countrycode=$mysoc->country_code; |
|
2455 | + } |
|
2197 | 2456 | |
2198 | 2457 | // Short format for small screens |
2199 | - if ($conf->dol_optimize_smallscreen) $separ=''; |
|
2458 | + if ($conf->dol_optimize_smallscreen) { |
|
2459 | + $separ=''; |
|
2460 | + } |
|
2200 | 2461 | |
2201 | 2462 | $newphone=$phone; |
2202 | 2463 | if (strtoupper($countrycode) == "FR") |
@@ -2204,297 +2465,257 @@ discard block |
||
2204 | 2465 | // France |
2205 | 2466 | if (dol_strlen($phone) == 10) { |
2206 | 2467 | $newphone=substr($newphone,0,2).$separ.substr($newphone,2,2).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2); |
2207 | - } |
|
2208 | - elseif (dol_strlen($phone) == 7) |
|
2468 | + } elseif (dol_strlen($phone) == 7) |
|
2209 | 2469 | { |
2210 | 2470 | $newphone=substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,2); |
2211 | - } |
|
2212 | - elseif (dol_strlen($phone) == 9) |
|
2471 | + } elseif (dol_strlen($phone) == 9) |
|
2213 | 2472 | { |
2214 | 2473 | $newphone=substr($newphone,0,2).$separ.substr($newphone,2,3).$separ.substr($newphone,5,2).$separ.substr($newphone,7,2); |
2215 | - } |
|
2216 | - elseif (dol_strlen($phone) == 11) |
|
2474 | + } elseif (dol_strlen($phone) == 11) |
|
2217 | 2475 | { |
2218 | 2476 | $newphone=substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,2).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2); |
2219 | - } |
|
2220 | - elseif (dol_strlen($phone) == 12) |
|
2477 | + } elseif (dol_strlen($phone) == 12) |
|
2221 | 2478 | { |
2222 | 2479 | $newphone=substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); |
2223 | 2480 | } |
2224 | - } |
|
2225 | - |
|
2226 | - elseif (strtoupper($countrycode) == "CA") |
|
2481 | + } elseif (strtoupper($countrycode) == "CA") |
|
2227 | 2482 | { |
2228 | 2483 | if (dol_strlen($phone) == 10) { |
2229 | 2484 | $newphone=($separ!=''?'(':'').substr($newphone,0,3).($separ!=''?')':'').$separ.substr($newphone,3,3).($separ!=''?'-':'').substr($newphone,6,4); |
2230 | 2485 | } |
2231 | - } |
|
2232 | - elseif (strtoupper($countrycode) == "PT" ) |
|
2486 | + } elseif (strtoupper($countrycode) == "PT" ) |
|
2233 | 2487 | {//Portugal |
2234 | 2488 | if (dol_strlen($phone) == 13) |
2235 | 2489 | {//ex: +351_ABC_DEF_GHI |
2236 | 2490 | $newphone= substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3).$separ.substr($newphone,10,3); |
2237 | 2491 | } |
2238 | - } |
|
2239 | - elseif (strtoupper($countrycode) == "SR" ) |
|
2492 | + } elseif (strtoupper($countrycode) == "SR" ) |
|
2240 | 2493 | {//Suriname |
2241 | 2494 | if (dol_strlen($phone) == 10) |
2242 | 2495 | {//ex: +597_ABC_DEF |
2243 | 2496 | $newphone= substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3); |
2244 | - } |
|
2245 | - elseif (dol_strlen($phone) == 11) |
|
2497 | + } elseif (dol_strlen($phone) == 11) |
|
2246 | 2498 | {//ex: +597_ABC_DEFG |
2247 | 2499 | $newphone= substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,4); |
2248 | 2500 | } |
2249 | - } |
|
2250 | - elseif (strtoupper($countrycode) == "DE" ) |
|
2501 | + } elseif (strtoupper($countrycode) == "DE" ) |
|
2251 | 2502 | {//Allemagne |
2252 | 2503 | if (dol_strlen($phone) == 14) |
2253 | 2504 | {//ex: +49_ABCD_EFGH_IJK |
2254 | 2505 | $newphone= substr($newphone,0,3).$separ.substr($newphone,3,4).$separ.substr($newphone,7,4).$separ.substr($newphone,11,3); |
2255 | - } |
|
2256 | - elseif (dol_strlen($phone) == 13) |
|
2506 | + } elseif (dol_strlen($phone) == 13) |
|
2257 | 2507 | {//ex: +49_ABC_DEFG_HIJ |
2258 | 2508 | $newphone= substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,4).$separ.substr($newphone,10,3); |
2259 | 2509 | } |
2260 | - } |
|
2261 | - elseif (strtoupper($countrycode) == "ES") |
|
2510 | + } elseif (strtoupper($countrycode) == "ES") |
|
2262 | 2511 | {//Espagne |
2263 | 2512 | if (dol_strlen($phone) == 12) |
2264 | 2513 | {//ex: +34_ABC_DEF_GHI |
2265 | 2514 | $newphone= substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,3); |
2266 | 2515 | } |
2267 | - } |
|
2268 | - elseif (strtoupper($countrycode) == "BF") |
|
2516 | + } elseif (strtoupper($countrycode) == "BF") |
|
2269 | 2517 | {// Burkina Faso |
2270 | 2518 | if (dol_strlen($phone) == 12) |
2271 | 2519 | {//ex : +22 A BC_DE_FG_HI |
2272 | 2520 | $newphone= substr($newphone,0,3).$separ.substr($newphone,3,1).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); |
2273 | 2521 | } |
2274 | - } |
|
2275 | - elseif (strtoupper($countrycode) == "RO") |
|
2522 | + } elseif (strtoupper($countrycode) == "RO") |
|
2276 | 2523 | {// Roumanie |
2277 | 2524 | if (dol_strlen($phone) == 12) |
2278 | 2525 | {//ex : +40 AB_CDE_FG_HI |
2279 | 2526 | $newphone= substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,3).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); |
2280 | 2527 | } |
2281 | - } |
|
2282 | - elseif (strtoupper($countrycode) == "TR") |
|
2528 | + } elseif (strtoupper($countrycode) == "TR") |
|
2283 | 2529 | {//Turquie |
2284 | 2530 | if (dol_strlen($phone) == 13) |
2285 | 2531 | {//ex : +90 ABC_DEF_GHIJ |
2286 | 2532 | $newphone= substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,4); |
2287 | 2533 | } |
2288 | - } |
|
2289 | - elseif (strtoupper($countrycode) == "US") |
|
2534 | + } elseif (strtoupper($countrycode) == "US") |
|
2290 | 2535 | {//Etat-Unis |
2291 | 2536 | if (dol_strlen($phone) == 12) |
2292 | 2537 | {//ex: +1 ABC_DEF_GHIJ |
2293 | 2538 | $newphone= substr($newphone,0,2).$separ.substr($newphone,2,3).$separ.substr($newphone,5,3).$separ.substr($newphone,8,4); |
2294 | 2539 | } |
2295 | - } |
|
2296 | - elseif (strtoupper($countrycode) == "MX") |
|
2540 | + } elseif (strtoupper($countrycode) == "MX") |
|
2297 | 2541 | {//Mexique |
2298 | 2542 | if (dol_strlen($phone) == 12) |
2299 | 2543 | {//ex: +52 ABCD_EFG_HI |
2300 | 2544 | $newphone = substr($newphone,0,3).$separ.substr($newphone,3,4).$separ.substr($newphone,7,3).$separ.substr($newphone,10,2); |
2301 | - } |
|
2302 | - elseif (dol_strlen($phone) == 11) |
|
2545 | + } elseif (dol_strlen($phone) == 11) |
|
2303 | 2546 | {//ex: +52 AB_CD_EF_GH |
2304 | 2547 | $newphone = substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,2).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2); |
2305 | - } |
|
2306 | - elseif (dol_strlen($phone) == 13) |
|
2548 | + } elseif (dol_strlen($phone) == 13) |
|
2307 | 2549 | {//ex: +52 ABC_DEF_GHIJ |
2308 | 2550 | $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,4); |
2309 | 2551 | } |
2310 | - } |
|
2311 | - elseif (strtoupper($countrycode) == "ML") |
|
2552 | + } elseif (strtoupper($countrycode) == "ML") |
|
2312 | 2553 | {//Mali |
2313 | 2554 | if(dol_strlen($phone) == 12) |
2314 | 2555 | {//ex: +223 AB_CD_EF_GH |
2315 | 2556 | $newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); |
2316 | 2557 | } |
2317 | - } |
|
2318 | - elseif (strtoupper($countrycode) == "TH") |
|
2558 | + } elseif (strtoupper($countrycode) == "TH") |
|
2319 | 2559 | {//Thaïlande |
2320 | 2560 | if(dol_strlen($phone) == 11) |
2321 | 2561 | {//ex: +66_ABC_DE_FGH |
2322 | 2562 | $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,2).$separ.substr($newphone,8,3); |
2323 | - } |
|
2324 | - elseif(dol_strlen($phone) == 12) |
|
2563 | + } elseif(dol_strlen($phone) == 12) |
|
2325 | 2564 | {//ex: +66_A_BCD_EF_GHI |
2326 | 2565 | $newphone = substr($newphone,0,3).$separ.substr($newphone,3,1).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,3); |
2327 | 2566 | } |
2328 | - } |
|
2329 | - elseif (strtoupper($countrycode) == "MU") |
|
2567 | + } elseif (strtoupper($countrycode) == "MU") |
|
2330 | 2568 | {//Maurice |
2331 | 2569 | if(dol_strlen($phone) == 11) |
2332 | 2570 | {//ex: +230_ABC_DE_FG |
2333 | 2571 | $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2); |
2334 | - } |
|
2335 | - elseif(dol_strlen($phone) == 12) |
|
2572 | + } elseif(dol_strlen($phone) == 12) |
|
2336 | 2573 | {//ex: +230_ABCD_EF_GH |
2337 | 2574 | $newphone = substr($newphone,0,4).$separ.substr($newphone,4,4).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); |
2338 | 2575 | } |
2339 | - } |
|
2340 | - elseif (strtoupper($countrycode) == "ZA") |
|
2576 | + } elseif (strtoupper($countrycode) == "ZA") |
|
2341 | 2577 | {//Afrique du sud |
2342 | 2578 | if(dol_strlen($phone) == 12) |
2343 | 2579 | {//ex: +27_AB_CDE_FG_HI |
2344 | 2580 | $newphone = substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,3).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); |
2345 | 2581 | } |
2346 | - } |
|
2347 | - elseif (strtoupper($countrycode) == "SY") |
|
2582 | + } elseif (strtoupper($countrycode) == "SY") |
|
2348 | 2583 | {//Syrie |
2349 | 2584 | if(dol_strlen($phone) == 12) |
2350 | 2585 | {//ex: +963_AB_CD_EF_GH |
2351 | 2586 | $newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); |
2352 | - } |
|
2353 | - elseif(dol_strlen($phone) == 13) |
|
2587 | + } elseif(dol_strlen($phone) == 13) |
|
2354 | 2588 | {//ex: +963_AB_CD_EF_GHI |
2355 | 2589 | $newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,3); |
2356 | 2590 | } |
2357 | - } |
|
2358 | - elseif (strtoupper($countrycode) == "AE") |
|
2591 | + } elseif (strtoupper($countrycode) == "AE") |
|
2359 | 2592 | {//Emirats Arabes Unis |
2360 | 2593 | if(dol_strlen($phone) == 12) |
2361 | 2594 | {//ex: +971_ABC_DEF_GH |
2362 | 2595 | $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3).$separ.substr($newphone,10,2); |
2363 | - } |
|
2364 | - elseif(dol_strlen($phone) == 13) |
|
2596 | + } elseif(dol_strlen($phone) == 13) |
|
2365 | 2597 | {//ex: +971_ABC_DEF_GHI |
2366 | 2598 | $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3).$separ.substr($newphone,10,3); |
2367 | - } |
|
2368 | - elseif(dol_strlen($phone) == 14) |
|
2599 | + } elseif(dol_strlen($phone) == 14) |
|
2369 | 2600 | {//ex: +971_ABC_DEF_GHIK |
2370 | 2601 | $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3).$separ.substr($newphone,10,4); |
2371 | 2602 | } |
2372 | - } |
|
2373 | - elseif (strtoupper($countrycode) == "DZ") |
|
2603 | + } elseif (strtoupper($countrycode) == "DZ") |
|
2374 | 2604 | {//Algérie |
2375 | 2605 | if(dol_strlen($phone) == 13) |
2376 | 2606 | {//ex: +213_ABC_DEF_GHI |
2377 | 2607 | $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3).$separ.substr($newphone,10,3); |
2378 | 2608 | } |
2379 | - } |
|
2380 | - elseif (strtoupper($countrycode) == "BE") |
|
2609 | + } elseif (strtoupper($countrycode) == "BE") |
|
2381 | 2610 | {//Belgique |
2382 | 2611 | if(dol_strlen($phone) == 11) |
2383 | 2612 | {//ex: +32_ABC_DE_FGH |
2384 | 2613 | $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,2).$separ.substr($newphone,8,3); |
2385 | - } |
|
2386 | - elseif(dol_strlen($phone) == 12) |
|
2614 | + } elseif(dol_strlen($phone) == 12) |
|
2387 | 2615 | {//ex: +32_ABC_DEF_GHI |
2388 | 2616 | $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,3); |
2389 | 2617 | } |
2390 | - } |
|
2391 | - elseif (strtoupper($countrycode) == "PF") |
|
2618 | + } elseif (strtoupper($countrycode) == "PF") |
|
2392 | 2619 | {//Polynésie française |
2393 | 2620 | if(dol_strlen($phone) == 12) |
2394 | 2621 | {//ex: +689_AB_CD_EF_GH |
2395 | 2622 | $newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); |
2396 | 2623 | } |
2397 | - } |
|
2398 | - elseif (strtoupper($countrycode) == "CO") |
|
2624 | + } elseif (strtoupper($countrycode) == "CO") |
|
2399 | 2625 | {//Colombie |
2400 | 2626 | if(dol_strlen($phone) == 13) |
2401 | 2627 | {//ex: +57_ABC_DEF_GH_IJ |
2402 | 2628 | $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,2).$separ.substr($newphone,11,2); |
2403 | 2629 | } |
2404 | - } |
|
2405 | - elseif (strtoupper($countrycode) == "JO") |
|
2630 | + } elseif (strtoupper($countrycode) == "JO") |
|
2406 | 2631 | {//Jordanie |
2407 | 2632 | if(dol_strlen($phone) == 12) |
2408 | 2633 | {//ex: +962_A_BCD_EF_GH |
2409 | 2634 | $newphone = substr($newphone,0,4).$separ.substr($newphone,4,1).$separ.substr($newphone,5,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2); |
2410 | 2635 | } |
2411 | - } |
|
2412 | - elseif (strtoupper($countrycode) == "MG") |
|
2636 | + } elseif (strtoupper($countrycode) == "MG") |
|
2413 | 2637 | {//Madagascar |
2414 | 2638 | if(dol_strlen($phone) == 13) |
2415 | 2639 | {//ex: +261_AB_CD_EF_GHI |
2416 | 2640 | $newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,2).$separ.substr($newphone,8,2).$separ.substr($newphone,10,3); |
2417 | 2641 | } |
2418 | - } |
|
2419 | - elseif (strtoupper($countrycode) == "GB") |
|
2642 | + } elseif (strtoupper($countrycode) == "GB") |
|
2420 | 2643 | {//Royaume uni |
2421 | 2644 | if(dol_strlen($phone) == 13) |
2422 | 2645 | {//ex: +44_ABCD_EFG_HIJ |
2423 | 2646 | $newphone = substr($newphone,0,3).$separ.substr($newphone,3,4).$separ.substr($newphone,7,3).$separ.substr($newphone,10,3); |
2424 | 2647 | } |
2425 | - } |
|
2426 | - elseif (strtoupper($countrycode) == "CH") |
|
2648 | + } elseif (strtoupper($countrycode) == "CH") |
|
2427 | 2649 | {//Suisse |
2428 | 2650 | if(dol_strlen($phone) == 12) |
2429 | 2651 | {//ex: +41_AB_CDE_FG_HI |
2430 | 2652 | $newphone = substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,3).$separ.substr($newphone,8,2).$separ.substr($newphone,10,2); |
2431 | - } |
|
2432 | - elseif(dol_strlen($phone) == 15) |
|
2653 | + } elseif(dol_strlen($phone) == 15) |
|
2433 | 2654 | {// +41_AB_CDE_FGH_IJKL |
2434 | 2655 | $newphone =$newphone = substr($newphone,0,3).$separ.substr($newphone,3,2).$separ.substr($newphone,5,3).$separ.substr($newphone,8,3).$separ.substr($newphone,11,4); |
2435 | 2656 | } |
2436 | - } |
|
2437 | - elseif (strtoupper($countrycode) == "TN") |
|
2657 | + } elseif (strtoupper($countrycode) == "TN") |
|
2438 | 2658 | {//Tunisie |
2439 | 2659 | if(dol_strlen($phone) == 12) |
2440 | 2660 | {//ex: +216_AB_CDE_FGH |
2441 | 2661 | $newphone = substr($newphone,0,4).$separ.substr($newphone,4,2).$separ.substr($newphone,6,3).$separ.substr($newphone,9,3); |
2442 | 2662 | } |
2443 | - } |
|
2444 | - elseif (strtoupper($countrycode) == "GF") |
|
2663 | + } elseif (strtoupper($countrycode) == "GF") |
|
2445 | 2664 | {//Guyane francaise |
2446 | 2665 | if(dol_strlen($phone) == 13) |
2447 | 2666 | {//ex: +594_ABC_DE_FG_HI (ABC=594 de nouveau) |
2448 | 2667 | $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2).$separ.substr($newphone,11,2); |
2449 | 2668 | } |
2450 | - } |
|
2451 | - elseif (strtoupper($countrycode) == "GP") |
|
2669 | + } elseif (strtoupper($countrycode) == "GP") |
|
2452 | 2670 | {//Guadeloupe |
2453 | 2671 | if(dol_strlen($phone) == 13) |
2454 | 2672 | {//ex: +590_ABC_DE_FG_HI (ABC=590 de nouveau) |
2455 | 2673 | $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2).$separ.substr($newphone,11,2); |
2456 | 2674 | } |
2457 | - } |
|
2458 | - elseif (strtoupper($countrycode) == "MQ") |
|
2675 | + } elseif (strtoupper($countrycode) == "MQ") |
|
2459 | 2676 | {//Martinique |
2460 | 2677 | if(dol_strlen($phone) == 13) |
2461 | 2678 | {//ex: +596_ABC_DE_FG_HI (ABC=596 de nouveau) |
2462 | 2679 | $newphone = substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,2).$separ.substr($newphone,9,2).$separ.substr($newphone,11,2); |
2463 | 2680 | } |
2464 | - } |
|
2465 | - elseif (strtoupper($countrycode) == "IT") |
|
2681 | + } elseif (strtoupper($countrycode) == "IT") |
|
2466 | 2682 | {//Italie |
2467 | 2683 | if(dol_strlen($phone) == 12) |
2468 | 2684 | {//ex: +39_ABC_DEF_GHI |
2469 | 2685 | $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,3); |
2470 | - } |
|
2471 | - elseif(dol_strlen($phone) == 13) |
|
2686 | + } elseif(dol_strlen($phone) == 13) |
|
2472 | 2687 | {//ex: +39_ABC_DEF_GH_IJ |
2473 | 2688 | $newphone = substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,2).$separ.substr($newphone,11,2); |
2474 | 2689 | } |
2475 | - } |
|
2476 | - elseif(strtoupper($countrycode) == "AU") |
|
2690 | + } elseif(strtoupper($countrycode) == "AU") |
|
2477 | 2691 | {//Australie |
2478 | 2692 | if(dol_strlen($phone) == 12) |
2479 | 2693 | {//ex: +61_A_BCDE_FGHI |
2480 | 2694 | $newphone = substr($newphone,0,3).$separ.substr($newphone,3,1).$separ.substr($newphone,4,4).$separ.substr($newphone,8,4); |
2481 | 2695 | } |
2482 | 2696 | } |
2483 | - if (! empty($addlink)) // Link on phone number (+ link to add action if conf->global->AGENDA_ADDACTIONFORPHONE set) |
|
2697 | + if (! empty($addlink)) { |
|
2698 | + // Link on phone number (+ link to add action if conf->global->AGENDA_ADDACTIONFORPHONE set) |
|
2484 | 2699 | { |
2485 | 2700 | if (! empty($conf->browser->phone) || (! empty($conf->clicktodial->enabled) && ! empty($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS))) // If phone or option for, we use link of phone |
2486 | 2701 | { |
2487 | 2702 | $newphone ='<a href="tel:'.$phone.'"'; |
2703 | + } |
|
2488 | 2704 | $newphone.='>'.$phone.'</a>'; |
2489 | - } |
|
2490 | - else if (! empty($conf->clicktodial->enabled) && $addlink == 'AC_TEL') // If click to dial, we use click to dial url |
|
2705 | + } else if (! empty($conf->clicktodial->enabled) && $addlink == 'AC_TEL') { |
|
2706 | + // If click to dial, we use click to dial url |
|
2491 | 2707 | { |
2492 | 2708 | if (empty($user->clicktodial_loaded)) $user->fetch_clicktodial(); |
2709 | + } |
|
2493 | 2710 | |
2494 | 2711 | // Define urlmask |
2495 | 2712 | $urlmask='ErrorClickToDialModuleNotConfigured'; |
2496 | - if (! empty($conf->global->CLICKTODIAL_URL)) $urlmask=$conf->global->CLICKTODIAL_URL; |
|
2497 | - if (! empty($user->clicktodial_url)) $urlmask=$user->clicktodial_url; |
|
2713 | + if (! empty($conf->global->CLICKTODIAL_URL)) { |
|
2714 | + $urlmask=$conf->global->CLICKTODIAL_URL; |
|
2715 | + } |
|
2716 | + if (! empty($user->clicktodial_url)) { |
|
2717 | + $urlmask=$user->clicktodial_url; |
|
2718 | + } |
|
2498 | 2719 | |
2499 | 2720 | $clicktodial_poste=(! empty($user->clicktodial_poste)?urlencode($user->clicktodial_poste):''); |
2500 | 2721 | $clicktodial_login=(! empty($user->clicktodial_login)?urlencode($user->clicktodial_login):''); |
@@ -2509,7 +2730,9 @@ discard block |
||
2509 | 2730 | $url = make_substitutions($url, $substitarray); |
2510 | 2731 | $newphonesav=$newphone; |
2511 | 2732 | $newphone ='<a href="'.$url.'"'; |
2512 | - if (! empty($conf->global->CLICKTODIAL_FORCENEWTARGET)) $newphone.=' target="_blank"'; |
|
2733 | + if (! empty($conf->global->CLICKTODIAL_FORCENEWTARGET)) { |
|
2734 | + $newphone.=' target="_blank"'; |
|
2735 | + } |
|
2513 | 2736 | $newphone.='>'.$newphonesav.'</a>'; |
2514 | 2737 | } |
2515 | 2738 | |
@@ -2517,9 +2740,15 @@ discard block |
||
2517 | 2740 | if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) |
2518 | 2741 | { |
2519 | 2742 | $type='AC_TEL'; $link=''; |
2520 | - if ($addlink == 'AC_FAX') $type='AC_FAX'; |
|
2521 | - if (! empty($conf->global->AGENDA_ADDACTIONFORPHONE)) $link='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&actioncode='.$type.($cid?'&contactid='.$cid:'').($socid?'&socid='.$socid:'').'">'.img_object($langs->trans("AddAction"),"calendar").'</a>'; |
|
2522 | - if ($link) $newphone='<div>'.$newphone.' '.$link.'</div>'; |
|
2743 | + if ($addlink == 'AC_FAX') { |
|
2744 | + $type='AC_FAX'; |
|
2745 | + } |
|
2746 | + if (! empty($conf->global->AGENDA_ADDACTIONFORPHONE)) { |
|
2747 | + $link='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&actioncode='.$type.($cid?'&contactid='.$cid:'').($socid?'&socid='.$socid:'').'">'.img_object($langs->trans("AddAction"),"calendar").'</a>'; |
|
2748 | + } |
|
2749 | + if ($link) { |
|
2750 | + $newphone='<div>'.$newphone.' '.$link.'</div>'; |
|
2751 | + } |
|
2523 | 2752 | } |
2524 | 2753 | } |
2525 | 2754 | |
@@ -2540,19 +2769,25 @@ discard block |
||
2540 | 2769 | if($withpicto){ |
2541 | 2770 | if($withpicto=='fax'){ |
2542 | 2771 | $picto = 'phoning_fax'; |
2543 | - }elseif($withpicto=='phone'){ |
|
2772 | + } elseif($withpicto=='phone'){ |
|
2544 | 2773 | $picto = 'phoning'; |
2545 | - }elseif($withpicto=='mobile'){ |
|
2774 | + } elseif($withpicto=='mobile'){ |
|
2546 | 2775 | $picto = 'phoning_mobile'; |
2547 | - }else{ |
|
2776 | + } else{ |
|
2548 | 2777 | $picto = ''; |
2549 | 2778 | } |
2550 | 2779 | } |
2551 | - if ($adddivfloat) $rep.='<div class="nospan float" style="margin-right: 10px">'; |
|
2552 | - else $rep.='<span style="margin-right: 10px;">'; |
|
2780 | + if ($adddivfloat) { |
|
2781 | + $rep.='<div class="nospan float" style="margin-right: 10px">'; |
|
2782 | + } else { |
|
2783 | + $rep.='<span style="margin-right: 10px;">'; |
|
2784 | + } |
|
2553 | 2785 | $rep.=($withpicto?img_picto($titlealt, 'object_'.$picto.'.png').' ':'').$newphone; |
2554 | - if ($adddivfloat) $rep.='</div>'; |
|
2555 | - else $rep.='</span>'; |
|
2786 | + if ($adddivfloat) { |
|
2787 | + $rep.='</div>'; |
|
2788 | + } else { |
|
2789 | + $rep.='</span>'; |
|
2790 | + } |
|
2556 | 2791 | } |
2557 | 2792 | |
2558 | 2793 | return $rep; |
@@ -2571,18 +2806,23 @@ discard block |
||
2571 | 2806 | |
2572 | 2807 | $ret=''; |
2573 | 2808 | |
2574 | - if (empty($mode)) $ret.=$ip; |
|
2809 | + if (empty($mode)) { |
|
2810 | + $ret.=$ip; |
|
2811 | + } |
|
2575 | 2812 | |
2576 | 2813 | if ($mode != 2) |
2577 | 2814 | { |
2578 | 2815 | $countrycode=dolGetCountryCodeFromIp($ip); |
2579 | - if ($countrycode) // If success, countrycode is us, fr, ... |
|
2816 | + if ($countrycode) { |
|
2817 | + // If success, countrycode is us, fr, ... |
|
2580 | 2818 | { |
2581 | 2819 | if (file_exists(DOL_DOCUMENT_ROOT.'/theme/common/flags/'.$countrycode.'.png')) |
2582 | 2820 | { |
2583 | 2821 | $ret.=' '.img_picto($countrycode.' '.$langs->trans("AccordingToGeoIPDatabase"),DOL_URL_ROOT.'/theme/common/flags/'.$countrycode.'.png','',1); |
2822 | + } |
|
2823 | + } else { |
|
2824 | + $ret.=' ('.$countrycode.')'; |
|
2584 | 2825 | } |
2585 | - else $ret.=' ('.$countrycode.')'; |
|
2586 | 2826 | } |
2587 | 2827 | } |
2588 | 2828 | |
@@ -2671,18 +2911,33 @@ discard block |
||
2671 | 2911 | } |
2672 | 2912 | if (empty($reshook)) |
2673 | 2913 | { |
2674 | - if (empty($charfornl)) $out.=nl2br($address); |
|
2675 | - else $out.=preg_replace('/[\r\n]+/', $charfornl, $address); |
|
2914 | + if (empty($charfornl)) { |
|
2915 | + $out.=nl2br($address); |
|
2916 | + } else { |
|
2917 | + $out.=preg_replace('/[\r\n]+/', $charfornl, $address); |
|
2918 | + } |
|
2676 | 2919 | |
2677 | 2920 | $showgmap=$showomap=0; |
2678 | 2921 | |
2679 | 2922 | // TODO Add a hook here |
2680 | - if (($mode=='thirdparty' || $mode =='societe') && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS)) $showgmap=1; |
|
2681 | - if ($mode=='contact' && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) $showgmap=1; |
|
2682 | - if ($mode=='member' && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) $showgmap=1; |
|
2683 | - if (($mode=='thirdparty' || $mode =='societe') && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) $showomap=1; |
|
2684 | - if ($mode=='contact' && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) $showomap=1; |
|
2685 | - if ($mode=='member' && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) $showomap=1; |
|
2923 | + if (($mode=='thirdparty' || $mode =='societe') && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS)) { |
|
2924 | + $showgmap=1; |
|
2925 | + } |
|
2926 | + if ($mode=='contact' && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) { |
|
2927 | + $showgmap=1; |
|
2928 | + } |
|
2929 | + if ($mode=='member' && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) { |
|
2930 | + $showgmap=1; |
|
2931 | + } |
|
2932 | + if (($mode=='thirdparty' || $mode =='societe') && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) { |
|
2933 | + $showomap=1; |
|
2934 | + } |
|
2935 | + if ($mode=='contact' && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) { |
|
2936 | + $showomap=1; |
|
2937 | + } |
|
2938 | + if ($mode=='member' && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) { |
|
2939 | + $showomap=1; |
|
2940 | + } |
|
2686 | 2941 | |
2687 | 2942 | if ($showgmap) |
2688 | 2943 | { |
@@ -2696,9 +2951,12 @@ discard block |
||
2696 | 2951 | } |
2697 | 2952 | } |
2698 | 2953 | } |
2699 | - if ($noprint) return $out; |
|
2700 | - else print $out; |
|
2701 | -} |
|
2954 | + if ($noprint) { |
|
2955 | + return $out; |
|
2956 | + } else { |
|
2957 | + print $out; |
|
2958 | + } |
|
2959 | + } |
|
2702 | 2960 | |
2703 | 2961 | |
2704 | 2962 | /** |
@@ -2710,8 +2968,12 @@ discard block |
||
2710 | 2968 | */ |
2711 | 2969 | function isValidEmail($address, $acceptsupervisorkey=0) |
2712 | 2970 | { |
2713 | - if ($acceptsupervisorkey && $address == '__SUPERVISOREMAIL__') return true; |
|
2714 | - if (filter_var($address, FILTER_VALIDATE_EMAIL)) return true; |
|
2971 | + if ($acceptsupervisorkey && $address == '__SUPERVISOREMAIL__') { |
|
2972 | + return true; |
|
2973 | + } |
|
2974 | + if (filter_var($address, FILTER_VALIDATE_EMAIL)) { |
|
2975 | + return true; |
|
2976 | + } |
|
2715 | 2977 | |
2716 | 2978 | return false; |
2717 | 2979 | } |
@@ -2738,9 +3000,12 @@ discard block |
||
2738 | 3000 | */ |
2739 | 3001 | function dol_strlen($string,$stringencoding='UTF-8') |
2740 | 3002 | { |
2741 | - if (function_exists('mb_strlen')) return mb_strlen($string,$stringencoding); |
|
2742 | - else return strlen($string); |
|
2743 | -} |
|
3003 | + if (function_exists('mb_strlen')) { |
|
3004 | + return mb_strlen($string,$stringencoding); |
|
3005 | + } else { |
|
3006 | + return strlen($string); |
|
3007 | + } |
|
3008 | + } |
|
2744 | 3009 | |
2745 | 3010 | /** |
2746 | 3011 | * Make a substring. Works even in mbstring module is not enabled. |
@@ -2755,14 +3020,15 @@ discard block |
||
2755 | 3020 | { |
2756 | 3021 | global $langs; |
2757 | 3022 | |
2758 | - if (empty($stringencoding)) $stringencoding=$langs->charset_output; |
|
3023 | + if (empty($stringencoding)) { |
|
3024 | + $stringencoding=$langs->charset_output; |
|
3025 | + } |
|
2759 | 3026 | |
2760 | 3027 | $ret=''; |
2761 | 3028 | if (function_exists('mb_substr')) |
2762 | 3029 | { |
2763 | 3030 | $ret=mb_substr($string,$start,$length,$stringencoding); |
2764 | - } |
|
2765 | - else |
|
3031 | + } else |
|
2766 | 3032 | { |
2767 | 3033 | $ret=substr($string,$start,$length); |
2768 | 3034 | } |
@@ -2802,7 +3068,9 @@ discard block |
||
2802 | 3068 | return; |
2803 | 3069 | } |
2804 | 3070 | |
2805 | - if (empty($conf->use_javascript_ajax)) return; |
|
3071 | + if (empty($conf->use_javascript_ajax)) { |
|
3072 | + return; |
|
3073 | + } |
|
2806 | 3074 | $jsgraphlib='flot'; |
2807 | 3075 | $datacolor=array(); |
2808 | 3076 | |
@@ -2860,11 +3128,17 @@ discard block |
||
2860 | 3128 | var number=series.data[0][1]; |
2861 | 3129 | return \''; |
2862 | 3130 | print '<div style="font-size:8pt;text-align:center;padding:2px;color:black;">'; |
2863 | - if ($url) print '<a style="color: #FFFFFF;" border="0" href="'.$url.'">'; |
|
3131 | + if ($url) { |
|
3132 | + print '<a style="color: #FFFFFF;" border="0" href="'.$url.'">'; |
|
3133 | + } |
|
2864 | 3134 | print '\'+'.($showlegend?'number':'label+\' \'+number'); |
2865 | - if (! empty($showpercent)) print '+\'<br/>\'+percent+\'%\''; |
|
3135 | + if (! empty($showpercent)) { |
|
3136 | + print '+\'<br/>\'+percent+\'%\''; |
|
3137 | + } |
|
2866 | 3138 | print '+\''; |
2867 | - if ($url) print '</a>'; |
|
3139 | + if ($url) { |
|
3140 | + print '</a>'; |
|
3141 | + } |
|
2868 | 3142 | print '</div>\'; |
2869 | 3143 | }, |
2870 | 3144 | background: { |
@@ -2890,8 +3164,7 @@ discard block |
||
2890 | 3164 | plotWithOptions(); |
2891 | 3165 | }); |
2892 | 3166 | </script>'; |
2893 | - } |
|
2894 | - else if ($type == 'barline') |
|
3167 | + } else if ($type == 'barline') |
|
2895 | 3168 | { |
2896 | 3169 | // data is array('series'=>array(serie1,serie2,...), |
2897 | 3170 | // 'seriestype'=>array('bar','line',...), |
@@ -2906,18 +3179,24 @@ discard block |
||
2906 | 3179 | foreach($data['series'] as $serie) |
2907 | 3180 | { |
2908 | 3181 | if ($data['seriestype'][$i]=='line') { $i++; continue; }; |
2909 | - if ($outputserie > 0) print ','; |
|
3182 | + if ($outputserie > 0) { |
|
3183 | + print ','; |
|
3184 | + } |
|
2910 | 3185 | print '{ bars: { stack: 0, show: true, barWidth: 0.9, align: \'center\' }, label: \''.dol_escape_js($serie['label']).'\', data: '.json_encode($serie['data']).'}'."\n"; |
2911 | 3186 | $outputserie++; $i++; |
2912 | 3187 | } |
2913 | - if ($outputserie) print ', '; |
|
3188 | + if ($outputserie) { |
|
3189 | + print ', '; |
|
3190 | + } |
|
2914 | 3191 | //print ']; |
2915 | 3192 | //var datalines = ['; |
2916 | 3193 | $i=0; $outputserie=0; |
2917 | 3194 | foreach($data['series'] as $serie) |
2918 | 3195 | { |
2919 | 3196 | if (empty($data['seriestype'][$i]) || $data['seriestype'][$i]=='bar') { $i++; continue; }; |
2920 | - if ($outputserie > 0) print ','; |
|
3197 | + if ($outputserie > 0) { |
|
3198 | + print ','; |
|
3199 | + } |
|
2921 | 3200 | print '{ lines: { show: true }, label: \''.dol_escape_js($serie['label']).'\', data: '.json_encode($serie['data']).'}'."\n"; |
2922 | 3201 | $outputserie++; $i++; |
2923 | 3202 | } |
@@ -2947,8 +3226,9 @@ discard block |
||
2947 | 3226 | plotWithOptions(); |
2948 | 3227 | }); |
2949 | 3228 | </script>'; |
3229 | + } else { |
|
3230 | + print 'BadValueForParameterType'; |
|
2950 | 3231 | } |
2951 | - else print 'BadValueForParameterType'; |
|
2952 | 3232 | } |
2953 | 3233 | } |
2954 | 3234 | |
@@ -2969,23 +3249,30 @@ discard block |
||
2969 | 3249 | { |
2970 | 3250 | global $conf; |
2971 | 3251 | |
2972 | - if ($size==0 || ! empty($conf->global->MAIN_DISABLE_TRUNC)) return $string; |
|
3252 | + if ($size==0 || ! empty($conf->global->MAIN_DISABLE_TRUNC)) { |
|
3253 | + return $string; |
|
3254 | + } |
|
2973 | 3255 | |
2974 | - if (empty($stringencoding)) $stringencoding='UTF-8'; |
|
3256 | + if (empty($stringencoding)) { |
|
3257 | + $stringencoding='UTF-8'; |
|
3258 | + } |
|
2975 | 3259 | // reduce for small screen |
2976 | - if ($conf->dol_optimize_smallscreen==1 && $display==1) $size = round($size/3); |
|
3260 | + if ($conf->dol_optimize_smallscreen==1 && $display==1) { |
|
3261 | + $size = round($size/3); |
|
3262 | + } |
|
2977 | 3263 | |
2978 | 3264 | // We go always here |
2979 | 3265 | if ($trunc == 'right') |
2980 | 3266 | { |
2981 | 3267 | $newstring=dol_textishtml($string)?dol_string_nohtmltag($string,1):$string; |
2982 | - if (dol_strlen($newstring,$stringencoding) > ($size+($nodot?0:3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... |
|
3268 | + if (dol_strlen($newstring,$stringencoding) > ($size+($nodot?0:3))) { |
|
3269 | + // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... |
|
2983 | 3270 | return dol_substr($newstring,0,$size,$stringencoding).($nodot?'':'...'); |
2984 | - else |
|
2985 | - //return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string; |
|
3271 | + } else { |
|
3272 | + //return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string; |
|
2986 | 3273 | return $string; |
2987 | - } |
|
2988 | - elseif ($trunc == 'middle') |
|
3274 | + } |
|
3275 | + } elseif ($trunc == 'middle') |
|
2989 | 3276 | { |
2990 | 3277 | $newstring=dol_textishtml($string)?dol_string_nohtmltag($string,1):$string; |
2991 | 3278 | if (dol_strlen($newstring,$stringencoding) > 2 && dol_strlen($newstring,$stringencoding) > ($size+1)) |
@@ -2993,28 +3280,30 @@ discard block |
||
2993 | 3280 | $size1=round($size/2); |
2994 | 3281 | $size2=round($size/2); |
2995 | 3282 | return dol_substr($newstring,0,$size1,$stringencoding).'...'.dol_substr($newstring,dol_strlen($newstring,$stringencoding) - $size2,$size2,$stringencoding); |
3283 | + } else { |
|
3284 | + return $string; |
|
2996 | 3285 | } |
2997 | - else |
|
2998 | - return $string; |
|
2999 | - } |
|
3000 | - elseif ($trunc == 'left') |
|
3286 | + } elseif ($trunc == 'left') |
|
3001 | 3287 | { |
3002 | 3288 | $newstring=dol_textishtml($string)?dol_string_nohtmltag($string,1):$string; |
3003 | - if (dol_strlen($newstring,$stringencoding) > ($size+($nodot?0:3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... |
|
3289 | + if (dol_strlen($newstring,$stringencoding) > ($size+($nodot?0:3))) { |
|
3290 | + // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... |
|
3004 | 3291 | return '...'.dol_substr($newstring,dol_strlen($newstring,$stringencoding) - $size,$size,$stringencoding); |
3005 | - else |
|
3006 | - return $string; |
|
3007 | - } |
|
3008 | - elseif ($trunc == 'wrap') |
|
3292 | + } else { |
|
3293 | + return $string; |
|
3294 | + } |
|
3295 | + } elseif ($trunc == 'wrap') |
|
3009 | 3296 | { |
3010 | 3297 | $newstring=dol_textishtml($string)?dol_string_nohtmltag($string,1):$string; |
3011 | - if (dol_strlen($newstring,$stringencoding) > ($size+1)) |
|
3012 | - return dol_substr($newstring,0,$size,$stringencoding)."\n".dol_trunc(dol_substr($newstring,$size,dol_strlen($newstring,$stringencoding)-$size,$stringencoding),$size,$trunc); |
|
3013 | - else |
|
3014 | - return $string; |
|
3298 | + if (dol_strlen($newstring,$stringencoding) > ($size+1)) { |
|
3299 | + return dol_substr($newstring,0,$size,$stringencoding)."\n".dol_trunc(dol_substr($newstring,$size,dol_strlen($newstring,$stringencoding)-$size,$stringencoding),$size,$trunc); |
|
3300 | + } else { |
|
3301 | + return $string; |
|
3302 | + } |
|
3303 | + } else { |
|
3304 | + return 'BadParam3CallingDolTrunc'; |
|
3305 | + } |
|
3015 | 3306 | } |
3016 | - else return 'BadParam3CallingDolTrunc'; |
|
3017 | -} |
|
3018 | 3307 | |
3019 | 3308 | /** |
3020 | 3309 | * Show picto whatever it's its name (generic function) |
@@ -3042,10 +3331,11 @@ discard block |
||
3042 | 3331 | if ($pictoisfullpath) |
3043 | 3332 | { |
3044 | 3333 | // Clean parameters |
3045 | - if (! preg_match('/(\.png|\.gif|\.svg)$/i',$picto)) $picto .= '.png'; |
|
3334 | + if (! preg_match('/(\.png|\.gif|\.svg)$/i',$picto)) { |
|
3335 | + $picto .= '.png'; |
|
3336 | + } |
|
3046 | 3337 | $fullpathpicto = $picto; |
3047 | - } |
|
3048 | - else |
|
3338 | + } else |
|
3049 | 3339 | { |
3050 | 3340 | //if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on'))) |
3051 | 3341 | if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on'))) |
@@ -3057,7 +3347,9 @@ discard block |
||
3057 | 3347 | if ($picto == 'on') { $fakey = 'fa-check-square-o'; $fasize='1.3em'; } |
3058 | 3348 | $enabledisablehtml=''; |
3059 | 3349 | $enabledisablehtml.='<span class="fa '.$fakey.' valignmiddle'.($morecss?' '.$morecss:'').'" style="'.($fasize?('font-size: '.$fasize.';'):'').($facolor?(' color: '.$facolor.';'):'').'" alt="'.dol_escape_htmltag($titlealt).'" title="'.dol_escape_htmltag($titlealt).'"'.($moreatt?' '.$moreatt:'').'">'; |
3060 | - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $enabledisablehtml.=$titlealt; |
|
3350 | + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { |
|
3351 | + $enabledisablehtml.=$titlealt; |
|
3352 | + } |
|
3061 | 3353 | $enabledisablehtml.='</span>'; |
3062 | 3354 | return $enabledisablehtml; |
3063 | 3355 | } |
@@ -3067,9 +3359,18 @@ discard block |
||
3067 | 3359 | $theme = $conf->theme; |
3068 | 3360 | |
3069 | 3361 | $path = 'theme/'.$theme; |
3070 | - if (! empty($conf->global->MAIN_OVERWRITE_THEME_PATH)) $path = $conf->global->MAIN_OVERWRITE_THEME_PATH.'/theme/'.$theme; // If the theme does not have the same name as the module |
|
3071 | - else if (! empty($conf->global->MAIN_OVERWRITE_THEME_RES)) $path = $conf->global->MAIN_OVERWRITE_THEME_RES.'/theme/'.$conf->global->MAIN_OVERWRITE_THEME_RES; // To allow an external module to overwrite image resources whatever is activated theme |
|
3072 | - else if (! empty($conf->modules_parts['theme']) && array_key_exists($theme, $conf->modules_parts['theme'])) $path = $theme.'/theme/'.$theme; // If the theme have the same name as the module |
|
3362 | + if (! empty($conf->global->MAIN_OVERWRITE_THEME_PATH)) { |
|
3363 | + $path = $conf->global->MAIN_OVERWRITE_THEME_PATH.'/theme/'.$theme; |
|
3364 | + } |
|
3365 | + // If the theme does not have the same name as the module |
|
3366 | + else if (! empty($conf->global->MAIN_OVERWRITE_THEME_RES)) { |
|
3367 | + $path = $conf->global->MAIN_OVERWRITE_THEME_RES.'/theme/'.$conf->global->MAIN_OVERWRITE_THEME_RES; |
|
3368 | + } |
|
3369 | + // To allow an external module to overwrite image resources whatever is activated theme |
|
3370 | + else if (! empty($conf->modules_parts['theme']) && array_key_exists($theme, $conf->modules_parts['theme'])) { |
|
3371 | + $path = $theme.'/theme/'.$theme; |
|
3372 | + } |
|
3373 | + // If the theme have the same name as the module |
|
3073 | 3374 | |
3074 | 3375 | // If we ask an image into $url/$mymodule/img (instead of default path) |
3075 | 3376 | if (preg_match('/^([^@]+)@([^@]+)$/i',$picto,$regs)) |
@@ -3079,14 +3380,20 @@ discard block |
||
3079 | 3380 | } |
3080 | 3381 | |
3081 | 3382 | // Clean parameters |
3082 | - if (! preg_match('/(\.png|\.gif|\.svg)$/i',$picto)) $picto .= '.png'; |
|
3383 | + if (! preg_match('/(\.png|\.gif|\.svg)$/i',$picto)) { |
|
3384 | + $picto .= '.png'; |
|
3385 | + } |
|
3083 | 3386 | // If alt path are defined, define url where img file is, according to physical path |
3084 | - foreach ($conf->file->dol_document_root as $type => $dirroot) // ex: array(["main"]=>"/home/maindir/htdocs", ["alt0"]=>"/home/moddir0/htdocs", ...) |
|
3387 | + foreach ($conf->file->dol_document_root as $type => $dirroot) { |
|
3388 | + // ex: array(["main"]=>"/home/maindir/htdocs", ["alt0"]=>"/home/moddir0/htdocs", ...) |
|
3085 | 3389 | { |
3086 | 3390 | if ($type == 'main') continue; |
3087 | - if (file_exists($dirroot.'/'.$path.'/img/'.$picto)) // This need a lot of time, that's why enabling alternative dir like "custom" dir is not recommanded |
|
3391 | + } |
|
3392 | + if (file_exists($dirroot.'/'.$path.'/img/'.$picto)) { |
|
3393 | + // This need a lot of time, that's why enabling alternative dir like "custom" dir is not recommanded |
|
3088 | 3394 | { |
3089 | 3395 | $url=DOL_URL_ROOT.$conf->file->dol_url_root[$type]; |
3396 | + } |
|
3090 | 3397 | break; |
3091 | 3398 | } |
3092 | 3399 | } |
@@ -3095,8 +3402,9 @@ discard block |
||
3095 | 3402 | $fullpathpicto = $url.'/'.$path.'/img/'.$picto; |
3096 | 3403 | } |
3097 | 3404 | |
3098 | - if ($srconly) return $fullpathpicto; |
|
3099 | - else |
|
3405 | + if ($srconly) { |
|
3406 | + return $fullpathpicto; |
|
3407 | + } else |
|
3100 | 3408 | { |
3101 | 3409 | // tag title is used for tooltip on <a>, tag alt can be used with very simple text on image for bind people |
3102 | 3410 | //$tmparray=array(0=>$titlealt); |
@@ -3140,7 +3448,9 @@ discard block |
||
3140 | 3448 | { |
3141 | 3449 | global $conf; |
3142 | 3450 | |
3143 | - if (! preg_match('/(\.png|\.gif)$/i', $picto)) $picto .= '.png'; |
|
3451 | + if (! preg_match('/(\.png|\.gif)$/i', $picto)) { |
|
3452 | + $picto .= '.png'; |
|
3453 | + } |
|
3144 | 3454 | |
3145 | 3455 | $path = DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/weather/'.$picto; |
3146 | 3456 | |
@@ -3161,10 +3471,13 @@ discard block |
||
3161 | 3471 | { |
3162 | 3472 | global $conf; |
3163 | 3473 | |
3164 | - if (! preg_match('/(\.png|\.gif)$/i', $picto)) $picto .= '.png'; |
|
3474 | + if (! preg_match('/(\.png|\.gif)$/i', $picto)) { |
|
3475 | + $picto .= '.png'; |
|
3476 | + } |
|
3165 | 3477 | |
3166 | - if ($pictoisfullpath) $path = $picto; |
|
3167 | - else |
|
3478 | + if ($pictoisfullpath) { |
|
3479 | + $path = $picto; |
|
3480 | + } else |
|
3168 | 3481 | { |
3169 | 3482 | $path = DOL_URL_ROOT.'/theme/common/'.$picto; |
3170 | 3483 | |
@@ -3172,7 +3485,9 @@ discard block |
||
3172 | 3485 | { |
3173 | 3486 | $themepath = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/'.$picto; |
3174 | 3487 | |
3175 | - if (file_exists($themepath)) $path = $themepath; |
|
3488 | + if (file_exists($themepath)) { |
|
3489 | + $path = $themepath; |
|
3490 | + } |
|
3176 | 3491 | } |
3177 | 3492 | } |
3178 | 3493 | |
@@ -3192,14 +3507,11 @@ discard block |
||
3192 | 3507 | |
3193 | 3508 | if (empty($titlealt) || $titlealt == 'default') |
3194 | 3509 | { |
3195 | - if ($numaction == '-1' || $numaction == 'ST_NO') { $numaction = -1; $titlealt = $langs->transnoentitiesnoconv('ChangeDoNotContact'); } |
|
3196 | - elseif ($numaction == '0' || $numaction == 'ST_NEVER') { $numaction = 0; $titlealt = $langs->transnoentitiesnoconv('ChangeNeverContacted'); } |
|
3197 | - elseif ($numaction == '1' || $numaction == 'ST_TODO') { $numaction = 1; $titlealt = $langs->transnoentitiesnoconv('ChangeToContact'); } |
|
3198 | - elseif ($numaction == '2' || $numaction == 'ST_PEND') { $numaction = 2; $titlealt = $langs->transnoentitiesnoconv('ChangeContactInProcess'); } |
|
3199 | - elseif ($numaction == '3' || $numaction == 'ST_DONE') { $numaction = 3; $titlealt = $langs->transnoentitiesnoconv('ChangeContactDone'); } |
|
3200 | - else { $titlealt = $langs->transnoentitiesnoconv('ChangeStatus '.$numaction); $numaction = 0; } |
|
3510 | + if ($numaction == '-1' || $numaction == 'ST_NO') { $numaction = -1; $titlealt = $langs->transnoentitiesnoconv('ChangeDoNotContact'); } elseif ($numaction == '0' || $numaction == 'ST_NEVER') { $numaction = 0; $titlealt = $langs->transnoentitiesnoconv('ChangeNeverContacted'); } elseif ($numaction == '1' || $numaction == 'ST_TODO') { $numaction = 1; $titlealt = $langs->transnoentitiesnoconv('ChangeToContact'); } elseif ($numaction == '2' || $numaction == 'ST_PEND') { $numaction = 2; $titlealt = $langs->transnoentitiesnoconv('ChangeContactInProcess'); } elseif ($numaction == '3' || $numaction == 'ST_DONE') { $numaction = 3; $titlealt = $langs->transnoentitiesnoconv('ChangeContactDone'); } else { $titlealt = $langs->transnoentitiesnoconv('ChangeStatus '.$numaction); $numaction = 0; } |
|
3511 | + } |
|
3512 | + if (! is_numeric($numaction)) { |
|
3513 | + $numaction=0; |
|
3201 | 3514 | } |
3202 | - if (! is_numeric($numaction)) $numaction=0; |
|
3203 | 3515 | |
3204 | 3516 | return img_picto($titlealt, 'stcomm'.$numaction.'.png'); |
3205 | 3517 | } |
@@ -3215,7 +3527,9 @@ discard block |
||
3215 | 3527 | { |
3216 | 3528 | global $conf, $langs; |
3217 | 3529 | |
3218 | - if ($titlealt == 'default') $titlealt = $langs->trans('Show'); |
|
3530 | + if ($titlealt == 'default') { |
|
3531 | + $titlealt = $langs->trans('Show'); |
|
3532 | + } |
|
3219 | 3533 | |
3220 | 3534 | return img_picto($titlealt, 'pdf'.$size.'.png'); |
3221 | 3535 | } |
@@ -3231,7 +3545,9 @@ discard block |
||
3231 | 3545 | { |
3232 | 3546 | global $conf, $langs; |
3233 | 3547 | |
3234 | - if ($titlealt == 'default') $titlealt = $langs->trans('Add'); |
|
3548 | + if ($titlealt == 'default') { |
|
3549 | + $titlealt = $langs->trans('Add'); |
|
3550 | + } |
|
3235 | 3551 | |
3236 | 3552 | return img_picto($titlealt, 'edit_add.png', $other); |
3237 | 3553 | } |
@@ -3246,7 +3562,9 @@ discard block |
||
3246 | 3562 | { |
3247 | 3563 | global $conf, $langs; |
3248 | 3564 | |
3249 | - if ($titlealt == 'default') $titlealt = $langs->trans('Remove'); |
|
3565 | + if ($titlealt == 'default') { |
|
3566 | + $titlealt = $langs->trans('Remove'); |
|
3567 | + } |
|
3250 | 3568 | |
3251 | 3569 | return img_picto($titlealt, 'edit_remove.png', $other); |
3252 | 3570 | } |
@@ -3263,7 +3581,9 @@ discard block |
||
3263 | 3581 | { |
3264 | 3582 | global $conf, $langs; |
3265 | 3583 | |
3266 | - if ($titlealt == 'default') $titlealt = $langs->trans('Modify'); |
|
3584 | + if ($titlealt == 'default') { |
|
3585 | + $titlealt = $langs->trans('Modify'); |
|
3586 | + } |
|
3267 | 3587 | |
3268 | 3588 | return img_picto($titlealt, 'edit.png', ($float ? 'style="float: '.($langs->tab_translate["DIRECTION"] == 'rtl'?'left':'right').'"' : "") . ($other?' '.$other:'')); |
3269 | 3589 | } |
@@ -3280,7 +3600,9 @@ discard block |
||
3280 | 3600 | { |
3281 | 3601 | global $conf, $langs; |
3282 | 3602 | |
3283 | - if ($titlealt == 'default') $titlealt = $langs->trans('View'); |
|
3603 | + if ($titlealt == 'default') { |
|
3604 | + $titlealt = $langs->trans('View'); |
|
3605 | + } |
|
3284 | 3606 | |
3285 | 3607 | $moreatt = ($float ? 'style="float: right" ' : '').$other; |
3286 | 3608 | |
@@ -3298,7 +3620,9 @@ discard block |
||
3298 | 3620 | { |
3299 | 3621 | global $conf, $langs; |
3300 | 3622 | |
3301 | - if ($titlealt == 'default') $titlealt = $langs->trans('Delete'); |
|
3623 | + if ($titlealt == 'default') { |
|
3624 | + $titlealt = $langs->trans('Delete'); |
|
3625 | + } |
|
3302 | 3626 | |
3303 | 3627 | return img_picto($titlealt, 'delete.png', $other); |
3304 | 3628 | } |
@@ -3313,7 +3637,9 @@ discard block |
||
3313 | 3637 | function img_printer($titlealt = "default", $other='') |
3314 | 3638 | { |
3315 | 3639 | global $conf,$langs; |
3316 | - if ($titlealt=="default") $titlealt=$langs->trans("Print"); |
|
3640 | + if ($titlealt=="default") { |
|
3641 | + $titlealt=$langs->trans("Print"); |
|
3642 | + } |
|
3317 | 3643 | return img_picto($titlealt,'printer.png',$other); |
3318 | 3644 | } |
3319 | 3645 | |
@@ -3328,7 +3654,9 @@ discard block |
||
3328 | 3654 | { |
3329 | 3655 | global $conf, $langs; |
3330 | 3656 | |
3331 | - if ($titlealt == 'default') $titlealt = $langs->trans('Split'); |
|
3657 | + if ($titlealt == 'default') { |
|
3658 | + $titlealt = $langs->trans('Split'); |
|
3659 | + } |
|
3332 | 3660 | |
3333 | 3661 | return img_picto($titlealt, 'split.png', $other); |
3334 | 3662 | } |
@@ -3346,8 +3674,11 @@ discard block |
||
3346 | 3674 | |
3347 | 3675 | if ($usealttitle) |
3348 | 3676 | { |
3349 | - if (is_string($usealttitle)) $usealttitle = dol_escape_htmltag($usealttitle); |
|
3350 | - else $usealttitle = $langs->trans('Info'); |
|
3677 | + if (is_string($usealttitle)) { |
|
3678 | + $usealttitle = dol_escape_htmltag($usealttitle); |
|
3679 | + } else { |
|
3680 | + $usealttitle = $langs->trans('Info'); |
|
3681 | + } |
|
3351 | 3682 | } |
3352 | 3683 | |
3353 | 3684 | return img_picto($usealttitle, 'info.png', 'style="vertical-align: middle;'.($usehelpcursor == 1 ? ' cursor: help': ($usehelpcursor == 2 ? ' cursor: pointer':'')).'"'); |
@@ -3363,7 +3694,9 @@ discard block |
||
3363 | 3694 | { |
3364 | 3695 | global $conf, $langs; |
3365 | 3696 | |
3366 | - if ($titlealt == 'default') $titlealt = $langs->trans('Informations'); |
|
3697 | + if ($titlealt == 'default') { |
|
3698 | + $titlealt = $langs->trans('Informations'); |
|
3699 | + } |
|
3367 | 3700 | |
3368 | 3701 | return img_picto($titlealt, 'info.png', 'style="vertical-align: middle;"'); |
3369 | 3702 | } |
@@ -3379,7 +3712,9 @@ discard block |
||
3379 | 3712 | { |
3380 | 3713 | global $conf, $langs; |
3381 | 3714 | |
3382 | - if ($titlealt == 'default') $titlealt = $langs->trans('Warning'); |
|
3715 | + if ($titlealt == 'default') { |
|
3716 | + $titlealt = $langs->trans('Warning'); |
|
3717 | + } |
|
3383 | 3718 | |
3384 | 3719 | //return '<div class="imglatecoin">'.img_picto($titlealt, 'warning_white.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): '')).'</div>'; |
3385 | 3720 | return img_picto($titlealt, 'warning.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): '')); |
@@ -3395,7 +3730,9 @@ discard block |
||
3395 | 3730 | { |
3396 | 3731 | global $conf, $langs; |
3397 | 3732 | |
3398 | - if ($titlealt == 'default') $titlealt = $langs->trans('Error'); |
|
3733 | + if ($titlealt == 'default') { |
|
3734 | + $titlealt = $langs->trans('Error'); |
|
3735 | + } |
|
3399 | 3736 | |
3400 | 3737 | return img_picto($titlealt, 'error.png', 'class="valigntextbottom"'); |
3401 | 3738 | } |
@@ -3411,7 +3748,9 @@ discard block |
||
3411 | 3748 | { |
3412 | 3749 | global $conf, $langs; |
3413 | 3750 | |
3414 | - if ($titlealt == 'default') $titlealt = $langs->trans('Next'); |
|
3751 | + if ($titlealt == 'default') { |
|
3752 | + $titlealt = $langs->trans('Next'); |
|
3753 | + } |
|
3415 | 3754 | |
3416 | 3755 | //return img_picto($titlealt, 'next.png', $moreatt); |
3417 | 3756 | return '<span class="fa fa-chevron-right paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).'"></span>'; |
@@ -3428,7 +3767,9 @@ discard block |
||
3428 | 3767 | { |
3429 | 3768 | global $conf, $langs; |
3430 | 3769 | |
3431 | - if ($titlealt == 'default') $titlealt = $langs->trans('Previous'); |
|
3770 | + if ($titlealt == 'default') { |
|
3771 | + $titlealt = $langs->trans('Previous'); |
|
3772 | + } |
|
3432 | 3773 | |
3433 | 3774 | //return img_picto($titlealt, 'previous.png', $moreatt); |
3434 | 3775 | return '<span class="fa fa-chevron-left paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).'"></span>'; |
@@ -3446,7 +3787,9 @@ discard block |
||
3446 | 3787 | { |
3447 | 3788 | global $conf, $langs; |
3448 | 3789 | |
3449 | - if ($titlealt == 'default') $titlealt = $langs->trans('Down'); |
|
3790 | + if ($titlealt == 'default') { |
|
3791 | + $titlealt = $langs->trans('Down'); |
|
3792 | + } |
|
3450 | 3793 | |
3451 | 3794 | return img_picto($titlealt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown'.($moreclass?" ".$moreclass:"").'"'); |
3452 | 3795 | } |
@@ -3463,7 +3806,9 @@ discard block |
||
3463 | 3806 | { |
3464 | 3807 | global $conf, $langs; |
3465 | 3808 | |
3466 | - if ($titlealt == 'default') $titlealt = $langs->trans('Up'); |
|
3809 | + if ($titlealt == 'default') { |
|
3810 | + $titlealt = $langs->trans('Up'); |
|
3811 | + } |
|
3467 | 3812 | |
3468 | 3813 | return img_picto($titlealt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup'.($moreclass?" ".$moreclass:"").'"'); |
3469 | 3814 | } |
@@ -3480,7 +3825,9 @@ discard block |
||
3480 | 3825 | { |
3481 | 3826 | global $conf, $langs; |
3482 | 3827 | |
3483 | - if ($titlealt == 'default') $titlealt = $langs->trans('Left'); |
|
3828 | + if ($titlealt == 'default') { |
|
3829 | + $titlealt = $langs->trans('Left'); |
|
3830 | + } |
|
3484 | 3831 | |
3485 | 3832 | return img_picto($titlealt, ($selected ? '1leftarrow_selected.png' : '1leftarrow.png'), $moreatt); |
3486 | 3833 | } |
@@ -3497,7 +3844,9 @@ discard block |
||
3497 | 3844 | { |
3498 | 3845 | global $conf, $langs; |
3499 | 3846 | |
3500 | - if ($titlealt == 'default') $titlealt = $langs->trans('Right'); |
|
3847 | + if ($titlealt == 'default') { |
|
3848 | + $titlealt = $langs->trans('Right'); |
|
3849 | + } |
|
3501 | 3850 | |
3502 | 3851 | return img_picto($titlealt, ($selected ? '1rightarrow_selected.png' : '1rightarrow.png'), $moreatt); |
3503 | 3852 | } |
@@ -3513,9 +3862,13 @@ discard block |
||
3513 | 3862 | { |
3514 | 3863 | global $conf, $langs; |
3515 | 3864 | |
3516 | - if ($titlealt == 'default') $titlealt = $langs->trans('Active'); |
|
3865 | + if ($titlealt == 'default') { |
|
3866 | + $titlealt = $langs->trans('Active'); |
|
3867 | + } |
|
3517 | 3868 | |
3518 | - if ($allow == 1) return img_picto($titlealt, 'tick.png'); |
|
3869 | + if ($allow == 1) { |
|
3870 | + return img_picto($titlealt, 'tick.png'); |
|
3871 | + } |
|
3519 | 3872 | |
3520 | 3873 | return '-'; |
3521 | 3874 | } |
@@ -3537,7 +3890,9 @@ discard block |
||
3537 | 3890 | $mimeimg = dol_mimetype($file, '', 2); |
3538 | 3891 | $mimefa = dol_mimetype($file, '', 4); |
3539 | 3892 | |
3540 | - if (empty($titlealt)) $titlealt = 'Mime type: '.$mimetype; |
|
3893 | + if (empty($titlealt)) { |
|
3894 | + $titlealt = 'Mime type: '.$mimetype; |
|
3895 | + } |
|
3541 | 3896 | |
3542 | 3897 | //return img_picto_common($titlealt, 'mime/'.$mimeimg, 'class="'.$morecss.'"'); |
3543 | 3898 | return '<i class="fa fa-'.$mimefa.' paddingright"></i>'; |
@@ -3560,10 +3915,15 @@ discard block |
||
3560 | 3915 | |
3561 | 3916 | global $conf,$langs; |
3562 | 3917 | |
3563 | - if ($titlealt == 'default') $titlealt = $langs->trans('Call'); |
|
3918 | + if ($titlealt == 'default') { |
|
3919 | + $titlealt = $langs->trans('Call'); |
|
3920 | + } |
|
3564 | 3921 | |
3565 | - if ($option == 1) $img = 'call'; |
|
3566 | - else $img = 'call_out'; |
|
3922 | + if ($option == 1) { |
|
3923 | + $img = 'call'; |
|
3924 | + } else { |
|
3925 | + $img = 'call_out'; |
|
3926 | + } |
|
3567 | 3927 | |
3568 | 3928 | return img_picto($titlealt, $img); |
3569 | 3929 | } |
@@ -3579,7 +3939,9 @@ discard block |
||
3579 | 3939 | { |
3580 | 3940 | global $conf, $langs; |
3581 | 3941 | |
3582 | - if ($titlealt == 'default') $titlealt = $langs->trans('Search'); |
|
3942 | + if ($titlealt == 'default') { |
|
3943 | + $titlealt = $langs->trans('Search'); |
|
3944 | + } |
|
3583 | 3945 | |
3584 | 3946 | $img = img_picto($titlealt, 'search.png', $other, false, 1); |
3585 | 3947 | |
@@ -3600,7 +3962,9 @@ discard block |
||
3600 | 3962 | { |
3601 | 3963 | global $conf, $langs; |
3602 | 3964 | |
3603 | - if ($titlealt == 'default') $titlealt = $langs->trans('Search'); |
|
3965 | + if ($titlealt == 'default') { |
|
3966 | + $titlealt = $langs->trans('Search'); |
|
3967 | + } |
|
3604 | 3968 | |
3605 | 3969 | $img = img_picto($titlealt, 'searchclear.png', $other, false, 1); |
3606 | 3970 | |
@@ -3663,15 +4027,21 @@ discard block |
||
3663 | 4027 | $langs->load("main"); |
3664 | 4028 | $langs->load("errors"); |
3665 | 4029 | |
3666 | - if ($_SERVER['DOCUMENT_ROOT']) // Mode web |
|
4030 | + if ($_SERVER['DOCUMENT_ROOT']) { |
|
4031 | + // Mode web |
|
3667 | 4032 | { |
3668 | 4033 | $out.=$langs->trans("DolibarrHasDetectedError").".<br>\n"; |
3669 | - if (! empty($conf->global->MAIN_FEATURES_LEVEL)) $out.="You use an experimental or develop level of features, so please do NOT report any bugs, except if problem is confirmed moving option MAIN_FEATURES_LEVEL back to 0.<br>\n"; |
|
4034 | + } |
|
4035 | + if (! empty($conf->global->MAIN_FEATURES_LEVEL)) { |
|
4036 | + $out.="You use an experimental or develop level of features, so please do NOT report any bugs, except if problem is confirmed moving option MAIN_FEATURES_LEVEL back to 0.<br>\n"; |
|
4037 | + } |
|
3670 | 4038 | $out.=$langs->trans("InformationToHelpDiagnose").":<br>\n"; |
3671 | 4039 | |
3672 | 4040 | $out.="<b>".$langs->trans("Date").":</b> ".dol_print_date(time(),'dayhourlog')."<br>\n"; |
3673 | 4041 | $out.="<b>".$langs->trans("Dolibarr").":</b> ".DOL_VERSION."<br>\n"; |
3674 | - if (isset($conf->global->MAIN_FEATURES_LEVEL)) $out.="<b>".$langs->trans("LevelOfFeature").":</b> ".$conf->global->MAIN_FEATURES_LEVEL."<br>\n"; |
|
4042 | + if (isset($conf->global->MAIN_FEATURES_LEVEL)) { |
|
4043 | + $out.="<b>".$langs->trans("LevelOfFeature").":</b> ".$conf->global->MAIN_FEATURES_LEVEL."<br>\n"; |
|
4044 | + } |
|
3675 | 4045 | if (function_exists("phpversion")) |
3676 | 4046 | { |
3677 | 4047 | $out.="<b>".$langs->trans("PHP").":</b> ".phpversion()."<br>\n"; |
@@ -3689,8 +4059,7 @@ discard block |
||
3689 | 4059 | $out.="<br>\n"; |
3690 | 4060 | $syslog.="url=".dol_escape_htmltag($_SERVER["REQUEST_URI"]); |
3691 | 4061 | $syslog.=", query_string=".dol_escape_htmltag($_SERVER["QUERY_STRING"]); |
3692 | - } |
|
3693 | - else // Mode CLI |
|
4062 | + } else // Mode CLI |
|
3694 | 4063 | { |
3695 | 4064 | $out.='> '.$langs->transnoentities("ErrorInternalErrorDetected").":\n".$argv[0]."\n"; |
3696 | 4065 | $syslog.="pid=".dol_getmypid(); |
@@ -3698,15 +4067,16 @@ discard block |
||
3698 | 4067 | |
3699 | 4068 | if (is_object($db)) |
3700 | 4069 | { |
3701 | - if ($_SERVER['DOCUMENT_ROOT']) // Mode web |
|
4070 | + if ($_SERVER['DOCUMENT_ROOT']) { |
|
4071 | + // Mode web |
|
3702 | 4072 | { |
3703 | 4073 | $out.="<b>".$langs->trans("DatabaseTypeManager").":</b> ".$db->type."<br>\n"; |
4074 | + } |
|
3704 | 4075 | $out.="<b>".$langs->trans("RequestLastAccessInError").":</b> ".($db->lastqueryerror()?dol_escape_htmltag($db->lastqueryerror()):$langs->trans("ErrorNoRequestInError"))."<br>\n"; |
3705 | 4076 | $out.="<b>".$langs->trans("ReturnCodeLastAccessInError").":</b> ".($db->lasterrno()?dol_escape_htmltag($db->lasterrno()):$langs->trans("ErrorNoRequestInError"))."<br>\n"; |
3706 | 4077 | $out.="<b>".$langs->trans("InformationLastAccessInError").":</b> ".($db->lasterror()?dol_escape_htmltag($db->lasterror()):$langs->trans("ErrorNoRequestInError"))."<br>\n"; |
3707 | 4078 | $out.="<br>\n"; |
3708 | - } |
|
3709 | - else // Mode CLI |
|
4079 | + } else // Mode CLI |
|
3710 | 4080 | { |
3711 | 4081 | // No dol_escape_htmltag for output, we are in CLI mode |
3712 | 4082 | $out.='> '.$langs->transnoentities("DatabaseTypeManager").":\n".$db->type."\n"; |
@@ -3724,19 +4094,27 @@ discard block |
||
3724 | 4094 | $langs->load("errors"); |
3725 | 4095 | |
3726 | 4096 | // Merge all into $errors array |
3727 | - if (is_array($error) && is_array($errors)) $errors=array_merge($error,$errors); |
|
3728 | - elseif (is_array($error)) $errors=$error; |
|
3729 | - elseif (is_array($errors)) $errors=array_merge(array($error),$errors); |
|
3730 | - else $errors=array_merge(array($error)); |
|
4097 | + if (is_array($error) && is_array($errors)) { |
|
4098 | + $errors=array_merge($error,$errors); |
|
4099 | + } elseif (is_array($error)) { |
|
4100 | + $errors=$error; |
|
4101 | + } elseif (is_array($errors)) { |
|
4102 | + $errors=array_merge(array($error),$errors); |
|
4103 | + } else { |
|
4104 | + $errors=array_merge(array($error)); |
|
4105 | + } |
|
3731 | 4106 | |
3732 | 4107 | foreach($errors as $msg) |
3733 | 4108 | { |
3734 | - if (empty($msg)) continue; |
|
3735 | - if ($_SERVER['DOCUMENT_ROOT']) // Mode web |
|
4109 | + if (empty($msg)) { |
|
4110 | + continue; |
|
4111 | + } |
|
4112 | + if ($_SERVER['DOCUMENT_ROOT']) { |
|
4113 | + // Mode web |
|
3736 | 4114 | { |
3737 | 4115 | $out.="<b>".$langs->trans("Message").":</b> ".dol_escape_htmltag($msg)."<br>\n" ; |
3738 | 4116 | } |
3739 | - else // Mode CLI |
|
4117 | + } else // Mode CLI |
|
3740 | 4118 | { |
3741 | 4119 | $out.='> '.$langs->transnoentities("Message").":\n".$msg."\n" ; |
3742 | 4120 | } |
@@ -3753,8 +4131,9 @@ discard block |
||
3753 | 4131 | $out.="<br>\n"; |
3754 | 4132 | } |
3755 | 4133 | |
3756 | - if (empty($dolibarr_main_prod)) print $out; |
|
3757 | - else |
|
4134 | + if (empty($dolibarr_main_prod)) { |
|
4135 | + print $out; |
|
4136 | + } else |
|
3758 | 4137 | { |
3759 | 4138 | print $langs->trans("DolibarrHasDetectedError").'. '; |
3760 | 4139 | print $langs->trans("YouCanSetOptionDolibarrMainProdToZero"); |
@@ -3781,7 +4160,9 @@ discard block |
||
3781 | 4160 | $now=dol_now(); |
3782 | 4161 | print '<br><div class="center login_main_message"><div class="'.$morecss.'">'; |
3783 | 4162 | print $langs->trans("ErrorContactEMail", $conf->global->MAIN_INFO_SOCIETE_MAIL, $prefixcode.dol_print_date($now,'%Y%m%d')); |
3784 | - if ($errormessage) print '<br><br>'.$errormessage; |
|
4163 | + if ($errormessage) { |
|
4164 | + print '<br><br>'.$errormessage; |
|
4165 | + } |
|
3785 | 4166 | if (is_array($errormessages) && count($errormessages)) |
3786 | 4167 | { |
3787 | 4168 | foreach($errormessages as $mesgtoshow) |
@@ -3839,7 +4220,9 @@ discard block |
||
3839 | 4220 | $sortimg=''; |
3840 | 4221 | |
3841 | 4222 | $tag='th'; |
3842 | - if ($thead==2) $tag='div'; |
|
4223 | + if ($thead==2) { |
|
4224 | + $tag='div'; |
|
4225 | + } |
|
3843 | 4226 | |
3844 | 4227 | $tmpsortfield=explode(',',$sortfield); |
3845 | 4228 | $sortfield1=trim($tmpsortfield[0]); // If $sortfield is 'd.datep,d.id', it becomes 'd.datep' |
@@ -3849,42 +4232,63 @@ discard block |
||
3849 | 4232 | //var_dump('field='.$field.' field1='.$field1.' sortfield='.$sortfield.' sortfield1='.$sortfield1); |
3850 | 4233 | // If field is used as sort criteria we use a specific css class liste_titre_sel |
3851 | 4234 | // Example if (sortfield,field)=("nom","xxx.nom") or (sortfield,field)=("nom","nom") |
3852 | - if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace("/^[^\.]+\./","",$field1))) $out.= '<'.$tag.' class="'.$prefix.'liste_titre_sel" '. $moreattrib.'>'; |
|
3853 | - else $out.= '<'.$tag.' class="'.$prefix.'liste_titre" '. $moreattrib.'>'; |
|
4235 | + if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace("/^[^\.]+\./","",$field1))) { |
|
4236 | + $out.= '<'.$tag.' class="'.$prefix.'liste_titre_sel" '. $moreattrib.'>'; |
|
4237 | + } else { |
|
4238 | + $out.= '<'.$tag.' class="'.$prefix.'liste_titre" '. $moreattrib.'>'; |
|
4239 | + } |
|
3854 | 4240 | |
3855 | - if (empty($thead) && $field && empty($disablesortlink)) // If this is a sort field |
|
4241 | + if (empty($thead) && $field && empty($disablesortlink)) { |
|
4242 | + // If this is a sort field |
|
3856 | 4243 | { |
3857 | 4244 | $options=preg_replace('/sortfield=([a-zA-Z0-9,\s\.]+)/i','',$moreparam); |
4245 | + } |
|
3858 | 4246 | $options=preg_replace('/sortorder=([a-zA-Z0-9,\s\.]+)/i','',$options); |
3859 | 4247 | $options=preg_replace('/&+/i','&',$options); |
3860 | - if (! preg_match('/^&/',$options)) $options='&'.$options; |
|
4248 | + if (! preg_match('/^&/',$options)) { |
|
4249 | + $options='&'.$options; |
|
4250 | + } |
|
3861 | 4251 | |
3862 | - if ($field1 != $sortfield1) // We are on another field |
|
4252 | + if ($field1 != $sortfield1) { |
|
4253 | + // We are on another field |
|
3863 | 4254 | { |
3864 | 4255 | if (preg_match('/^DESC/', $sortorder)) $out.= '<a class="reposition" href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'; |
3865 | - else $out.= '<a class="reposition" href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'; |
|
3866 | - } |
|
3867 | - else // We are of first sorting criteria |
|
4256 | + } else { |
|
4257 | + $out.= '<a class="reposition" href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'; |
|
4258 | + } |
|
4259 | + } else // We are of first sorting criteria |
|
3868 | 4260 | { |
3869 | - if (preg_match('/^ASC/', $sortorder)) $out.= '<a class="reposition" href="'.$file.'?sortfield='.$sortfield.'&sortorder=desc&begin='.$begin.$options.'">'; |
|
3870 | - else $out.= '<a class="reposition" href="'.$file.'?sortfield='.$sortfield.'&sortorder=asc&begin='.$begin.$options.'">'; |
|
4261 | + if (preg_match('/^ASC/', $sortorder)) { |
|
4262 | + $out.= '<a class="reposition" href="'.$file.'?sortfield='.$sortfield.'&sortorder=desc&begin='.$begin.$options.'">'; |
|
4263 | + } else { |
|
4264 | + $out.= '<a class="reposition" href="'.$file.'?sortfield='.$sortfield.'&sortorder=asc&begin='.$begin.$options.'">'; |
|
4265 | + } |
|
3871 | 4266 | } |
3872 | 4267 | } |
3873 | 4268 | |
3874 | - if ($tooltip) $out.=$form->textwithpicto($langs->trans($name), $langs->trans($tooltip)); |
|
3875 | - else $out.=$langs->trans($name); |
|
4269 | + if ($tooltip) { |
|
4270 | + $out.=$form->textwithpicto($langs->trans($name), $langs->trans($tooltip)); |
|
4271 | + } else { |
|
4272 | + $out.=$langs->trans($name); |
|
4273 | + } |
|
3876 | 4274 | |
3877 | - if (empty($thead) && $field && empty($disablesortlink)) // If this is a sort field |
|
4275 | + if (empty($thead) && $field && empty($disablesortlink)) { |
|
4276 | + // If this is a sort field |
|
3878 | 4277 | { |
3879 | 4278 | $out.='</a>'; |
3880 | 4279 | } |
4280 | + } |
|
3881 | 4281 | |
3882 | - if (empty($thead) && $field) // If this is a sort field |
|
4282 | + if (empty($thead) && $field) { |
|
4283 | + // If this is a sort field |
|
3883 | 4284 | { |
3884 | 4285 | $options=preg_replace('/sortfield=([a-zA-Z0-9,\s\.]+)/i','',$moreparam); |
4286 | + } |
|
3885 | 4287 | $options=preg_replace('/sortorder=([a-zA-Z0-9,\s\.]+)/i','',$options); |
3886 | 4288 | $options=preg_replace('/&+/i','&',$options); |
3887 | - if (! preg_match('/^&/',$options)) $options='&'.$options; |
|
4289 | + if (! preg_match('/^&/',$options)) { |
|
4290 | + $options='&'.$options; |
|
4291 | + } |
|
3888 | 4292 | |
3889 | 4293 | //print " "; |
3890 | 4294 | //$sortimg.= '<img width="2" src="'.DOL_URL_ROOT.'/theme/common/transparent.png" alt="">'; |
@@ -3894,8 +4298,7 @@ discard block |
||
3894 | 4298 | { |
3895 | 4299 | //$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>'; |
3896 | 4300 | //$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",0).'</a>'; |
3897 | - } |
|
3898 | - else |
|
4301 | + } else |
|
3899 | 4302 | { |
3900 | 4303 | if (preg_match('/^DESC/', $sortorder)) { |
3901 | 4304 | //$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>'; |
@@ -3969,12 +4372,18 @@ discard block |
||
3969 | 4372 | |
3970 | 4373 | $return=''; |
3971 | 4374 | |
3972 | - if ($picto == 'setup') $picto='title.png'; |
|
3973 | - if (($conf->browser->name == 'ie') && $picto=='title.png') $picto='title.gif'; |
|
4375 | + if ($picto == 'setup') { |
|
4376 | + $picto='title.png'; |
|
4377 | + } |
|
4378 | + if (($conf->browser->name == 'ie') && $picto=='title.png') { |
|
4379 | + $picto='title.gif'; |
|
4380 | + } |
|
3974 | 4381 | |
3975 | 4382 | $return.= "\n"; |
3976 | 4383 | $return.= '<table '.($id?'id="'.$id.'" ':'').'summary="" class="centpercent notopnoleftnoright'.($morecssontable?' '.$morecssontable:'').'" style="margin-bottom: 2px;"><tr>'; |
3977 | - if ($picto) $return.= '<td class="nobordernopadding widthpictotitle" valign="middle">'.img_picto('',$picto, 'class="valignmiddle widthpictotitle" id="pictotitle"', $pictoisfullpath).'</td>'; |
|
4384 | + if ($picto) { |
|
4385 | + $return.= '<td class="nobordernopadding widthpictotitle" valign="middle">'.img_picto('',$picto, 'class="valignmiddle widthpictotitle" id="pictotitle"', $pictoisfullpath).'</td>'; |
|
4386 | + } |
|
3978 | 4387 | $return.= '<td class="nobordernopadding" valign="middle">'; |
3979 | 4388 | $return.= '<div class="titre">'.$titre.'</div>'; |
3980 | 4389 | $return.= '</td>'; |
@@ -4020,14 +4429,19 @@ discard block |
||
4020 | 4429 | $savtotalnboflines = $totalnboflines; |
4021 | 4430 | $totalnboflines=abs($totalnboflines); |
4022 | 4431 | |
4023 | - if ($picto == 'setup') $picto='title_setup.png'; |
|
4024 | - if (($conf->browser->name == 'ie') && $picto=='title_generic.png') $picto='title.gif'; |
|
4025 | - if ($limit < 0) $limit = $conf->liste_limit; |
|
4432 | + if ($picto == 'setup') { |
|
4433 | + $picto='title_setup.png'; |
|
4434 | + } |
|
4435 | + if (($conf->browser->name == 'ie') && $picto=='title_generic.png') { |
|
4436 | + $picto='title.gif'; |
|
4437 | + } |
|
4438 | + if ($limit < 0) { |
|
4439 | + $limit = $conf->liste_limit; |
|
4440 | + } |
|
4026 | 4441 | if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) |
4027 | 4442 | { |
4028 | 4443 | $nextpage = 1; |
4029 | - } |
|
4030 | - else |
|
4444 | + } else |
|
4031 | 4445 | { |
4032 | 4446 | $nextpage = 0; |
4033 | 4447 | } |
@@ -4040,9 +4454,13 @@ discard block |
||
4040 | 4454 | // Left |
4041 | 4455 | //if ($picto && $titre) print '<td class="nobordernopadding hideonsmartphone" width="40" align="left" valign="middle">'.img_picto('', $picto, 'id="pictotitle"', $pictoisfullpath).'</td>'; |
4042 | 4456 | print '<td class="nobordernopadding valignmiddle">'; |
4043 | - if ($picto && $titre) print img_picto('', $picto, 'class="hideonsmartphone valignmiddle" id="pictotitle"', $pictoisfullpath); |
|
4457 | + if ($picto && $titre) { |
|
4458 | + print img_picto('', $picto, 'class="hideonsmartphone valignmiddle" id="pictotitle"', $pictoisfullpath); |
|
4459 | + } |
|
4044 | 4460 | print '<div class="titre inline-block">'.$titre; |
4045 | - if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') print ' ('.$totalnboflines.')'; |
|
4461 | + if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') { |
|
4462 | + print ' ('.$totalnboflines.')'; |
|
4463 | + } |
|
4046 | 4464 | print '</div></td>'; |
4047 | 4465 | |
4048 | 4466 | // Center |
@@ -4053,27 +4471,39 @@ discard block |
||
4053 | 4471 | |
4054 | 4472 | // Right |
4055 | 4473 | print '<td class="nobordernopadding valignmiddle" align="right">'; |
4056 | - if ($sortfield) $options .= "&sortfield=".urlencode($sortfield); |
|
4057 | - if ($sortorder) $options .= "&sortorder=".urlencode($sortorder); |
|
4474 | + if ($sortfield) { |
|
4475 | + $options .= "&sortfield=".urlencode($sortfield); |
|
4476 | + } |
|
4477 | + if ($sortorder) { |
|
4478 | + $options .= "&sortorder=".urlencode($sortorder); |
|
4479 | + } |
|
4058 | 4480 | // Show navigation bar |
4059 | 4481 | $pagelist = ''; |
4060 | 4482 | if ($savlimit != 0 && ($page > 0 || $num > $limit)) |
4061 | 4483 | { |
4062 | - if ($totalnboflines) // If we know total nb of lines |
|
4484 | + if ($totalnboflines) { |
|
4485 | + // If we know total nb of lines |
|
4063 | 4486 | { |
4064 | 4487 | // Define nb of extra page links before and after selected page + ... + first or last |
4065 | 4488 | $maxnbofpage=(empty($conf->dol_optimize_smallscreen) ? 4 : 1); |
4489 | + } |
|
4066 | 4490 | |
4067 | - if ($limit > 0) $nbpages=ceil($totalnboflines/$limit); |
|
4068 | - else $nbpages=1; |
|
4491 | + if ($limit > 0) { |
|
4492 | + $nbpages=ceil($totalnboflines/$limit); |
|
4493 | + } else { |
|
4494 | + $nbpages=1; |
|
4495 | + } |
|
4069 | 4496 | $cpt=($page-$maxnbofpage); |
4070 | 4497 | if ($cpt < 0) { $cpt=0; } |
4071 | 4498 | |
4072 | 4499 | if ($cpt>=1) |
4073 | 4500 | { |
4074 | 4501 | $pagelist.= '<li'.(($conf->dol_use_jmobile != 4)?' class="pagination"':'').'><a href="'.$file.'?page=0'.$options.'">1</a></li>'; |
4075 | - if ($cpt > 2) $pagelist.='<li'.(($conf->dol_use_jmobile != 4)?' class="pagination"':'').'><span '.(($conf->dol_use_jmobile != 4)?'class="inactive"':'').'>...</span></li>'; |
|
4076 | - else if ($cpt == 2) $pagelist.='<li'.(($conf->dol_use_jmobile != 4)?' class="pagination"':'').'><a href="'.$file.'?page=1'.$options.'">2</a></li>'; |
|
4502 | + if ($cpt > 2) { |
|
4503 | + $pagelist.='<li'.(($conf->dol_use_jmobile != 4)?' class="pagination"':'').'><span '.(($conf->dol_use_jmobile != 4)?'class="inactive"':'').'>...</span></li>'; |
|
4504 | + } else if ($cpt == 2) { |
|
4505 | + $pagelist.='<li'.(($conf->dol_use_jmobile != 4)?' class="pagination"':'').'><a href="'.$file.'?page=1'.$options.'">2</a></li>'; |
|
4506 | + } |
|
4077 | 4507 | } |
4078 | 4508 | |
4079 | 4509 | do |
@@ -4081,8 +4511,7 @@ discard block |
||
4081 | 4511 | if ($cpt==$page) |
4082 | 4512 | { |
4083 | 4513 | $pagelist.= '<li'.(($conf->dol_use_jmobile != 4)?' class="pagination"':'').'><span '.(($conf->dol_use_jmobile != 4)?'class="active"':'').'>'.($page+1).'</span></li>'; |
4084 | - } |
|
4085 | - else |
|
4514 | + } else |
|
4086 | 4515 | { |
4087 | 4516 | $pagelist.= '<li'.(($conf->dol_use_jmobile != 4)?' class="pagination"':'').'><a href="'.$file.'?page='.$cpt.$options.'">'.($cpt+1).'</a></li>'; |
4088 | 4517 | } |
@@ -4092,12 +4521,14 @@ discard block |
||
4092 | 4521 | |
4093 | 4522 | if ($cpt<$nbpages) |
4094 | 4523 | { |
4095 | - if ($cpt<$nbpages-2) $pagelist.= '<li'.(($conf->dol_use_jmobile != 4)?' class="pagination"':'').'><span '.(($conf->dol_use_jmobile != 4)?'class="inactive"':'').'>...</span></li>'; |
|
4096 | - else if ($cpt == $nbpages-2) $pagelist.= '<li'.(($conf->dol_use_jmobile != 4)?' class="pagination"':'').'><a href="'.$file.'?page='.($nbpages-2).$options.'">'.($nbpages - 1).'</a></li>'; |
|
4524 | + if ($cpt<$nbpages-2) { |
|
4525 | + $pagelist.= '<li'.(($conf->dol_use_jmobile != 4)?' class="pagination"':'').'><span '.(($conf->dol_use_jmobile != 4)?'class="inactive"':'').'>...</span></li>'; |
|
4526 | + } else if ($cpt == $nbpages-2) { |
|
4527 | + $pagelist.= '<li'.(($conf->dol_use_jmobile != 4)?' class="pagination"':'').'><a href="'.$file.'?page='.($nbpages-2).$options.'">'.($nbpages - 1).'</a></li>'; |
|
4528 | + } |
|
4097 | 4529 | $pagelist.= '<li'.(($conf->dol_use_jmobile != 4)?' class="pagination"':'').'><a href="'.$file.'?page='.($nbpages-1).$options.'">'.$nbpages.'</a></li>'; |
4098 | 4530 | } |
4099 | - } |
|
4100 | - else |
|
4531 | + } else |
|
4101 | 4532 | { |
4102 | 4533 | $pagelist.= '<li'.(($conf->dol_use_jmobile != 4)?' class="pagination"':'').'><span '.(($conf->dol_use_jmobile != 4)?'class="active"':'').'>'.($page+1)."</li>"; |
4103 | 4534 | } |
@@ -4135,15 +4566,21 @@ discard block |
||
4135 | 4566 | $pagesizechoices='10:10,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000,5000:5000'; |
4136 | 4567 | //$pagesizechoices.=',0:'.$langs->trans("All"); // Not yet supported |
4137 | 4568 | //$pagesizechoices.=',2:2'; |
4138 | - if (! empty($conf->global->MAIN_PAGESIZE_CHOICES)) $pagesizechoices=$conf->global->MAIN_PAGESIZE_CHOICES; |
|
4569 | + if (! empty($conf->global->MAIN_PAGESIZE_CHOICES)) { |
|
4570 | + $pagesizechoices=$conf->global->MAIN_PAGESIZE_CHOICES; |
|
4571 | + } |
|
4139 | 4572 | |
4140 | 4573 | print '<li class="pagination">'; |
4141 | 4574 | print '<select class="flat selectlimit" name="limit" title="'.dol_escape_htmltag($langs->trans("MaxNbOfRecordPerPage")).'">'; |
4142 | 4575 | $tmpchoice=explode(',',$pagesizechoices); |
4143 | 4576 | $tmpkey=$limit.':'.$limit; |
4144 | - if (! in_array($tmpkey, $tmpchoice)) $tmpchoice[]=$tmpkey; |
|
4577 | + if (! in_array($tmpkey, $tmpchoice)) { |
|
4578 | + $tmpchoice[]=$tmpkey; |
|
4579 | + } |
|
4145 | 4580 | $tmpkey=$conf->liste_limit.':'.$conf->liste_limit; |
4146 | - if (! in_array($tmpkey, $tmpchoice)) $tmpchoice[]=$tmpkey; |
|
4581 | + if (! in_array($tmpkey, $tmpchoice)) { |
|
4582 | + $tmpchoice[]=$tmpkey; |
|
4583 | + } |
|
4147 | 4584 | asort($tmpchoice, SORT_NUMERIC); |
4148 | 4585 | $found=false; |
4149 | 4586 | foreach($tmpchoice as $val) |
@@ -4231,13 +4668,16 @@ discard block |
||
4231 | 4668 | } |
4232 | 4669 | |
4233 | 4670 | // If rate is '9/9/9' we don't change it. If rate is '9.000' we apply price() |
4234 | - if (! preg_match('/\//', $rate)) $ret=price($rate,0,'',0,0).($addpercent?'%':''); |
|
4235 | - else |
|
4671 | + if (! preg_match('/\//', $rate)) { |
|
4672 | + $ret=price($rate,0,'',0,0).($addpercent?'%':''); |
|
4673 | + } else |
|
4236 | 4674 | { |
4237 | 4675 | // TODO Split on / and output with a price2num to have clean numbers without ton of 000. |
4238 | 4676 | $ret=$rate.($addpercent?'%':''); |
4239 | 4677 | } |
4240 | - if (($info_bits & 1) && $usestarfornpr >= 0) $ret.=' *'; |
|
4678 | + if (($info_bits & 1) && $usestarfornpr >= 0) { |
|
4679 | + $ret.=' *'; |
|
4680 | + } |
|
4241 | 4681 | $ret.=$morelabel; |
4242 | 4682 | return $ret; |
4243 | 4683 | } |
@@ -4263,21 +4703,35 @@ discard block |
||
4263 | 4703 | global $langs,$conf; |
4264 | 4704 | |
4265 | 4705 | // Clean parameters |
4266 | - if (empty($amount)) $amount=0; // To have a numeric value if amount not defined or = '' |
|
4706 | + if (empty($amount)) { |
|
4707 | + $amount=0; |
|
4708 | + } |
|
4709 | + // To have a numeric value if amount not defined or = '' |
|
4267 | 4710 | $amount = (is_numeric($amount)?$amount:0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number) |
4268 | - if ($rounding < 0) $rounding=min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); |
|
4711 | + if ($rounding < 0) { |
|
4712 | + $rounding=min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); |
|
4713 | + } |
|
4269 | 4714 | $nbdecimal=$rounding; |
4270 | 4715 | |
4271 | 4716 | // Output separators by default (french) |
4272 | 4717 | $dec=','; $thousand=' '; |
4273 | 4718 | |
4274 | 4719 | // If $outlangs not forced, we use use language |
4275 | - if (! is_object($outlangs)) $outlangs=$langs; |
|
4720 | + if (! is_object($outlangs)) { |
|
4721 | + $outlangs=$langs; |
|
4722 | + } |
|
4276 | 4723 | |
4277 | - if ($outlangs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$outlangs->transnoentitiesnoconv("SeparatorDecimal"); |
|
4278 | - if ($outlangs->transnoentitiesnoconv("SeparatorThousand")!= "SeparatorThousand") $thousand=$outlangs->transnoentitiesnoconv("SeparatorThousand"); |
|
4279 | - if ($thousand == 'None') $thousand=''; |
|
4280 | - else if ($thousand == 'Space') $thousand=' '; |
|
4724 | + if ($outlangs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") { |
|
4725 | + $dec=$outlangs->transnoentitiesnoconv("SeparatorDecimal"); |
|
4726 | + } |
|
4727 | + if ($outlangs->transnoentitiesnoconv("SeparatorThousand")!= "SeparatorThousand") { |
|
4728 | + $thousand=$outlangs->transnoentitiesnoconv("SeparatorThousand"); |
|
4729 | + } |
|
4730 | + if ($thousand == 'None') { |
|
4731 | + $thousand=''; |
|
4732 | + } else if ($thousand == 'Space') { |
|
4733 | + $thousand=' '; |
|
4734 | + } |
|
4281 | 4735 | //print "outlangs=".$outlangs->defaultlang." amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>"; |
4282 | 4736 | |
4283 | 4737 | //print "amount=".$amount."-"; |
@@ -4290,7 +4744,9 @@ discard block |
||
4290 | 4744 | $end=''; |
4291 | 4745 | |
4292 | 4746 | // We increase nbdecimal if there is more decimal than asked (to not loose information) |
4293 | - if (dol_strlen($decpart) > $nbdecimal) $nbdecimal=dol_strlen($decpart); |
|
4747 | + if (dol_strlen($decpart) > $nbdecimal) { |
|
4748 | + $nbdecimal=dol_strlen($decpart); |
|
4749 | + } |
|
4294 | 4750 | // Si on depasse max |
4295 | 4751 | if ($trunc && $nbdecimal > $conf->global->MAIN_MAX_DECIMALS_SHOWN) |
4296 | 4752 | { |
@@ -4303,7 +4759,9 @@ discard block |
||
4303 | 4759 | } |
4304 | 4760 | |
4305 | 4761 | // If force rounding |
4306 | - if ($forcerounding >= 0) $nbdecimal = $forcerounding; |
|
4762 | + if ($forcerounding >= 0) { |
|
4763 | + $nbdecimal = $forcerounding; |
|
4764 | + } |
|
4307 | 4765 | |
4308 | 4766 | // Format number |
4309 | 4767 | $output=number_format($amount, $nbdecimal, $dec, $thousand); |
@@ -4316,11 +4774,14 @@ discard block |
||
4316 | 4774 | $cursymbolbefore=$cursymbolafter=''; |
4317 | 4775 | if ($currency_code) |
4318 | 4776 | { |
4319 | - if ($currency_code == 'auto') $currency_code=$conf->currency; |
|
4777 | + if ($currency_code == 'auto') { |
|
4778 | + $currency_code=$conf->currency; |
|
4779 | + } |
|
4320 | 4780 | |
4321 | 4781 | $listofcurrenciesbefore=array('USD','GBP','AUD','MXN','PEN','CNY'); |
4322 | - if (in_array($currency_code,$listofcurrenciesbefore)) $cursymbolbefore.=$outlangs->getCurrencySymbol($currency_code); |
|
4323 | - else |
|
4782 | + if (in_array($currency_code,$listofcurrenciesbefore)) { |
|
4783 | + $cursymbolbefore.=$outlangs->getCurrencySymbol($currency_code); |
|
4784 | + } else |
|
4324 | 4785 | { |
4325 | 4786 | $tmpcur=$outlangs->getCurrencySymbol($currency_code); |
4326 | 4787 | $cursymbolafter.=($tmpcur == $currency_code ? ' '.$tmpcur : $tmpcur); |
@@ -4353,14 +4814,22 @@ discard block |
||
4353 | 4814 | // Numbers must be '1234.56' |
4354 | 4815 | // Decimal delimiter for PHP and database SQL requests must be '.' |
4355 | 4816 | $dec=','; $thousand=' '; |
4356 | - if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->transnoentitiesnoconv("SeparatorDecimal"); |
|
4357 | - if ($langs->transnoentitiesnoconv("SeparatorThousand")!= "SeparatorThousand") $thousand=$langs->transnoentitiesnoconv("SeparatorThousand"); |
|
4358 | - if ($thousand == 'None') $thousand=''; |
|
4359 | - elseif ($thousand == 'Space') $thousand=' '; |
|
4817 | + if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") { |
|
4818 | + $dec=$langs->transnoentitiesnoconv("SeparatorDecimal"); |
|
4819 | + } |
|
4820 | + if ($langs->transnoentitiesnoconv("SeparatorThousand")!= "SeparatorThousand") { |
|
4821 | + $thousand=$langs->transnoentitiesnoconv("SeparatorThousand"); |
|
4822 | + } |
|
4823 | + if ($thousand == 'None') { |
|
4824 | + $thousand=''; |
|
4825 | + } elseif ($thousand == 'Space') { |
|
4826 | + $thousand=' '; |
|
4827 | + } |
|
4360 | 4828 | //print "amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>"; |
4361 | 4829 | |
4362 | 4830 | // Convert value to universal number format (no thousand separator, '.' as decimal separator) |
4363 | - if ($alreadysqlnb != 1) // If not a PHP number or unknown, we change format |
|
4831 | + if ($alreadysqlnb != 1) { |
|
4832 | + // If not a PHP number or unknown, we change format |
|
4364 | 4833 | { |
4365 | 4834 | //print 'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'<br>'; |
4366 | 4835 | |
@@ -4369,7 +4838,9 @@ discard block |
||
4369 | 4838 | if (is_numeric($amount)) |
4370 | 4839 | { |
4371 | 4840 | // We put in temps value of decimal ("0.00001"). Works with 0 and 2.0E-5 and 9999.10 |
4372 | - $temps=sprintf("%0.10F",$amount-intval($amount)); // temps=0.0000000000 or 0.0000200000 or 9999.1000000000 |
|
4841 | + $temps=sprintf("%0.10F",$amount-intval($amount)); |
|
4842 | + } |
|
4843 | + // temps=0.0000000000 or 0.0000200000 or 9999.1000000000 |
|
4373 | 4844 | $temps=preg_replace('/([\.1-9])0+$/','\\1',$temps); // temps=0. or 0.00002 or 9999.1 |
4374 | 4845 | $nbofdec=max(0,dol_strlen($temps)-2); // -2 to remove "0." |
4375 | 4846 | $amount=number_format($amount,$nbofdec,$dec,$thousand); |
@@ -4377,7 +4848,10 @@ discard block |
||
4377 | 4848 | //print "QQ".$amount.'<br>'; |
4378 | 4849 | |
4379 | 4850 | // Now make replace (the main goal of function) |
4380 | - if ($thousand != ',' && $thousand != '.') $amount=str_replace(',','.',$amount); // To accept 2 notations for french users |
|
4851 | + if ($thousand != ',' && $thousand != '.') { |
|
4852 | + $amount=str_replace(',','.',$amount); |
|
4853 | + } |
|
4854 | + // To accept 2 notations for french users |
|
4381 | 4855 | $amount=str_replace(' ','',$amount); // To avoid spaces |
4382 | 4856 | $amount=str_replace($thousand,'',$amount); // Replace of thousand before replace of dec to avoid pb if thousand is . |
4383 | 4857 | $amount=str_replace($dec,'.',$amount); |
@@ -4387,13 +4861,24 @@ discard block |
||
4387 | 4861 | if ($rounding) |
4388 | 4862 | { |
4389 | 4863 | $nbofdectoround=''; |
4390 | - if ($rounding == 'MU') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_UNIT; |
|
4391 | - elseif ($rounding == 'MT') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_TOT; |
|
4392 | - elseif ($rounding == 'MS') $nbofdectoround=empty($conf->global->MAIN_MAX_DECIMALS_STOCK)?5:$conf->global->MAIN_MAX_DECIMALS_STOCK; |
|
4393 | - elseif (is_numeric($rounding)) $nbofdectoround=$rounding; // For admin info page |
|
4864 | + if ($rounding == 'MU') { |
|
4865 | + $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_UNIT; |
|
4866 | + } elseif ($rounding == 'MT') { |
|
4867 | + $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_TOT; |
|
4868 | + } elseif ($rounding == 'MS') { |
|
4869 | + $nbofdectoround=empty($conf->global->MAIN_MAX_DECIMALS_STOCK)?5:$conf->global->MAIN_MAX_DECIMALS_STOCK; |
|
4870 | + } elseif (is_numeric($rounding)) { |
|
4871 | + $nbofdectoround=$rounding; |
|
4872 | + } |
|
4873 | + // For admin info page |
|
4394 | 4874 | //print "RR".$amount.' - '.$nbofdectoround.'<br>'; |
4395 | - if (dol_strlen($nbofdectoround)) $amount = round($amount,$nbofdectoround); // $nbofdectoround can be 0. |
|
4396 | - else return 'ErrorBadParameterProvidedToFunction'; |
|
4875 | + if (dol_strlen($nbofdectoround)) { |
|
4876 | + $amount = round($amount,$nbofdectoround); |
|
4877 | + } |
|
4878 | + // $nbofdectoround can be 0. |
|
4879 | + else { |
|
4880 | + return 'ErrorBadParameterProvidedToFunction'; |
|
4881 | + } |
|
4397 | 4882 | //print 'SS'.$amount.' - '.$nbofdec.' - '.$dec.' - '.$thousand.' - '.$nbofdectoround.'<br>'; |
4398 | 4883 | |
4399 | 4884 | // Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number |
@@ -4410,7 +4895,10 @@ discard block |
||
4410 | 4895 | |
4411 | 4896 | // Always make replace because each math function (like round) replace |
4412 | 4897 | // with local values and we want a number that has a SQL string format x.y |
4413 | - if ($thousand != ',' && $thousand != '.') $amount=str_replace(',','.',$amount); // To accept 2 notations for french users |
|
4898 | + if ($thousand != ',' && $thousand != '.') { |
|
4899 | + $amount=str_replace(',','.',$amount); |
|
4900 | + } |
|
4901 | + // To accept 2 notations for french users |
|
4414 | 4902 | $amount=str_replace(' ','',$amount); // To avoid spaces |
4415 | 4903 | $amount=str_replace($thousand,'',$amount); // Replace of thousand before replace of dec to avoid pb if thousand is . |
4416 | 4904 | $amount=str_replace($dec,'.',$amount); |
@@ -4439,18 +4927,15 @@ discard block |
||
4439 | 4927 | { |
4440 | 4928 | $dimension = $dimension * 1000000; |
4441 | 4929 | $unit = $unit - 6; |
4442 | - } |
|
4443 | - elseif (($forceunitoutput == 'no' && $dimension < 1/10) || (is_numeric($forceunitoutput) && $forceunitoutput == -3)) |
|
4930 | + } elseif (($forceunitoutput == 'no' && $dimension < 1/10) || (is_numeric($forceunitoutput) && $forceunitoutput == -3)) |
|
4444 | 4931 | { |
4445 | 4932 | $dimension = $dimension * 1000; |
4446 | 4933 | $unit = $unit - 3; |
4447 | - } |
|
4448 | - elseif (($forceunitoutput == 'no' && $dimension > 100000000) || (is_numeric($forceunitoutput) && $forceunitoutput == 6)) |
|
4934 | + } elseif (($forceunitoutput == 'no' && $dimension > 100000000) || (is_numeric($forceunitoutput) && $forceunitoutput == 6)) |
|
4449 | 4935 | { |
4450 | 4936 | $dimension = $dimension / 1000000; |
4451 | 4937 | $unit = $unit + 6; |
4452 | - } |
|
4453 | - elseif (($forceunitoutput == 'no' && $dimension > 100000) || (is_numeric($forceunitoutput) && $forceunitoutput == 3)) |
|
4938 | + } elseif (($forceunitoutput == 'no' && $dimension > 100000) || (is_numeric($forceunitoutput) && $forceunitoutput == 3)) |
|
4454 | 4939 | { |
4455 | 4940 | $dimension = $dimension / 1000; |
4456 | 4941 | $unit = $unit + 3; |
@@ -4478,14 +4963,18 @@ discard block |
||
4478 | 4963 | { |
4479 | 4964 | global $db, $conf, $mysoc; |
4480 | 4965 | |
4481 | - if (empty($thirdparty_seller) || ! is_object($thirdparty_seller)) $thirdparty_seller=$mysoc; |
|
4966 | + if (empty($thirdparty_seller) || ! is_object($thirdparty_seller)) { |
|
4967 | + $thirdparty_seller=$mysoc; |
|
4968 | + } |
|
4482 | 4969 | |
4483 | 4970 | dol_syslog("get_localtax tva=".$vatrate." local=".$local." thirdparty_buyer id=".(is_object($thirdparty_buyer)?$thirdparty_buyer->id:'')."/country_code=".(is_object($thirdparty_buyer)?$thirdparty_buyer->country_code:'')." thirdparty_seller id=".$thirdparty_seller->id."/country_code=".$thirdparty_seller->country_code." thirdparty_seller localtax1_assuj=".$thirdparty_seller->localtax1_assuj." thirdparty_seller localtax2_assuj=".$thirdparty_seller->localtax2_assuj); |
4484 | 4971 | |
4485 | 4972 | $vatratecleaned = $vatrate; |
4486 | - if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)" |
|
4973 | + if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) { |
|
4974 | + // If vat is "xx (yy)" |
|
4487 | 4975 | { |
4488 | 4976 | $vatratecleaned = trim($reg[1]); |
4977 | + } |
|
4489 | 4978 | $vatratecode = $reg[2]; |
4490 | 4979 | } |
4491 | 4980 | |
@@ -4495,38 +4984,51 @@ discard block |
||
4495 | 4984 | }*/ |
4496 | 4985 | |
4497 | 4986 | // Some test to guess with no need to make database access |
4498 | - if ($mysoc->country_code == 'ES') // For spain localtaxes 1 and 2, tax is qualified if buyer use local tax |
|
4987 | + if ($mysoc->country_code == 'ES') { |
|
4988 | + // For spain localtaxes 1 and 2, tax is qualified if buyer use local tax |
|
4499 | 4989 | { |
4500 | 4990 | if ($local == 1) |
4501 | 4991 | { |
4502 | 4992 | if (! $mysoc->localtax1_assuj || (string) $vatratecleaned == "0") return 0; |
4993 | + } |
|
4503 | 4994 | if ($thirdparty_seller->id == $mysoc->id) |
4504 | 4995 | { |
4505 | - if (! $thirdparty_buyer->localtax1_assuj) return 0; |
|
4506 | - } |
|
4507 | - else |
|
4996 | + if (! $thirdparty_buyer->localtax1_assuj) { |
|
4997 | + return 0; |
|
4998 | + } |
|
4999 | + } else |
|
4508 | 5000 | { |
4509 | - if (! $thirdparty_seller->localtax1_assuj) return 0; |
|
5001 | + if (! $thirdparty_seller->localtax1_assuj) { |
|
5002 | + return 0; |
|
5003 | + } |
|
4510 | 5004 | } |
4511 | 5005 | } |
4512 | 5006 | |
4513 | 5007 | if ($local == 2) |
4514 | 5008 | { |
4515 | - if (! $mysoc->localtax2_assuj || (string) $vatratecleaned == "0") return 0; |
|
5009 | + if (! $mysoc->localtax2_assuj || (string) $vatratecleaned == "0") { |
|
5010 | + return 0; |
|
5011 | + } |
|
4516 | 5012 | if ($thirdparty_seller->id == $mysoc->id) |
4517 | 5013 | { |
4518 | - if (! $thirdparty_buyer->localtax2_assuj) return 0; |
|
4519 | - } |
|
4520 | - else |
|
5014 | + if (! $thirdparty_buyer->localtax2_assuj) { |
|
5015 | + return 0; |
|
5016 | + } |
|
5017 | + } else |
|
4521 | 5018 | { |
4522 | - if (! $thirdparty_seller->localtax2_assuj) return 0; |
|
5019 | + if (! $thirdparty_seller->localtax2_assuj) { |
|
5020 | + return 0; |
|
5021 | + } |
|
4523 | 5022 | } |
4524 | 5023 | } |
4525 | - } |
|
4526 | - else |
|
5024 | + } else |
|
4527 | 5025 | { |
4528 | - if ($local == 1 && ! $thirdparty_seller->localtax1_assuj) return 0; |
|
4529 | - if ($local == 2 && ! $thirdparty_seller->localtax2_assuj) return 0; |
|
5026 | + if ($local == 1 && ! $thirdparty_seller->localtax1_assuj) { |
|
5027 | + return 0; |
|
5028 | + } |
|
5029 | + if ($local == 2 && ! $thirdparty_seller->localtax2_assuj) { |
|
5030 | + return 0; |
|
5031 | + } |
|
4530 | 5032 | } |
4531 | 5033 | |
4532 | 5034 | // For some country MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY is forced to on. |
@@ -4542,35 +5044,41 @@ discard block |
||
4542 | 5044 | { |
4543 | 5045 | if ($thirdparty_seller != $mysoc) |
4544 | 5046 | { |
4545 | - if (!isOnlyOneLocalTax($local)) // TODO We should provide $vatrate to search on correct line and not always on line with highest vat rate |
|
5047 | + if (!isOnlyOneLocalTax($local)) { |
|
5048 | + // TODO We should provide $vatrate to search on correct line and not always on line with highest vat rate |
|
4546 | 5049 | { |
4547 | 5050 | return $thirdparty_seller->localtax1_value; |
4548 | 5051 | } |
4549 | - } |
|
4550 | - else // i am the seller |
|
5052 | + } |
|
5053 | + } else // i am the seller |
|
4551 | 5054 | { |
4552 | - if (!isOnlyOneLocalTax($local)) // TODO If seller is me, why not always returning this, even if there is only one locatax vat. |
|
5055 | + if (!isOnlyOneLocalTax($local)) { |
|
5056 | + // TODO If seller is me, why not always returning this, even if there is only one locatax vat. |
|
4553 | 5057 | { |
4554 | 5058 | return $conf->global->MAIN_INFO_VALUE_LOCALTAX1; |
4555 | 5059 | } |
5060 | + } |
|
4556 | 5061 | } |
4557 | 5062 | } |
4558 | 5063 | if ($local==2) |
4559 | 5064 | { |
4560 | 5065 | if ($thirdparty_seller != $mysoc) |
4561 | 5066 | { |
4562 | - if (!isOnlyOneLocalTax($local)) // TODO We should provide $vatrate to search on correct line and not always on line with highest vat rate |
|
5067 | + if (!isOnlyOneLocalTax($local)) { |
|
5068 | + // TODO We should provide $vatrate to search on correct line and not always on line with highest vat rate |
|
4563 | 5069 | // TODO We should also return value defined on thirdparty only if defined |
4564 | 5070 | { |
4565 | 5071 | return $thirdparty_seller->localtax2_value; |
4566 | 5072 | } |
4567 | - } |
|
4568 | - else // i am the seller |
|
5073 | + } |
|
5074 | + } else // i am the seller |
|
4569 | 5075 | { |
4570 | - if (!isOnlyOneLocalTax($local)) // This is for spain only, we don't return value found into datbase even if there is only one locatax vat. |
|
5076 | + if (!isOnlyOneLocalTax($local)) { |
|
5077 | + // This is for spain only, we don't return value found into datbase even if there is only one locatax vat. |
|
4571 | 5078 | { |
4572 | 5079 | return $conf->global->MAIN_INFO_VALUE_LOCALTAX2; |
4573 | 5080 | } |
5081 | + } |
|
4574 | 5082 | } |
4575 | 5083 | } |
4576 | 5084 | } |
@@ -4580,16 +5088,24 @@ discard block |
||
4580 | 5088 | $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; |
4581 | 5089 | $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$thirdparty_seller->country_code."'"; |
4582 | 5090 | $sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; |
4583 | - if ($vatratecode) $sql.= " AND t.code ='".$vatratecode."'"; // If we have the code, we use it in priority |
|
4584 | - else $sql.= " AND t.recuperableonly ='".$vatnpr."'"; |
|
5091 | + if ($vatratecode) { |
|
5092 | + $sql.= " AND t.code ='".$vatratecode."'"; |
|
5093 | + } |
|
5094 | + // If we have the code, we use it in priority |
|
5095 | + else { |
|
5096 | + $sql.= " AND t.recuperableonly ='".$vatnpr."'"; |
|
5097 | + } |
|
4585 | 5098 | dol_syslog("get_localtax", LOG_DEBUG); |
4586 | 5099 | $resql=$db->query($sql); |
4587 | 5100 | |
4588 | 5101 | if ($resql) |
4589 | 5102 | { |
4590 | 5103 | $obj = $db->fetch_object($resql); |
4591 | - if ($local==1) return $obj->localtax1; |
|
4592 | - elseif ($local==2) return $obj->localtax2; |
|
5104 | + if ($local==1) { |
|
5105 | + return $obj->localtax1; |
|
5106 | + } elseif ($local==2) { |
|
5107 | + return $obj->localtax2; |
|
5108 | + } |
|
4593 | 5109 | } |
4594 | 5110 | |
4595 | 5111 | return 0; |
@@ -4613,8 +5129,7 @@ discard block |
||
4613 | 5129 | if (count($valors)>1) |
4614 | 5130 | { |
4615 | 5131 | return false; |
4616 | - } |
|
4617 | - else |
|
5132 | + } else |
|
4618 | 5133 | { |
4619 | 5134 | return true; |
4620 | 5135 | } |
@@ -4640,8 +5155,11 @@ discard block |
||
4640 | 5155 | if ($resql) |
4641 | 5156 | { |
4642 | 5157 | $obj = $db->fetch_object($resql); |
4643 | - if ($local==1) return $obj->localtax1; |
|
4644 | - elseif ($local==2) return $obj->localtax2; |
|
5158 | + if ($local==1) { |
|
5159 | + return $obj->localtax1; |
|
5160 | + } elseif ($local==2) { |
|
5161 | + return $obj->localtax2; |
|
5162 | + } |
|
4645 | 5163 | } |
4646 | 5164 | |
4647 | 5165 | return 0; |
@@ -4669,32 +5187,46 @@ discard block |
||
4669 | 5187 | // Search local taxes |
4670 | 5188 | $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy"; |
4671 | 5189 | $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t"; |
4672 | - if ($firstparamisid) $sql.= " WHERE t.rowid = ".(int) $vatrate; |
|
4673 | - else |
|
5190 | + if ($firstparamisid) { |
|
5191 | + $sql.= " WHERE t.rowid = ".(int) $vatrate; |
|
5192 | + } else |
|
4674 | 5193 | { |
4675 | 5194 | $vatratecleaned = $vatrate; |
4676 | 5195 | $vatratecode = ''; |
4677 | - if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)" |
|
5196 | + if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) { |
|
5197 | + // If vat is "xx (yy)" |
|
4678 | 5198 | { |
4679 | 5199 | $vatratecleaned = $reg[1]; |
5200 | + } |
|
4680 | 5201 | $vatratecode = $reg[2]; |
4681 | 5202 | } |
4682 | 5203 | |
4683 | 5204 | $sql.=", ".MAIN_DB_PREFIX."c_country as c"; |
4684 | - if ($mysoc->country_code == 'ES') $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'"; // local tax in spain use the buyer country ?? |
|
4685 | - else $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; |
|
5205 | + if ($mysoc->country_code == 'ES') { |
|
5206 | + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'"; |
|
5207 | + } |
|
5208 | + // local tax in spain use the buyer country ?? |
|
5209 | + else { |
|
5210 | + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; |
|
5211 | + } |
|
4686 | 5212 | $sql.= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; |
4687 | - if ($vatratecode) $sql.= " AND t.code = '".$vatratecode."'"; |
|
5213 | + if ($vatratecode) { |
|
5214 | + $sql.= " AND t.code = '".$vatratecode."'"; |
|
5215 | + } |
|
4688 | 5216 | } |
4689 | 5217 | |
4690 | 5218 | $resql=$db->query($sql); |
4691 | 5219 | if ($resql) |
4692 | 5220 | { |
4693 | 5221 | $obj = $db->fetch_object($resql); |
4694 | - if ($obj) return array('rowid'=>$obj->rowid, 'code'=>$obj->code, 'rate'=>$obj->rate, 'npr'=>$obj->npr, 'accountancy_code_sell'=>$obj->accountancy_code_sell, 'accountancy_code_buy'=>$obj->accountancy_code_buy); |
|
4695 | - else return array(); |
|
5222 | + if ($obj) { |
|
5223 | + return array('rowid'=>$obj->rowid, 'code'=>$obj->code, 'rate'=>$obj->rate, 'npr'=>$obj->npr, 'accountancy_code_sell'=>$obj->accountancy_code_sell, 'accountancy_code_buy'=>$obj->accountancy_code_buy); |
|
5224 | + } else { |
|
5225 | + return array(); |
|
5226 | + } |
|
5227 | + } else { |
|
5228 | + dol_print_error($db); |
|
4696 | 5229 | } |
4697 | - else dol_print_error($db); |
|
4698 | 5230 | |
4699 | 5231 | return array(); |
4700 | 5232 | } |
@@ -4724,22 +5256,32 @@ discard block |
||
4724 | 5256 | // Search local taxes |
4725 | 5257 | $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy"; |
4726 | 5258 | $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t"; |
4727 | - if ($firstparamisid) $sql.= " WHERE t.rowid = ".(int) $vatrate; |
|
4728 | - else |
|
5259 | + if ($firstparamisid) { |
|
5260 | + $sql.= " WHERE t.rowid = ".(int) $vatrate; |
|
5261 | + } else |
|
4729 | 5262 | { |
4730 | 5263 | $vatratecleaned = $vatrate; |
4731 | 5264 | $vatratecode = ''; |
4732 | - if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)" |
|
5265 | + if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) { |
|
5266 | + // If vat is "xx (yy)" |
|
4733 | 5267 | { |
4734 | 5268 | $vatratecleaned = $reg[1]; |
5269 | + } |
|
4735 | 5270 | $vatratecode = $reg[2]; |
4736 | 5271 | } |
4737 | 5272 | |
4738 | 5273 | $sql.=", ".MAIN_DB_PREFIX."c_country as c"; |
4739 | - if ($mysoc->country_code == 'ES') $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'"; // local tax in spain use the buyer country ?? |
|
4740 | - else $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; |
|
5274 | + if ($mysoc->country_code == 'ES') { |
|
5275 | + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'"; |
|
5276 | + } |
|
5277 | + // local tax in spain use the buyer country ?? |
|
5278 | + else { |
|
5279 | + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; |
|
5280 | + } |
|
4741 | 5281 | $sql.= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; |
4742 | - if ($vatratecode) $sql.= " AND t.code = '".$vatratecode."'"; |
|
5282 | + if ($vatratecode) { |
|
5283 | + $sql.= " AND t.code = '".$vatratecode."'"; |
|
5284 | + } |
|
4743 | 5285 | } |
4744 | 5286 | |
4745 | 5287 | $resql=$db->query($sql); |
@@ -4751,43 +5293,36 @@ discard block |
||
4751 | 5293 | if (! isOnlyOneLocalTax(1)) |
4752 | 5294 | { |
4753 | 5295 | return array($obj->localtax1_type, get_localtax($vatrate, $local, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); |
4754 | - } |
|
4755 | - else |
|
5296 | + } else |
|
4756 | 5297 | { |
4757 | 5298 | return array($obj->localtax1_type, $obj->localtax1,$obj->accountancy_code_sell, $obj->accountancy_code_buy); |
4758 | 5299 | } |
4759 | - } |
|
4760 | - elseif ($local == 2) |
|
5300 | + } elseif ($local == 2) |
|
4761 | 5301 | { |
4762 | 5302 | if (! isOnlyOneLocalTax(2)) |
4763 | 5303 | { |
4764 | 5304 | return array($obj->localtax2_type, get_localtax($vatrate, $local, $buyer, $seller),$obj->accountancy_code_sell, $obj->accountancy_code_buy); |
4765 | - } |
|
4766 | - else |
|
5305 | + } else |
|
4767 | 5306 | { |
4768 | 5307 | return array($obj->localtax2_type, $obj->localtax2,$obj->accountancy_code_sell, $obj->accountancy_code_buy); |
4769 | 5308 | } |
4770 | - } |
|
4771 | - else |
|
5309 | + } else |
|
4772 | 5310 | { |
4773 | 5311 | if(! isOnlyOneLocalTax(1)) |
4774 | 5312 | { |
4775 | 5313 | if(! isOnlyOneLocalTax(2)) |
4776 | 5314 | { |
4777 | 5315 | return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller), $obj->accountancy_code_sell,$obj->accountancy_code_buy); |
4778 | - } |
|
4779 | - else |
|
5316 | + } else |
|
4780 | 5317 | { |
4781 | 5318 | return array($obj->localtax1_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, $obj->localtax2, $obj->accountancy_code_sell, $obj->accountancy_code_buy); |
4782 | 5319 | } |
4783 | - } |
|
4784 | - else |
|
5320 | + } else |
|
4785 | 5321 | { |
4786 | 5322 | if(! isOnlyOneLocalTax(2)) |
4787 | 5323 | { |
4788 | 5324 | return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller), $obj->accountancy_code_sell, $obj->accountancy_code_buy); |
4789 | - } |
|
4790 | - else |
|
5325 | + } else |
|
4791 | 5326 | { |
4792 | 5327 | return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, $obj->localtax2, $obj->accountancy_code_sell, $obj->accountancy_code_buy); |
4793 | 5328 | } |
@@ -4823,22 +5358,26 @@ discard block |
||
4823 | 5358 | $product=new Product($db); |
4824 | 5359 | $result=$product->fetch($idprod); |
4825 | 5360 | |
4826 | - if ($mysoc->country_code == $thirdparty_seller->country_code) // If selling country is ours |
|
5361 | + if ($mysoc->country_code == $thirdparty_seller->country_code) { |
|
5362 | + // If selling country is ours |
|
4827 | 5363 | { |
4828 | 5364 | if ($idprodfournprice > 0) // We want vat for product for a "supplier" order or invoice |
4829 | 5365 | { |
4830 | 5366 | $product->get_buyprice($idprodfournprice,0,0,0); |
5367 | + } |
|
4831 | 5368 | $ret=$product->vatrate_supplier; |
4832 | - if ($product->default_vat_code) $ret.=' ('.$product->default_vat_code.')'; |
|
4833 | - } |
|
4834 | - else |
|
5369 | + if ($product->default_vat_code) { |
|
5370 | + $ret.=' ('.$product->default_vat_code.')'; |
|
5371 | + } |
|
5372 | + } else |
|
4835 | 5373 | { |
4836 | 5374 | $ret=$product->tva_tx; // Default vat of product we defined |
4837 | - if ($product->default_vat_code) $ret.=' ('.$product->default_vat_code.')'; |
|
5375 | + if ($product->default_vat_code) { |
|
5376 | + $ret.=' ('.$product->default_vat_code.')'; |
|
5377 | + } |
|
4838 | 5378 | } |
4839 | 5379 | $found=1; |
4840 | - } |
|
4841 | - else |
|
5380 | + } else |
|
4842 | 5381 | { |
4843 | 5382 | // TODO Read default product vat according to countrycode and product. Vat for couple countrycode/product is a feature not implemeted yet. |
4844 | 5383 | // May be usefull/required if hidden option SERVICE_ARE_ECOMMERCE_200238EC is on |
@@ -4865,10 +5404,13 @@ discard block |
||
4865 | 5404 | $ret=$obj->vat_rate; |
4866 | 5405 | } |
4867 | 5406 | $db->free($sql); |
5407 | + } else { |
|
5408 | + dol_print_error($db); |
|
4868 | 5409 | } |
4869 | - else dol_print_error($db); |
|
5410 | + } else { |
|
5411 | + $ret=$conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS; |
|
4870 | 5412 | } |
4871 | - else $ret=$conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS; // Forced value if autodetect fails |
|
5413 | + // Forced value if autodetect fails |
|
4872 | 5414 | } |
4873 | 5415 | |
4874 | 5416 | dol_syslog("get_product_vat_for_country: ret=".$ret); |
@@ -4901,7 +5443,8 @@ discard block |
||
4901 | 5443 | $product=new Product($db); |
4902 | 5444 | $result=$product->fetch($idprod); |
4903 | 5445 | |
4904 | - if ($mysoc->country_code == $thirdparty_seller->country_code) // If selling country is ours |
|
5446 | + if ($mysoc->country_code == $thirdparty_seller->country_code) { |
|
5447 | + // If selling country is ours |
|
4905 | 5448 | { |
4906 | 5449 | /* Not defined yet, so we don't use this |
4907 | 5450 | if ($local==1) $ret=$product->localtax1_tx; |
@@ -4921,6 +5464,7 @@ discard block |
||
4921 | 5464 | { |
4922 | 5465 | // If vat of product for the country not found or not defined, we return higher vat of country. |
4923 | 5466 | $sql = "SELECT taux as vat_rate, localtax1, localtax2"; |
5467 | + } |
|
4924 | 5468 | $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; |
4925 | 5469 | $sql.= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$thirdparty_seller->country_code."'"; |
4926 | 5470 | $sql.= " ORDER BY t.taux DESC, t.recuperableonly ASC"; |
@@ -4932,11 +5476,15 @@ discard block |
||
4932 | 5476 | $obj=$db->fetch_object($resql); |
4933 | 5477 | if ($obj) |
4934 | 5478 | { |
4935 | - if ($local==1) $ret=$obj->localtax1; |
|
4936 | - elseif ($local==2) $ret=$obj->localtax2; |
|
5479 | + if ($local==1) { |
|
5480 | + $ret=$obj->localtax1; |
|
5481 | + } elseif ($local==2) { |
|
5482 | + $ret=$obj->localtax2; |
|
5483 | + } |
|
4937 | 5484 | } |
5485 | + } else { |
|
5486 | + dol_print_error($db); |
|
4938 | 5487 | } |
4939 | - else dol_print_error($db); |
|
4940 | 5488 | } |
4941 | 5489 | |
4942 | 5490 | dol_syslog("get_product_localtax_for_country: ret=".$ret); |
@@ -4998,11 +5546,13 @@ discard block |
||
4998 | 5546 | |
4999 | 5547 | // Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle. |
5000 | 5548 | if (($seller_country_code == $buyer_country_code) |
5001 | - || (in_array($seller_country_code,array('FR,MC')) && in_array($buyer_country_code,array('FR','MC')))) // Warning ->country_code not always defined |
|
5549 | + || (in_array($seller_country_code,array('FR,MC')) && in_array($buyer_country_code,array('FR','MC')))) { |
|
5550 | + // Warning ->country_code not always defined |
|
5002 | 5551 | { |
5003 | 5552 | //print 'VATRULE 2'; |
5004 | 5553 | return get_product_vat_for_country($idprod,$thirdparty_seller,$idprodfournprice); |
5005 | 5554 | } |
5555 | + } |
|
5006 | 5556 | |
5007 | 5557 | // Si (vendeur et acheteur dans Communaute europeenne) et (bien vendu = moyen de transports neuf comme auto, bateau, avion) alors TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle. |
5008 | 5558 | // Not supported |
@@ -5016,8 +5566,7 @@ discard block |
||
5016 | 5566 | { |
5017 | 5567 | //print 'VATRULE 3'; |
5018 | 5568 | return 0; |
5019 | - } |
|
5020 | - else |
|
5569 | + } else |
|
5021 | 5570 | { |
5022 | 5571 | //print 'VATRULE 4'; |
5023 | 5572 | return get_product_vat_for_country($idprod,$thirdparty_seller,$idprodfournprice); |
@@ -5047,16 +5596,17 @@ discard block |
||
5047 | 5596 | |
5048 | 5597 | if ($idprodfournprice > 0) |
5049 | 5598 | { |
5050 | - if (! class_exists('ProductFournisseur')) |
|
5051 | - require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php'; |
|
5599 | + if (! class_exists('ProductFournisseur')) { |
|
5600 | + require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php'; |
|
5601 | + } |
|
5052 | 5602 | $prodprice = new ProductFournisseur($db); |
5053 | 5603 | $prodprice->fetch_product_fournisseur_price($idprodfournprice); |
5054 | 5604 | return $prodprice->fourn_tva_npr; |
5055 | - } |
|
5056 | - elseif ($idprod > 0) |
|
5605 | + } elseif ($idprod > 0) |
|
5057 | 5606 | { |
5058 | - if (! class_exists('Product')) |
|
5059 | - require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; |
|
5607 | + if (! class_exists('Product')) { |
|
5608 | + require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; |
|
5609 | + } |
|
5060 | 5610 | $prod = new Product($db); |
5061 | 5611 | $prod->fetch($idprod); |
5062 | 5612 | return $prod->tva_npr; |
@@ -5082,27 +5632,39 @@ discard block |
||
5082 | 5632 | { |
5083 | 5633 | global $mysoc; |
5084 | 5634 | |
5085 | - if (!is_object($thirdparty_seller)) return -1; |
|
5086 | - if (!is_object($thirdparty_buyer)) return -1; |
|
5635 | + if (!is_object($thirdparty_seller)) { |
|
5636 | + return -1; |
|
5637 | + } |
|
5638 | + if (!is_object($thirdparty_buyer)) { |
|
5639 | + return -1; |
|
5640 | + } |
|
5087 | 5641 | |
5088 | - if ($local==1) // Localtax 1 |
|
5642 | + if ($local==1) { |
|
5643 | + // Localtax 1 |
|
5089 | 5644 | { |
5090 | 5645 | if ($mysoc->country_code == 'ES') |
5091 | 5646 | { |
5092 | 5647 | if (is_numeric($thirdparty_buyer->localtax1_assuj) && ! $thirdparty_buyer->localtax1_assuj) return 0; |
5093 | - } |
|
5094 | - else |
|
5648 | + } |
|
5649 | + } else |
|
5095 | 5650 | { |
5096 | 5651 | // Si vendeur non assujeti a Localtax1, localtax1 par default=0 |
5097 | - if (is_numeric($thirdparty_seller->localtax1_assuj) && ! $thirdparty_seller->localtax1_assuj) return 0; |
|
5098 | - if (! is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj=='localtax1off') return 0; |
|
5652 | + if (is_numeric($thirdparty_seller->localtax1_assuj) && ! $thirdparty_seller->localtax1_assuj) { |
|
5653 | + return 0; |
|
5654 | + } |
|
5655 | + if (! is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj=='localtax1off') { |
|
5656 | + return 0; |
|
5657 | + } |
|
5099 | 5658 | } |
5100 | - } |
|
5101 | - elseif ($local==2) //I Localtax 2 |
|
5659 | + } elseif ($local==2) { |
|
5660 | + //I Localtax 2 |
|
5102 | 5661 | { |
5103 | 5662 | // Si vendeur non assujeti a Localtax2, localtax2 par default=0 |
5104 | 5663 | if (is_numeric($thirdparty_seller->localtax2_assuj) && ! $thirdparty_seller->localtax2_assuj) return 0; |
5105 | - if (! is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj=='localtax2off') return 0; |
|
5664 | + } |
|
5665 | + if (! is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj=='localtax2off') { |
|
5666 | + return 0; |
|
5667 | + } |
|
5106 | 5668 | } |
5107 | 5669 | |
5108 | 5670 | if ($thirdparty_seller->country_code == $thirdparty_buyer->country_code) |
@@ -5125,26 +5687,44 @@ discard block |
||
5125 | 5687 | { |
5126 | 5688 | global $langs; |
5127 | 5689 | $result='unknown'; $classname=''; |
5128 | - if ($yesno == 1 || strtolower($yesno) == 'yes' || strtolower($yesno) == 'true') // A mettre avant test sur no a cause du == 0 |
|
5690 | + if ($yesno == 1 || strtolower($yesno) == 'yes' || strtolower($yesno) == 'true') { |
|
5691 | + // A mettre avant test sur no a cause du == 0 |
|
5129 | 5692 | { |
5130 | 5693 | $result=$langs->trans('yes'); |
5131 | - if ($case == 1 || $case == 3) $result=$langs->trans("Yes"); |
|
5132 | - if ($case == 2) $result='<input type="checkbox" value="1" checked disabled>'; |
|
5133 | - if ($case == 3) $result='<input type="checkbox" value="1" checked disabled> '.$result; |
|
5694 | + } |
|
5695 | + if ($case == 1 || $case == 3) { |
|
5696 | + $result=$langs->trans("Yes"); |
|
5697 | + } |
|
5698 | + if ($case == 2) { |
|
5699 | + $result='<input type="checkbox" value="1" checked disabled>'; |
|
5700 | + } |
|
5701 | + if ($case == 3) { |
|
5702 | + $result='<input type="checkbox" value="1" checked disabled> '.$result; |
|
5703 | + } |
|
5134 | 5704 | |
5135 | 5705 | $classname='ok'; |
5136 | - } |
|
5137 | - elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') |
|
5706 | + } elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') |
|
5138 | 5707 | { |
5139 | 5708 | $result=$langs->trans("no"); |
5140 | - if ($case == 1 || $case == 3) $result=$langs->trans("No"); |
|
5141 | - if ($case == 2) $result='<input type="checkbox" value="0" disabled>'; |
|
5142 | - if ($case == 3) $result='<input type="checkbox" value="0" disabled> '.$result; |
|
5709 | + if ($case == 1 || $case == 3) { |
|
5710 | + $result=$langs->trans("No"); |
|
5711 | + } |
|
5712 | + if ($case == 2) { |
|
5713 | + $result='<input type="checkbox" value="0" disabled>'; |
|
5714 | + } |
|
5715 | + if ($case == 3) { |
|
5716 | + $result='<input type="checkbox" value="0" disabled> '.$result; |
|
5717 | + } |
|
5143 | 5718 | |
5144 | - if ($color == 2) $classname='ok'; |
|
5145 | - else $classname='error'; |
|
5719 | + if ($color == 2) { |
|
5720 | + $classname='ok'; |
|
5721 | + } else { |
|
5722 | + $classname='error'; |
|
5723 | + } |
|
5724 | + } |
|
5725 | + if ($color) { |
|
5726 | + return '<font class="'.$classname.'">'.$result.'</font>'; |
|
5146 | 5727 | } |
5147 | - if ($color) return '<font class="'.$classname.'">'.$result.'</font>'; |
|
5148 | 5728 | return $result; |
5149 | 5729 | } |
5150 | 5730 | |
@@ -5171,18 +5751,28 @@ discard block |
||
5171 | 5751 | $path = ''; |
5172 | 5752 | |
5173 | 5753 | $arrayforoldpath=array('cheque','user','category','holiday','supplier_invoice','invoice_supplier','mailing','supplier_payment'); |
5174 | - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $arrayforoldpath[]='product'; |
|
5754 | + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { |
|
5755 | + $arrayforoldpath[]='product'; |
|
5756 | + } |
|
5175 | 5757 | if (! empty($level) && in_array($modulepart, $arrayforoldpath)) |
5176 | 5758 | { |
5177 | 5759 | // This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided. |
5178 | - if (empty($alpha)) $num = preg_replace('/([^0-9])/i','',$num); |
|
5179 | - else $num = preg_replace('/^.*\-/i','',$num); |
|
5760 | + if (empty($alpha)) { |
|
5761 | + $num = preg_replace('/([^0-9])/i','',$num); |
|
5762 | + } else { |
|
5763 | + $num = preg_replace('/^.*\-/i','',$num); |
|
5764 | + } |
|
5180 | 5765 | $num = substr("000".$num, -$level); |
5181 | - if ($level == 1) $path = substr($num,0,1); |
|
5182 | - if ($level == 2) $path = substr($num,1,1).'/'.substr($num,0,1); |
|
5183 | - if ($level == 3) $path = substr($num,2,1).'/'.substr($num,1,1).'/'.substr($num,0,1); |
|
5184 | - } |
|
5185 | - else |
|
5766 | + if ($level == 1) { |
|
5767 | + $path = substr($num,0,1); |
|
5768 | + } |
|
5769 | + if ($level == 2) { |
|
5770 | + $path = substr($num,1,1).'/'.substr($num,0,1); |
|
5771 | + } |
|
5772 | + if ($level == 3) { |
|
5773 | + $path = substr($num,2,1).'/'.substr($num,1,1).'/'.substr($num,0,1); |
|
5774 | + } |
|
5775 | + } else |
|
5186 | 5776 | { |
5187 | 5777 | // TODO |
5188 | 5778 | // We will enhance here a common way of forging path for document storage |
@@ -5193,7 +5783,9 @@ discard block |
||
5193 | 5783 | } |
5194 | 5784 | } |
5195 | 5785 | |
5196 | - if (empty($withoutslash) && ! empty($path)) $path.='/'; |
|
5786 | + if (empty($withoutslash) && ! empty($path)) { |
|
5787 | + $path.='/'; |
|
5788 | + } |
|
5197 | 5789 | |
5198 | 5790 | return $path; |
5199 | 5791 | } |
@@ -5213,7 +5805,9 @@ discard block |
||
5213 | 5805 | dol_syslog("functions.lib::dol_mkdir: dir=".$dir,LOG_INFO); |
5214 | 5806 | |
5215 | 5807 | $dir_osencoded=dol_osencode($dir); |
5216 | - if (@is_dir($dir_osencoded)) return 0; |
|
5808 | + if (@is_dir($dir_osencoded)) { |
|
5809 | + return 0; |
|
5810 | + } |
|
5217 | 5811 | |
5218 | 5812 | $nberr=0; |
5219 | 5813 | $nbcreated=0; |
@@ -5229,9 +5823,15 @@ discard block |
||
5229 | 5823 | $num=count($cdir); |
5230 | 5824 | for ($i = 0; $i < $num; $i++) |
5231 | 5825 | { |
5232 | - if ($i > 0) $ccdir .= '/'.$cdir[$i]; |
|
5233 | - else $ccdir .= $cdir[$i]; |
|
5234 | - if (preg_match("/^.:$/",$ccdir,$regs)) continue; // Si chemin Windows incomplet, on poursuit par rep suivant |
|
5826 | + if ($i > 0) { |
|
5827 | + $ccdir .= '/'.$cdir[$i]; |
|
5828 | + } else { |
|
5829 | + $ccdir .= $cdir[$i]; |
|
5830 | + } |
|
5831 | + if (preg_match("/^.:$/",$ccdir,$regs)) { |
|
5832 | + continue; |
|
5833 | + } |
|
5834 | + // Si chemin Windows incomplet, on poursuit par rep suivant |
|
5235 | 5835 | |
5236 | 5836 | // Attention, le is_dir() peut echouer bien que le rep existe. |
5237 | 5837 | // (ex selon config de open_basedir) |
@@ -5253,15 +5853,13 @@ discard block |
||
5253 | 5853 | // Si le is_dir a renvoye une fausse info, alors on passe ici. |
5254 | 5854 | dol_syslog("functions.lib::dol_mkdir: Fails to create directory '".$ccdir."' or directory already exists.",LOG_WARNING); |
5255 | 5855 | $nberr++; |
5256 | - } |
|
5257 | - else |
|
5856 | + } else |
|
5258 | 5857 | { |
5259 | 5858 | dol_syslog("functions.lib::dol_mkdir: Directory '".$ccdir."' created",LOG_DEBUG); |
5260 | 5859 | $nberr=0; // On remet a zero car si on arrive ici, cela veut dire que les echecs precedents peuvent etre ignore |
5261 | 5860 | $nbcreated++; |
5262 | 5861 | } |
5263 | - } |
|
5264 | - else |
|
5862 | + } else |
|
5265 | 5863 | { |
5266 | 5864 | $nberr=0; // On remet a zero car si on arrive ici, cela veut dire que les echecs precedents peuvent etre ignores |
5267 | 5865 | } |
@@ -5310,7 +5908,9 @@ discard block |
||
5310 | 5908 | // $temp after pass 2: 0000-021 |
5311 | 5909 | |
5312 | 5910 | // Supprime aussi les retours |
5313 | - if ($removelinefeed) $temp=str_replace(array("\r\n","\r","\n")," ",$temp); |
|
5911 | + if ($removelinefeed) { |
|
5912 | + $temp=str_replace(array("\r\n","\r","\n")," ",$temp); |
|
5913 | + } |
|
5314 | 5914 | |
5315 | 5915 | // et les espaces doubles |
5316 | 5916 | while(strpos($temp," ")) |
@@ -5339,14 +5939,12 @@ discard block |
||
5339 | 5939 | $firstline=preg_replace('/<br[^>]*>.*$/s','',$text); // The s pattern modifier means the . can match newline characters |
5340 | 5940 | $firstline=preg_replace('/<div[^>]*>.*$/s','',$firstline); // The s pattern modifier means the . can match newline characters |
5341 | 5941 | |
5342 | - } |
|
5343 | - else |
|
5942 | + } else |
|
5344 | 5943 | { |
5345 | 5944 | $firstline=preg_replace('/[\n\r].*/','',$text); |
5346 | 5945 | } |
5347 | 5946 | return $firstline.((strlen($firstline) != strlen($text))?'...':''); |
5348 | - } |
|
5349 | - else |
|
5947 | + } else |
|
5350 | 5948 | { |
5351 | 5949 | $ishtml=0; |
5352 | 5950 | if (dol_textishtml($text)) |
@@ -5354,15 +5952,17 @@ discard block |
||
5354 | 5952 | $text=preg_replace('/\n/','',$text); |
5355 | 5953 | $ishtml=1; |
5356 | 5954 | $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " "); |
5357 | - } |
|
5358 | - else |
|
5955 | + } else |
|
5359 | 5956 | { |
5360 | 5957 | $repTable = array("\t" => " ", "\n" => "<br>", "\r" => " ", "\0" => " ", "\x0B" => " "); |
5361 | 5958 | } |
5362 | 5959 | |
5363 | 5960 | $text = strtr($text, $repTable); |
5364 | 5961 | if ($charset == 'UTF-8') { $pattern = '/(<br[^>]*>)/Uu'; } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support |
5365 | - else $pattern = '/(<br[^>]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. |
|
5962 | + else { |
|
5963 | + $pattern = '/(<br[^>]*>)/U'; |
|
5964 | + } |
|
5965 | + // /U is to have UNGREEDY regex to limit to one html tag. |
|
5366 | 5966 | $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
5367 | 5967 | |
5368 | 5968 | $firstline=''; |
@@ -5370,8 +5970,11 @@ discard block |
||
5370 | 5970 | $nba = count($a); // 2x nb of lines in $a because $a contains also a line for each new line separator |
5371 | 5971 | while (($i < $nba) && ($i < ($nboflines * 2))) |
5372 | 5972 | { |
5373 | - if ($i % 2 == 0) $firstline .= $a[$i]; |
|
5374 | - elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) $firstline .= ($ishtml?"<br>\n":"\n"); |
|
5973 | + if ($i % 2 == 0) { |
|
5974 | + $firstline .= $a[$i]; |
|
5975 | + } elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) { |
|
5976 | + $firstline .= ($ishtml?"<br>\n":"\n"); |
|
5977 | + } |
|
5375 | 5978 | $i++; |
5376 | 5979 | } |
5377 | 5980 | unset($a); |
@@ -5420,17 +6023,25 @@ discard block |
||
5420 | 6023 | function dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1) |
5421 | 6024 | { |
5422 | 6025 | $newstring=$stringtoencode; |
5423 | - if (dol_textishtml($stringtoencode)) // Check if text is already HTML or not |
|
6026 | + if (dol_textishtml($stringtoencode)) { |
|
6027 | + // Check if text is already HTML or not |
|
5424 | 6028 | { |
5425 | - $newstring=preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i','<br>',$newstring); // Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF. |
|
5426 | - if ($removelasteolbr) $newstring=preg_replace('/<br>$/i','',$newstring); // Remove last <br> (remove only last one) |
|
6029 | + $newstring=preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i','<br>',$newstring); |
|
6030 | + } |
|
6031 | + // Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF. |
|
6032 | + if ($removelasteolbr) { |
|
6033 | + $newstring=preg_replace('/<br>$/i','',$newstring); |
|
6034 | + } |
|
6035 | + // Remove last <br> (remove only last one) |
|
5427 | 6036 | $newstring=strtr($newstring,array('&'=>'__and__','<'=>'__lt__','>'=>'__gt__','"'=>'__dquot__')); |
5428 | 6037 | $newstring=dol_htmlentities($newstring,ENT_COMPAT,$pagecodefrom); // Make entity encoding |
5429 | 6038 | $newstring=strtr($newstring,array('__and__'=>'&','__lt__'=>'<','__gt__'=>'>','__dquot__'=>'"')); |
5430 | - } |
|
5431 | - else |
|
6039 | + } else |
|
5432 | 6040 | { |
5433 | - if ($removelasteolbr) $newstring=preg_replace('/(\r\n|\r|\n)$/i','',$newstring); // Remove last \n (may remove several) |
|
6041 | + if ($removelasteolbr) { |
|
6042 | + $newstring=preg_replace('/(\r\n|\r|\n)$/i','',$newstring); |
|
6043 | + } |
|
6044 | + // Remove last \n (may remove several) |
|
5434 | 6045 | $newstring=dol_nl2br(dol_htmlentities($newstring,ENT_COMPAT,$pagecodefrom),$nl2brmode); |
5435 | 6046 | } |
5436 | 6047 | // Other substitutions that htmlentities does not do |
@@ -5528,7 +6139,9 @@ discard block |
||
5528 | 6139 | */ |
5529 | 6140 | function dol_nboflines($s,$maxchar=0) |
5530 | 6141 | { |
5531 | - if ($s == '') return 0; |
|
6142 | + if ($s == '') { |
|
6143 | + return 0; |
|
6144 | + } |
|
5532 | 6145 | $arraystring=explode("\n",$s); |
5533 | 6146 | $nb=count($arraystring); |
5534 | 6147 | |
@@ -5548,11 +6161,16 @@ discard block |
||
5548 | 6161 | function dol_nboflines_bis($text,$maxlinesize=0,$charset='UTF-8') |
5549 | 6162 | { |
5550 | 6163 | $repTable = array("\t" => " ", "\n" => "<br>", "\r" => " ", "\0" => " ", "\x0B" => " "); |
5551 | - if (dol_textishtml($text)) $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " "); |
|
6164 | + if (dol_textishtml($text)) { |
|
6165 | + $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " "); |
|
6166 | + } |
|
5552 | 6167 | |
5553 | 6168 | $text = strtr($text, $repTable); |
5554 | 6169 | if ($charset == 'UTF-8') { $pattern = '/(<br[^>]*>)/Uu'; } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support |
5555 | - else $pattern = '/(<br[^>]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. |
|
6170 | + else { |
|
6171 | + $pattern = '/(<br[^>]*>)/U'; |
|
6172 | + } |
|
6173 | + // /U is to have UNGREEDY regex to limit to one html tag. |
|
5556 | 6174 | $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
5557 | 6175 | |
5558 | 6176 | $nblines = (int) floor((count($a)+1)/2); |
@@ -5604,24 +6222,46 @@ discard block |
||
5604 | 6222 | { |
5605 | 6223 | if ($option == 1) |
5606 | 6224 | { |
5607 | - if (preg_match('/<html/i',$msg)) return true; |
|
5608 | - elseif (preg_match('/<body/i',$msg)) return true; |
|
5609 | - elseif (preg_match('/<br/i',$msg)) return true; |
|
6225 | + if (preg_match('/<html/i',$msg)) { |
|
6226 | + return true; |
|
6227 | + } elseif (preg_match('/<body/i',$msg)) { |
|
6228 | + return true; |
|
6229 | + } elseif (preg_match('/<br/i',$msg)) { |
|
6230 | + return true; |
|
6231 | + } |
|
5610 | 6232 | return false; |
5611 | - } |
|
5612 | - else |
|
5613 | - { |
|
5614 | - if (preg_match('/<html/i',$msg)) return true; |
|
5615 | - elseif (preg_match('/<body/i',$msg)) return true; |
|
5616 | - elseif (preg_match('/<(b|em|i|u)>/i',$msg)) return true; |
|
5617 | - elseif (preg_match('/<(br|div|font|li|p|span|strong|table)>/i',$msg)) return true; |
|
5618 | - elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*>/i',$msg)) return true; |
|
5619 | - elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/>/i',$msg)) return true; |
|
5620 | - elseif (preg_match('/<img\s+[^<>]*src[^<>]*>/i',$msg)) return true; // must accept <img src="http://example.com/aaa.png" /> |
|
5621 | - elseif (preg_match('/<a\s+[^<>]*href[^<>]*>/i',$msg)) return true; // must accept <a href="http://example.com/aaa.png" /> |
|
5622 | - elseif (preg_match('/<h[0-9]>/i',$msg)) return true; |
|
5623 | - elseif (preg_match('/&[A-Z0-9]{1,6};/i',$msg)) return true; // Html entities names (http://www.w3schools.com/tags/ref_entities.asp) |
|
5624 | - elseif (preg_match('/&#[0-9]{2,3};/i',$msg)) return true; // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp) |
|
6233 | + } else |
|
6234 | + { |
|
6235 | + if (preg_match('/<html/i',$msg)) { |
|
6236 | + return true; |
|
6237 | + } elseif (preg_match('/<body/i',$msg)) { |
|
6238 | + return true; |
|
6239 | + } elseif (preg_match('/<(b|em|i|u)>/i',$msg)) { |
|
6240 | + return true; |
|
6241 | + } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)>/i',$msg)) { |
|
6242 | + return true; |
|
6243 | + } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*>/i',$msg)) { |
|
6244 | + return true; |
|
6245 | + } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/>/i',$msg)) { |
|
6246 | + return true; |
|
6247 | + } elseif (preg_match('/<img\s+[^<>]*src[^<>]*>/i',$msg)) { |
|
6248 | + return true; |
|
6249 | + } |
|
6250 | + // must accept <img src="http://example.com/aaa.png" /> |
|
6251 | + elseif (preg_match('/<a\s+[^<>]*href[^<>]*>/i',$msg)) { |
|
6252 | + return true; |
|
6253 | + } |
|
6254 | + // must accept <a href="http://example.com/aaa.png" /> |
|
6255 | + elseif (preg_match('/<h[0-9]>/i',$msg)) { |
|
6256 | + return true; |
|
6257 | + } elseif (preg_match('/&[A-Z0-9]{1,6};/i',$msg)) { |
|
6258 | + return true; |
|
6259 | + } |
|
6260 | + // Html entities names (http://www.w3schools.com/tags/ref_entities.asp) |
|
6261 | + elseif (preg_match('/&#[0-9]{2,3};/i',$msg)) { |
|
6262 | + return true; |
|
6263 | + } |
|
6264 | + // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp) |
|
5625 | 6265 | return false; |
5626 | 6266 | } |
5627 | 6267 | } |
@@ -5732,8 +6372,7 @@ discard block |
||
5732 | 6372 | $substitutionarray['__SHIPPINGTRACKNUM__']='Shipping tacking number'; |
5733 | 6373 | $substitutionarray['__SHIPPINGTRACKNUMURL__']='Shipping tracking url'; |
5734 | 6374 | } |
5735 | - } |
|
5736 | - else |
|
6375 | + } else |
|
5737 | 6376 | { |
5738 | 6377 | $substitutionarray['__ID__'] = $object->id; |
5739 | 6378 | $substitutionarray['__REF__'] = $object->ref; |
@@ -5745,10 +6384,14 @@ discard block |
||
5745 | 6384 | |
5746 | 6385 | $birthday = dol_print_date($object->birth,'day'); |
5747 | 6386 | |
5748 | - if (method_exists($object, 'getCivilityLabel')) $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel(); |
|
6387 | + if (method_exists($object, 'getCivilityLabel')) { |
|
6388 | + $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel(); |
|
6389 | + } |
|
5749 | 6390 | $substitutionarray['__MEMBER_FIRSTNAME__']=$msgishtml?dol_htmlentitiesbr($object->firstname):$object->firstname; |
5750 | 6391 | $substitutionarray['__MEMBER_LASTNAME__']=$msgishtml?dol_htmlentitiesbr($object->lastname):$object->lastname; |
5751 | - if (method_exists($object, 'getFullName')) $substitutionarray['__MEMBER_FULLNAME__']=$msgishtml?dol_htmlentitiesbr($object->getFullName($outputlangs)):$object->getFullName($outputlangs); |
|
6392 | + if (method_exists($object, 'getFullName')) { |
|
6393 | + $substitutionarray['__MEMBER_FULLNAME__']=$msgishtml?dol_htmlentitiesbr($object->getFullName($outputlangs)):$object->getFullName($outputlangs); |
|
6394 | + } |
|
5752 | 6395 | $substitutionarray['__MEMBER_COMPANY__']=$msgishtml?dol_htmlentitiesbr($object->societe):$object->societe; |
5753 | 6396 | $substitutionarray['__MEMBER_ADDRESS__']=$msgishtml?dol_htmlentitiesbr($object->address):$object->address; |
5754 | 6397 | $substitutionarray['__MEMBER_ZIP__']=$msgishtml?dol_htmlentitiesbr($object->zip):$object->zip; |
@@ -5769,8 +6412,7 @@ discard block |
||
5769 | 6412 | $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object)?$object->name:''); |
5770 | 6413 | $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object)?$object->name_alias:''); |
5771 | 6414 | $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object)?$object->email:''); |
5772 | - } |
|
5773 | - elseif (is_object($object->thirdparty) && $object->thirdparty->id > 0) |
|
6415 | + } elseif (is_object($object->thirdparty) && $object->thirdparty->id > 0) |
|
5774 | 6416 | { |
5775 | 6417 | $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:''); |
5776 | 6418 | $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:''); |
@@ -5797,8 +6439,12 @@ discard block |
||
5797 | 6439 | $datenextexpiration=''; |
5798 | 6440 | foreach($object->lines as $line) |
5799 | 6441 | { |
5800 | - if ($line->date_ouverture_prevue > $dateplannedstart) $dateplannedstart = $line->date_ouverture_prevue; |
|
5801 | - if ($line->statut == 4 && $line->date_fin_prevue && (! $datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) $datenextexpiration = $line->date_fin_prevue; |
|
6442 | + if ($line->date_ouverture_prevue > $dateplannedstart) { |
|
6443 | + $dateplannedstart = $line->date_ouverture_prevue; |
|
6444 | + } |
|
6445 | + if ($line->statut == 4 && $line->date_fin_prevue && (! $datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) { |
|
6446 | + $datenextexpiration = $line->date_fin_prevue; |
|
6447 | + } |
|
5802 | 6448 | } |
5803 | 6449 | $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = dol_print_date($dateplannedstart, 'dayrfc'); |
5804 | 6450 | $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = dol_print_date($dateplannedstart, 'standard'); |
@@ -5827,8 +6473,12 @@ discard block |
||
5827 | 6473 | $substitutionarray['__AMOUNT__'] = is_object($object)?$object->total_ttc:''; |
5828 | 6474 | $substitutionarray['__AMOUNT_EXCL_TAX__'] = is_object($object)?$object->total_ht:''; |
5829 | 6475 | $substitutionarray['__AMOUNT_VAT__'] = is_object($object)?($object->total_vat?$object->total_vat:$object->total_tva):''; |
5830 | - if ($onlykey != 2 || $mysoc->useLocalTax(1)) $substitutionarray['__AMOUNT_TAX2__'] = is_object($object)?($object->total_localtax1?$object->total_localtax1:$object->total_localtax1):''; |
|
5831 | - if ($onlykey != 2 || $mysoc->useLocalTax(2)) $substitutionarray['__AMOUNT_TAX3__'] = is_object($object)?($object->total_localtax2?$object->total_localtax2:$object->total_localtax2):''; |
|
6476 | + if ($onlykey != 2 || $mysoc->useLocalTax(1)) { |
|
6477 | + $substitutionarray['__AMOUNT_TAX2__'] = is_object($object)?($object->total_localtax1?$object->total_localtax1:$object->total_localtax1):''; |
|
6478 | + } |
|
6479 | + if ($onlykey != 2 || $mysoc->useLocalTax(2)) { |
|
6480 | + $substitutionarray['__AMOUNT_TAX3__'] = is_object($object)?($object->total_localtax2?$object->total_localtax2:$object->total_localtax2):''; |
|
6481 | + } |
|
5832 | 6482 | |
5833 | 6483 | /* TODO Add key for multicurrency |
5834 | 6484 | $substitutionarray['__AMOUNT_FORMATED__'] = is_object($object)?price($object->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency_code):''; |
@@ -5919,9 +6569,13 @@ discard block |
||
5919 | 6569 | { |
5920 | 6570 | global $conf, $langs; |
5921 | 6571 | |
5922 | - if (! is_array($substitutionarray)) return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions'; |
|
6572 | + if (! is_array($substitutionarray)) { |
|
6573 | + return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions'; |
|
6574 | + } |
|
5923 | 6575 | |
5924 | - if (empty($outputlangs)) $outputlangs=$langs; |
|
6576 | + if (empty($outputlangs)) { |
|
6577 | + $outputlangs=$langs; |
|
6578 | + } |
|
5925 | 6579 | |
5926 | 6580 | // Make substitution for language keys |
5927 | 6581 | if (is_object($outputlangs)) |
@@ -5929,11 +6583,15 @@ discard block |
||
5929 | 6583 | while (preg_match('/__\(([^\)]+)\)__/', $text, $reg)) |
5930 | 6584 | { |
5931 | 6585 | $msgishtml = 0; |
5932 | - if (dol_textishtml($text,1)) $msgishtml = 1; |
|
6586 | + if (dol_textishtml($text,1)) { |
|
6587 | + $msgishtml = 1; |
|
6588 | + } |
|
5933 | 6589 | |
5934 | 6590 | // If key is __(TranslationKey|langfile)__, then force load of langfile.lang |
5935 | 6591 | $tmp=explode('|',$reg[1]); |
5936 | - if (! empty($tmp[1])) $outputlangs->load($tmp[1]); |
|
6592 | + if (! empty($tmp[1])) { |
|
6593 | + $outputlangs->load($tmp[1]); |
|
6594 | + } |
|
5937 | 6595 | |
5938 | 6596 | $text = preg_replace('/__\('.preg_quote($reg[1], '/').'\)__/', $msgishtml?dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])):$outputlangs->transnoentitiesnoconv($reg[1]), $text); |
5939 | 6597 | } |
@@ -5944,19 +6602,30 @@ discard block |
||
5944 | 6602 | while (preg_match('/__\[([^\]]+)\]__/', $text, $reg)) |
5945 | 6603 | { |
5946 | 6604 | $msgishtml = 0; |
5947 | - if (dol_textishtml($text,1)) $msgishtml = 1; |
|
6605 | + if (dol_textishtml($text,1)) { |
|
6606 | + $msgishtml = 1; |
|
6607 | + } |
|
5948 | 6608 | |
5949 | 6609 | $keyfound = $reg[1]; |
5950 | - if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) $newval = '*****forbidden*****'; |
|
5951 | - else $newval=empty($conf->global->$keyfound)?'':$conf->global->$keyfound; |
|
6610 | + if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) { |
|
6611 | + $newval = '*****forbidden*****'; |
|
6612 | + } else { |
|
6613 | + $newval=empty($conf->global->$keyfound)?'':$conf->global->$keyfound; |
|
6614 | + } |
|
5952 | 6615 | $text = preg_replace('/__\['.preg_quote($keyfound, '/').'\]__/', $msgishtml?dol_htmlentitiesbr($newval):$newval, $text); |
5953 | 6616 | } |
5954 | 6617 | |
5955 | 6618 | // Make substitition for array $substitutionarray |
5956 | 6619 | foreach ($substitutionarray as $key => $value) |
5957 | 6620 | { |
5958 | - if ($key == '__SIGNATURE__' && (! empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) $value=''; // Protection |
|
5959 | - if ($key == '__USER_SIGNATURE__' && (! empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) $value=''; // Protection |
|
6621 | + if ($key == '__SIGNATURE__' && (! empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) { |
|
6622 | + $value=''; |
|
6623 | + } |
|
6624 | + // Protection |
|
6625 | + if ($key == '__USER_SIGNATURE__' && (! empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) { |
|
6626 | + $value=''; |
|
6627 | + } |
|
6628 | + // Protection |
|
5960 | 6629 | |
5961 | 6630 | $text=str_replace("$key","$value",$text); // We must keep the " to work when value is 123.5 for example |
5962 | 6631 | } |
@@ -6003,7 +6672,9 @@ discard block |
||
6003 | 6672 | $dir=dol_buildpath($reldir,0); |
6004 | 6673 | |
6005 | 6674 | // Check if directory exists |
6006 | - if (! dol_is_dir($dir)) continue; |
|
6675 | + if (! dol_is_dir($dir)) { |
|
6676 | + continue; |
|
6677 | + } |
|
6007 | 6678 | |
6008 | 6679 | $substitfiles=dol_dir_list($dir,'files',0,'functions_'); |
6009 | 6680 | foreach($substitfiles as $substitfile) |
@@ -6017,7 +6688,9 @@ discard block |
||
6017 | 6688 | require_once $dir.$substitfile['name']; |
6018 | 6689 | // Call the user's function, and only if it is defined |
6019 | 6690 | $function_name=$module."_".$callfunc; |
6020 | - if (function_exists($function_name)) $function_name($substitutionarray,$outputlangs,$object,$parameters); |
|
6691 | + if (function_exists($function_name)) { |
|
6692 | + $function_name($substitutionarray,$outputlangs,$object,$parameters); |
|
6693 | + } |
|
6021 | 6694 | } |
6022 | 6695 | } |
6023 | 6696 | } |
@@ -6053,7 +6726,9 @@ discard block |
||
6053 | 6726 | |
6054 | 6727 | $out=''; |
6055 | 6728 | |
6056 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
6729 | + if (! is_object($outputlangs)) { |
|
6730 | + $outputlangs=$langs; |
|
6731 | + } |
|
6057 | 6732 | |
6058 | 6733 | if ($date_start && $date_end) |
6059 | 6734 | { |
@@ -6085,21 +6760,25 @@ discard block |
||
6085 | 6760 | |
6086 | 6761 | $ret=''; |
6087 | 6762 | // If order not defined, we use the setup |
6088 | - if ($nameorder < 0) $nameorder=(empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)); |
|
6763 | + if ($nameorder < 0) { |
|
6764 | + $nameorder=(empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)); |
|
6765 | + } |
|
6089 | 6766 | if ($nameorder && ((string) $nameorder != '2')) |
6090 | 6767 | { |
6091 | 6768 | $ret.=$firstname; |
6092 | - if ($firstname && $lastname) $ret.=' '; |
|
6769 | + if ($firstname && $lastname) { |
|
6770 | + $ret.=' '; |
|
6771 | + } |
|
6093 | 6772 | $ret.=$lastname; |
6094 | - } |
|
6095 | - else if ($nameorder == 2) |
|
6773 | + } else if ($nameorder == 2) |
|
6096 | 6774 | { |
6097 | 6775 | $ret.=$firstname; |
6098 | - } |
|
6099 | - else |
|
6776 | + } else |
|
6100 | 6777 | { |
6101 | 6778 | $ret.=$lastname; |
6102 | - if ($firstname && $lastname) $ret.=' '; |
|
6779 | + if ($firstname && $lastname) { |
|
6780 | + $ret.=' '; |
|
6781 | + } |
|
6103 | 6782 | $ret.=$firstname; |
6104 | 6783 | } |
6105 | 6784 | return $ret; |
@@ -6119,15 +6798,18 @@ discard block |
||
6119 | 6798 | function setEventMessage($mesgs, $style='mesgs') |
6120 | 6799 | { |
6121 | 6800 | //dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING); This is not deprecated, it is used by setEventMessages function |
6122 | - if (! is_array($mesgs)) // If mesgs is a string |
|
6801 | + if (! is_array($mesgs)) { |
|
6802 | + // If mesgs is a string |
|
6123 | 6803 | { |
6124 | 6804 | if ($mesgs) $_SESSION['dol_events'][$style][] = $mesgs; |
6125 | 6805 | } |
6126 | - else // If mesgs is an array |
|
6806 | + } else // If mesgs is an array |
|
6127 | 6807 | { |
6128 | 6808 | foreach($mesgs as $mesg) |
6129 | 6809 | { |
6130 | - if ($mesg) $_SESSION['dol_events'][$style][] = $mesg; |
|
6810 | + if ($mesg) { |
|
6811 | + $_SESSION['dol_events'][$style][] = $mesg; |
|
6812 | + } |
|
6131 | 6813 | } |
6132 | 6814 | } |
6133 | 6815 | } |
@@ -6144,11 +6826,17 @@ discard block |
||
6144 | 6826 | */ |
6145 | 6827 | function setEventMessages($mesg, $mesgs, $style='mesgs') |
6146 | 6828 | { |
6147 | - if (! in_array((string) $style, array('mesgs','warnings','errors'))) dol_print_error('','Bad parameter style='.$style.' for setEventMessages'); |
|
6148 | - if (empty($mesgs)) setEventMessage($mesg, $style); |
|
6149 | - else |
|
6829 | + if (! in_array((string) $style, array('mesgs','warnings','errors'))) { |
|
6830 | + dol_print_error('','Bad parameter style='.$style.' for setEventMessages'); |
|
6831 | + } |
|
6832 | + if (empty($mesgs)) { |
|
6833 | + setEventMessage($mesg, $style); |
|
6834 | + } else |
|
6150 | 6835 | { |
6151 | - if (! empty($mesg) && ! in_array($mesg, $mesgs)) setEventMessage($mesg, $style); // Add message string if not already into array |
|
6836 | + if (! empty($mesg) && ! in_array($mesg, $mesgs)) { |
|
6837 | + setEventMessage($mesg, $style); |
|
6838 | + } |
|
6839 | + // Add message string if not already into array |
|
6152 | 6840 | setEventMessage($mesgs, $style); |
6153 | 6841 | } |
6154 | 6842 | } |
@@ -6166,19 +6854,25 @@ discard block |
||
6166 | 6854 | { |
6167 | 6855 | // Show mesgs |
6168 | 6856 | if (isset($_SESSION['dol_events']['mesgs'])) { |
6169 | - if (empty($disabledoutputofmessages)) dol_htmloutput_mesg('', $_SESSION['dol_events']['mesgs']); |
|
6857 | + if (empty($disabledoutputofmessages)) { |
|
6858 | + dol_htmloutput_mesg('', $_SESSION['dol_events']['mesgs']); |
|
6859 | + } |
|
6170 | 6860 | unset($_SESSION['dol_events']['mesgs']); |
6171 | 6861 | } |
6172 | 6862 | |
6173 | 6863 | // Show errors |
6174 | 6864 | if (isset($_SESSION['dol_events']['errors'])) { |
6175 | - if (empty($disabledoutputofmessages)) dol_htmloutput_mesg('', $_SESSION['dol_events']['errors'], 'error'); |
|
6865 | + if (empty($disabledoutputofmessages)) { |
|
6866 | + dol_htmloutput_mesg('', $_SESSION['dol_events']['errors'], 'error'); |
|
6867 | + } |
|
6176 | 6868 | unset($_SESSION['dol_events']['errors']); |
6177 | 6869 | } |
6178 | 6870 | |
6179 | 6871 | // Show warnings |
6180 | 6872 | if (isset($_SESSION['dol_events']['warnings'])) { |
6181 | - if (empty($disabledoutputofmessages)) dol_htmloutput_mesg('', $_SESSION['dol_events']['warnings'], 'warning'); |
|
6873 | + if (empty($disabledoutputofmessages)) { |
|
6874 | + dol_htmloutput_mesg('', $_SESSION['dol_events']['warnings'], 'warning'); |
|
6875 | + } |
|
6182 | 6876 | unset($_SESSION['dol_events']['warnings']); |
6183 | 6877 | } |
6184 | 6878 | } |
@@ -6222,7 +6916,9 @@ discard block |
||
6222 | 6916 | { |
6223 | 6917 | $ret++; |
6224 | 6918 | $out.= $langs->trans($message); |
6225 | - if ($ret < count($mesgarray)) $out.= "<br>\n"; |
|
6919 | + if ($ret < count($mesgarray)) { |
|
6920 | + $out.= "<br>\n"; |
|
6921 | + } |
|
6226 | 6922 | } |
6227 | 6923 | } |
6228 | 6924 | if ($mesgstring) |
@@ -6252,8 +6948,7 @@ discard block |
||
6252 | 6948 | } |
6253 | 6949 | }); |
6254 | 6950 | </script>'; |
6255 | - } |
|
6256 | - else |
|
6951 | + } else |
|
6257 | 6952 | { |
6258 | 6953 | $return = $out; |
6259 | 6954 | } |
@@ -6293,7 +6988,9 @@ discard block |
||
6293 | 6988 | */ |
6294 | 6989 | function dol_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepembedded=0) |
6295 | 6990 | { |
6296 | - if (empty($mesgstring) && (! is_array($mesgarray) || count($mesgarray) == 0)) return; |
|
6991 | + if (empty($mesgstring) && (! is_array($mesgarray) || count($mesgarray) == 0)) { |
|
6992 | + return; |
|
6993 | + } |
|
6297 | 6994 | |
6298 | 6995 | $iserror=0; |
6299 | 6996 | $iswarning=0; |
@@ -6304,11 +7001,17 @@ discard block |
||
6304 | 7001 | if ($val && preg_match('/class="error"/i',$val)) { $iserror++; break; } |
6305 | 7002 | if ($val && preg_match('/class="warning"/i',$val)) { $iswarning++; break; } |
6306 | 7003 | } |
7004 | + } else if ($mesgstring && preg_match('/class="error"/i',$mesgstring)) { |
|
7005 | + $iserror++; |
|
7006 | + } else if ($mesgstring && preg_match('/class="warning"/i',$mesgstring)) { |
|
7007 | + $iswarning++; |
|
7008 | + } |
|
7009 | + if ($style=='error') { |
|
7010 | + $iserror++; |
|
7011 | + } |
|
7012 | + if ($style=='warning') { |
|
7013 | + $iswarning++; |
|
6307 | 7014 | } |
6308 | - else if ($mesgstring && preg_match('/class="error"/i',$mesgstring)) $iserror++; |
|
6309 | - else if ($mesgstring && preg_match('/class="warning"/i',$mesgstring)) $iswarning++; |
|
6310 | - if ($style=='error') $iserror++; |
|
6311 | - if ($style=='warning') $iswarning++; |
|
6312 | 7015 | |
6313 | 7016 | if ($iserror || $iswarning) |
6314 | 7017 | { |
@@ -6330,9 +7033,10 @@ discard block |
||
6330 | 7033 | $mesgarray=$newmesgarray; |
6331 | 7034 | } |
6332 | 7035 | print get_htmloutput_mesg($mesgstring,$mesgarray,($iserror?'error':'warning'),$keepembedded); |
7036 | + } else { |
|
7037 | + print get_htmloutput_mesg($mesgstring,$mesgarray,'ok',$keepembedded); |
|
7038 | + } |
|
6333 | 7039 | } |
6334 | - else print get_htmloutput_mesg($mesgstring,$mesgarray,'ok',$keepembedded); |
|
6335 | -} |
|
6336 | 7040 | |
6337 | 7041 | /** |
6338 | 7042 | * Print formated error messages to output (Used to show messages on html output). |
@@ -6372,13 +7076,18 @@ discard block |
||
6372 | 7076 | if (is_array($array) && $sizearray>0) |
6373 | 7077 | { |
6374 | 7078 | $temp = array(); |
6375 | - foreach(array_keys($array) as $key) $temp[$key]=$array[$key][$index]; |
|
7079 | + foreach(array_keys($array) as $key) { |
|
7080 | + $temp[$key]=$array[$key][$index]; |
|
7081 | + } |
|
6376 | 7082 | |
6377 | - if (!$natsort) ($order=='asc') ? asort($temp) : arsort($temp); |
|
6378 | - else |
|
7083 | + if (!$natsort) { |
|
7084 | + ($order=='asc') ? asort($temp) : arsort($temp); |
|
7085 | + } else |
|
6379 | 7086 | { |
6380 | 7087 | ($case_sensitive) ? natsort($temp) : natcasesort($temp); |
6381 | - if($order!='asc') $temp=array_reverse($temp,TRUE); |
|
7088 | + if($order!='asc') { |
|
7089 | + $temp=array_reverse($temp,TRUE); |
|
7090 | + } |
|
6382 | 7091 | } |
6383 | 7092 | |
6384 | 7093 | $sorted = array(); |
@@ -6406,17 +7115,39 @@ discard block |
||
6406 | 7115 | $strLength = dol_strlen($str); |
6407 | 7116 | for ($i=0; $i<$strLength; $i++) |
6408 | 7117 | { |
6409 | - if (ord($str[$i]) < 0x80) continue; // 0bbbbbbb |
|
6410 | - elseif ((ord($str[$i]) & 0xE0) == 0xC0) $n=1; // 110bbbbb |
|
6411 | - elseif ((ord($str[$i]) & 0xF0) == 0xE0) $n=2; // 1110bbbb |
|
6412 | - elseif ((ord($str[$i]) & 0xF8) == 0xF0) $n=3; // 11110bbb |
|
6413 | - elseif ((ord($str[$i]) & 0xFC) == 0xF8) $n=4; // 111110bb |
|
6414 | - elseif ((ord($str[$i]) & 0xFE) == 0xFC) $n=5; // 1111110b |
|
6415 | - else return false; // Does not match any model |
|
6416 | - for ($j=0; $j<$n; $j++) { // n bytes matching 10bbbbbb follow ? |
|
6417 | - if ((++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) |
|
7118 | + if (ord($str[$i]) < 0x80) { |
|
7119 | + continue; |
|
7120 | + } |
|
7121 | + // 0bbbbbbb |
|
7122 | + elseif ((ord($str[$i]) & 0xE0) == 0xC0) { |
|
7123 | + $n=1; |
|
7124 | + } |
|
7125 | + // 110bbbbb |
|
7126 | + elseif ((ord($str[$i]) & 0xF0) == 0xE0) { |
|
7127 | + $n=2; |
|
7128 | + } |
|
7129 | + // 1110bbbb |
|
7130 | + elseif ((ord($str[$i]) & 0xF8) == 0xF0) { |
|
7131 | + $n=3; |
|
7132 | + } |
|
7133 | + // 11110bbb |
|
7134 | + elseif ((ord($str[$i]) & 0xFC) == 0xF8) { |
|
7135 | + $n=4; |
|
7136 | + } |
|
7137 | + // 111110bb |
|
7138 | + elseif ((ord($str[$i]) & 0xFE) == 0xFC) { |
|
7139 | + $n=5; |
|
7140 | + } |
|
7141 | + // 1111110b |
|
7142 | + else { |
|
6418 | 7143 | return false; |
6419 | 7144 | } |
7145 | + // Does not match any model |
|
7146 | + for ($j=0; $j<$n; $j++) { // n bytes matching 10bbbbbb follow ? |
|
7147 | + if ((++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) { |
|
7148 | + return false; |
|
7149 | + } |
|
7150 | + } |
|
6420 | 7151 | } |
6421 | 7152 | return true; |
6422 | 7153 | } |
@@ -6434,11 +7165,21 @@ discard block |
||
6434 | 7165 | global $conf; |
6435 | 7166 | |
6436 | 7167 | $tmp=ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0 |
6437 | - if (empty($tmp) && ! empty($_SERVER["WINDIR"])) $tmp='iso-8859-1'; // By default for windows |
|
6438 | - if (empty($tmp)) $tmp='utf-8'; // By default for other |
|
6439 | - if (! empty($conf->global->MAIN_FILESYSTEM_ENCODING)) $tmp=$conf->global->MAIN_FILESYSTEM_ENCODING; |
|
7168 | + if (empty($tmp) && ! empty($_SERVER["WINDIR"])) { |
|
7169 | + $tmp='iso-8859-1'; |
|
7170 | + } |
|
7171 | + // By default for windows |
|
7172 | + if (empty($tmp)) { |
|
7173 | + $tmp='utf-8'; |
|
7174 | + } |
|
7175 | + // By default for other |
|
7176 | + if (! empty($conf->global->MAIN_FILESYSTEM_ENCODING)) { |
|
7177 | + $tmp=$conf->global->MAIN_FILESYSTEM_ENCODING; |
|
7178 | + } |
|
6440 | 7179 | |
6441 | - if ($tmp == 'iso-8859-1') return utf8_decode($str); |
|
7180 | + if ($tmp == 'iso-8859-1') { |
|
7181 | + return utf8_decode($str); |
|
7182 | + } |
|
6442 | 7183 | return $str; |
6443 | 7184 | } |
6444 | 7185 | |
@@ -6461,31 +7202,39 @@ discard block |
||
6461 | 7202 | global $cache_codes; |
6462 | 7203 | |
6463 | 7204 | // If key empty |
6464 | - if ($key == '') return ''; |
|
7205 | + if ($key == '') { |
|
7206 | + return ''; |
|
7207 | + } |
|
6465 | 7208 | |
6466 | 7209 | // Check in cache |
6467 | - if (isset($cache_codes[$tablename][$key])) // Can be defined to 0 or '' |
|
7210 | + if (isset($cache_codes[$tablename][$key])) { |
|
7211 | + // Can be defined to 0 or '' |
|
6468 | 7212 | { |
6469 | - return $cache_codes[$tablename][$key]; // Found in cache |
|
7213 | + return $cache_codes[$tablename][$key]; |
|
7214 | + } |
|
7215 | + // Found in cache |
|
6470 | 7216 | } |
6471 | 7217 | |
6472 | 7218 | $sql = "SELECT ".$fieldid." as valuetoget"; |
6473 | 7219 | $sql.= " FROM ".MAIN_DB_PREFIX.$tablename; |
6474 | 7220 | $sql.= " WHERE ".$fieldkey." = '".$db->escape($key)."'"; |
6475 | - if (! empty($entityfilter)) |
|
6476 | - $sql.= " AND entity IN (" . getEntity($tablename) . ")"; |
|
7221 | + if (! empty($entityfilter)) { |
|
7222 | + $sql.= " AND entity IN (" . getEntity($tablename) . ")"; |
|
7223 | + } |
|
6477 | 7224 | |
6478 | 7225 | dol_syslog('dol_getIdFromCode', LOG_DEBUG); |
6479 | 7226 | $resql = $db->query($sql); |
6480 | 7227 | if ($resql) |
6481 | 7228 | { |
6482 | 7229 | $obj = $db->fetch_object($resql); |
6483 | - if ($obj) $cache_codes[$tablename][$key]=$obj->valuetoget; |
|
6484 | - else $cache_codes[$tablename][$key]=''; |
|
7230 | + if ($obj) { |
|
7231 | + $cache_codes[$tablename][$key]=$obj->valuetoget; |
|
7232 | + } else { |
|
7233 | + $cache_codes[$tablename][$key]=''; |
|
7234 | + } |
|
6485 | 7235 | $db->free($resql); |
6486 | 7236 | return $cache_codes[$tablename][$key]; |
6487 | - } |
|
6488 | - else |
|
7237 | + } else |
|
6489 | 7238 | { |
6490 | 7239 | return -1; |
6491 | 7240 | } |
@@ -6542,13 +7291,18 @@ discard block |
||
6542 | 7291 | //print $s."<br>\n"; |
6543 | 7292 | if ($returnvalue) |
6544 | 7293 | { |
6545 | - if ($hideerrors) return @eval('return '.$s.';'); |
|
6546 | - else return eval('return '.$s.';'); |
|
6547 | - } |
|
6548 | - else |
|
7294 | + if ($hideerrors) { |
|
7295 | + return @eval('return '.$s.';'); |
|
7296 | + } else { |
|
7297 | + return eval('return '.$s.';'); |
|
7298 | + } |
|
7299 | + } else |
|
6549 | 7300 | { |
6550 | - if ($hideerrors) @eval($s); |
|
6551 | - else eval($s); |
|
7301 | + if ($hideerrors) { |
|
7302 | + @eval($s); |
|
7303 | + } else { |
|
7304 | + eval($s); |
|
7305 | + } |
|
6552 | 7306 | } |
6553 | 7307 | } |
6554 | 7308 | |
@@ -6574,9 +7328,13 @@ discard block |
||
6574 | 7328 | { |
6575 | 7329 | global $langs; |
6576 | 7330 | |
6577 | - if (empty($codelang)) return ''; |
|
7331 | + if (empty($codelang)) { |
|
7332 | + return ''; |
|
7333 | + } |
|
6578 | 7334 | |
6579 | - if (empty($codelang)) return ''; |
|
7335 | + if (empty($codelang)) { |
|
7336 | + return ''; |
|
7337 | + } |
|
6580 | 7338 | |
6581 | 7339 | if ($codelang == 'auto') |
6582 | 7340 | { |
@@ -6591,8 +7349,9 @@ discard block |
||
6591 | 7349 | 'sv_SV' => 'se' |
6592 | 7350 | ); |
6593 | 7351 | |
6594 | - if (isset($langtocountryflag[$codelang])) $flagImage = $langtocountryflag[$codelang]; |
|
6595 | - else |
|
7352 | + if (isset($langtocountryflag[$codelang])) { |
|
7353 | + $flagImage = $langtocountryflag[$codelang]; |
|
7354 | + } else |
|
6596 | 7355 | { |
6597 | 7356 | $tmparray = explode('_', $codelang); |
6598 | 7357 | $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1]; |
@@ -6642,50 +7401,62 @@ discard block |
||
6642 | 7401 | |
6643 | 7402 | if ($mode == 'add' && ! preg_match('/^\-/',$values[1])) |
6644 | 7403 | { |
6645 | - if (count($values) == 6) // new declaration with permissions: $value='objecttype:+tabname1:Title1:langfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__' |
|
7404 | + if (count($values) == 6) { |
|
7405 | + // new declaration with permissions: $value='objecttype:+tabname1:Title1:langfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__' |
|
6646 | 7406 | { |
6647 | 7407 | if ($values[0] != $type) continue; |
7408 | + } |
|
6648 | 7409 | |
6649 | 7410 | if (verifCond($values[4])) |
6650 | 7411 | { |
6651 | - if ($values[3]) $langs->load($values[3]); |
|
7412 | + if ($values[3]) { |
|
7413 | + $langs->load($values[3]); |
|
7414 | + } |
|
6652 | 7415 | if (preg_match('/SUBSTITUTION_([^_]+)/i',$values[2],$reg)) |
6653 | 7416 | { |
6654 | 7417 | $substitutionarray=array(); |
6655 | 7418 | complete_substitutions_array($substitutionarray,$langs,$object,array('needforkey'=>$values[2])); |
6656 | 7419 | $label=make_substitutions($reg[1], $substitutionarray); |
7420 | + } else { |
|
7421 | + $label=$langs->trans($values[2]); |
|
6657 | 7422 | } |
6658 | - else $label=$langs->trans($values[2]); |
|
6659 | 7423 | |
6660 | 7424 | $head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && ! empty($object->id))?$object->id:''), $values[5]), 1); |
6661 | 7425 | $head[$h][1] = $label; |
6662 | 7426 | $head[$h][2] = str_replace('+','',$values[1]); |
6663 | 7427 | $h++; |
6664 | 7428 | } |
6665 | - } |
|
6666 | - else if (count($values) == 5) // deprecated |
|
7429 | + } else if (count($values) == 5) { |
|
7430 | + // deprecated |
|
6667 | 7431 | { |
6668 | 7432 | dol_syslog('Passing 5 values in tabs module_parts is deprecated. Please update to 6 with permissions.', LOG_WARNING); |
7433 | + } |
|
6669 | 7434 | |
6670 | - if ($values[0] != $type) continue; |
|
6671 | - if ($values[3]) $langs->load($values[3]); |
|
7435 | + if ($values[0] != $type) { |
|
7436 | + continue; |
|
7437 | + } |
|
7438 | + if ($values[3]) { |
|
7439 | + $langs->load($values[3]); |
|
7440 | + } |
|
6672 | 7441 | if (preg_match('/SUBSTITUTION_([^_]+)/i',$values[2],$reg)) |
6673 | 7442 | { |
6674 | 7443 | $substitutionarray=array(); |
6675 | 7444 | complete_substitutions_array($substitutionarray,$langs,$object,array('needforkey'=>$values[2])); |
6676 | 7445 | $label=make_substitutions($reg[1], $substitutionarray); |
7446 | + } else { |
|
7447 | + $label=$langs->trans($values[2]); |
|
6677 | 7448 | } |
6678 | - else $label=$langs->trans($values[2]); |
|
6679 | 7449 | |
6680 | 7450 | $head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && ! empty($object->id))?$object->id:''), $values[4]), 1); |
6681 | 7451 | $head[$h][1] = $label; |
6682 | 7452 | $head[$h][2] = str_replace('+','',$values[1]); |
6683 | 7453 | $h++; |
6684 | 7454 | } |
6685 | - } |
|
6686 | - else if ($mode == 'remove' && preg_match('/^\-/',$values[1])) |
|
7455 | + } else if ($mode == 'remove' && preg_match('/^\-/',$values[1])) |
|
6687 | 7456 | { |
6688 | - if ($values[0] != $type) continue; |
|
7457 | + if ($values[0] != $type) { |
|
7458 | + continue; |
|
7459 | + } |
|
6689 | 7460 | $tabname=str_replace('-','',$values[1]); |
6690 | 7461 | foreach($head as $key => $val) |
6691 | 7462 | { |
@@ -6728,14 +7499,19 @@ discard block |
||
6728 | 7499 | global $conf, $hookmanager; |
6729 | 7500 | global $micro_start_time; |
6730 | 7501 | |
6731 | - if ($zone == 'private') print "\n".'<!-- Common footer for private page -->'."\n"; |
|
6732 | - else print "\n".'<!-- Common footer for public page -->'."\n"; |
|
7502 | + if ($zone == 'private') { |
|
7503 | + print "\n".'<!-- Common footer for private page -->'."\n"; |
|
7504 | + } else { |
|
7505 | + print "\n".'<!-- Common footer for public page -->'."\n"; |
|
7506 | + } |
|
6733 | 7507 | |
6734 | 7508 | $parameters=array(); |
6735 | 7509 | $reshook=$hookmanager->executeHooks('printCommonFooter',$parameters); // Note that $action and $object may have been modified by some hooks |
6736 | 7510 | if (empty($reshook)) |
6737 | 7511 | { |
6738 | - if (! empty($conf->global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER."\n"; |
|
7512 | + if (! empty($conf->global->MAIN_HTML_FOOTER)) { |
|
7513 | + print $conf->global->MAIN_HTML_FOOTER."\n"; |
|
7514 | + } |
|
6739 | 7515 | |
6740 | 7516 | print "\n"; |
6741 | 7517 | if (! empty($conf->use_javascript_ajax)) |
@@ -6779,11 +7555,15 @@ discard block |
||
6779 | 7555 | print "\n"; |
6780 | 7556 | print "/* JS CODE TO ENABLE to add memory info */\n"; |
6781 | 7557 | print 'window.console && console.log("'; |
6782 | - if (! empty($conf->global->MEMCACHED_SERVER)) print 'MEMCACHED_SERVER='.$conf->global->MEMCACHED_SERVER.' - '; |
|
7558 | + if (! empty($conf->global->MEMCACHED_SERVER)) { |
|
7559 | + print 'MEMCACHED_SERVER='.$conf->global->MEMCACHED_SERVER.' - '; |
|
7560 | + } |
|
6783 | 7561 | print 'MAIN_OPTIMIZE_SPEED='.(isset($conf->global->MAIN_OPTIMIZE_SPEED)?$conf->global->MAIN_OPTIMIZE_SPEED:'off'); |
6784 | - if (! empty($micro_start_time)) // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in global variable. |
|
7562 | + if (! empty($micro_start_time)) { |
|
7563 | + // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in global variable. |
|
6785 | 7564 | { |
6786 | 7565 | $micro_end_time = microtime(true); |
7566 | + } |
|
6787 | 7567 | print ' - Build time: '.ceil(1000*($micro_end_time-$micro_start_time)).' ms'; |
6788 | 7568 | } |
6789 | 7569 | if (function_exists("memory_get_usage")) |
@@ -6921,7 +7701,9 @@ discard block |
||
6921 | 7701 | |
6922 | 7702 | $crits = explode(' ', $value); |
6923 | 7703 | $res = ''; |
6924 | - if (! is_array($fields)) $fields = array($fields); |
|
7704 | + if (! is_array($fields)) { |
|
7705 | + $fields = array($fields); |
|
7706 | + } |
|
6925 | 7707 | |
6926 | 7708 | $nboffields = count($fields); |
6927 | 7709 | $end2 = count($crits); |
@@ -6948,20 +7730,17 @@ discard block |
||
6948 | 7730 | if (is_numeric($numnewcrit)) |
6949 | 7731 | { |
6950 | 7732 | $newres .= ($i2 > 0 ? ' OR ' : '') . $field . ' '.$operator.' '.$numnewcrit; |
6951 | - } |
|
6952 | - else |
|
7733 | + } else |
|
6953 | 7734 | { |
6954 | 7735 | $newres .= ($i2 > 0 ? ' OR ' : '') . '1 = 2'; // force false |
6955 | 7736 | } |
6956 | 7737 | $i2++; // a criteria was added to string |
6957 | 7738 | } |
6958 | - } |
|
6959 | - else if ($mode == 2) |
|
7739 | + } else if ($mode == 2) |
|
6960 | 7740 | { |
6961 | 7741 | $newres .= ($i2 > 0 ? ' OR ' : '') . $field . " IN (" . $db->escape(trim($crit)) . ")"; |
6962 | 7742 | $i2++; // a criteria was added to string |
6963 | - } |
|
6964 | - else if ($mode == 3) |
|
7743 | + } else if ($mode == 3) |
|
6965 | 7744 | { |
6966 | 7745 | $tmparray=explode(',',trim($crit)); |
6967 | 7746 | if (count($tmparray)) |
@@ -6978,8 +7757,7 @@ discard block |
||
6978 | 7757 | $newres .= ($i2 > 0 ? ' OR ' : '') . $field . " IN (" . $listofcodes . ")"; |
6979 | 7758 | $i2++; // a criteria was added to string |
6980 | 7759 | } |
6981 | - } |
|
6982 | - else // $mode=0 |
|
7760 | + } else // $mode=0 |
|
6983 | 7761 | { |
6984 | 7762 | $textcrit = ''; |
6985 | 7763 | $tmpcrits = explode('|',$crit); |
@@ -6988,11 +7766,12 @@ discard block |
||
6988 | 7766 | { |
6989 | 7767 | $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : ''); |
6990 | 7768 | |
6991 | - if (preg_match('/\.(id|rowid)$/', $field)) // Special case for rowid that is sometimes a ref so used as a search field |
|
7769 | + if (preg_match('/\.(id|rowid)$/', $field)) { |
|
7770 | + // Special case for rowid that is sometimes a ref so used as a search field |
|
6992 | 7771 | { |
6993 | 7772 | $newres .= $field . " = " . (is_numeric(trim($tmpcrit))?trim($tmpcrit):'0'); |
6994 | 7773 | } |
6995 | - else |
|
7774 | + } else |
|
6996 | 7775 | { |
6997 | 7776 | $newres .= $field . " LIKE '"; |
6998 | 7777 | |
@@ -7025,7 +7804,9 @@ discard block |
||
7025 | 7804 | } |
7026 | 7805 | $i++; |
7027 | 7806 | } |
7028 | - if ($newres) $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') .$newres . ($i2 > 1 ? ')' : ''); |
|
7807 | + if ($newres) { |
|
7808 | + $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') .$newres . ($i2 > 1 ? ')' : ''); |
|
7809 | + } |
|
7029 | 7810 | $j++; |
7030 | 7811 | } |
7031 | 7812 | $res = ($nofirstand?"":" AND ")."(" . $res . ")"; |
@@ -7066,21 +7847,37 @@ discard block |
||
7066 | 7847 | function getImageFileNameForSize($file, $extName, $extImgTarget='') |
7067 | 7848 | { |
7068 | 7849 | $dirName = dirname($file); |
7069 | - if ($dirName == '.') $dirName=''; |
|
7850 | + if ($dirName == '.') { |
|
7851 | + $dirName=''; |
|
7852 | + } |
|
7070 | 7853 | |
7071 | 7854 | $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // We remove extension, whatever is its case |
7072 | 7855 | $fileName = basename($fileName); |
7073 | 7856 | |
7074 | - if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.jpg$/i',$file)?'.jpg':''); |
|
7075 | - if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.jpeg$/i',$file)?'.jpeg':''); |
|
7076 | - if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.gif$/i',$file)?'.gif':''); |
|
7077 | - if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.png$/i',$file)?'.png':''); |
|
7078 | - if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.bmp$/i',$file)?'.bmp':''); |
|
7857 | + if (empty($extImgTarget)) { |
|
7858 | + $extImgTarget = (preg_match('/\.jpg$/i',$file)?'.jpg':''); |
|
7859 | + } |
|
7860 | + if (empty($extImgTarget)) { |
|
7861 | + $extImgTarget = (preg_match('/\.jpeg$/i',$file)?'.jpeg':''); |
|
7862 | + } |
|
7863 | + if (empty($extImgTarget)) { |
|
7864 | + $extImgTarget = (preg_match('/\.gif$/i',$file)?'.gif':''); |
|
7865 | + } |
|
7866 | + if (empty($extImgTarget)) { |
|
7867 | + $extImgTarget = (preg_match('/\.png$/i',$file)?'.png':''); |
|
7868 | + } |
|
7869 | + if (empty($extImgTarget)) { |
|
7870 | + $extImgTarget = (preg_match('/\.bmp$/i',$file)?'.bmp':''); |
|
7871 | + } |
|
7079 | 7872 | |
7080 | - if (! $extImgTarget) return $file; |
|
7873 | + if (! $extImgTarget) { |
|
7874 | + return $file; |
|
7875 | + } |
|
7081 | 7876 | |
7082 | 7877 | $subdir=''; |
7083 | - if ($extName) $subdir = 'thumbs/'; |
|
7878 | + if ($extName) { |
|
7879 | + $subdir = 'thumbs/'; |
|
7880 | + } |
|
7084 | 7881 | |
7085 | 7882 | return ($dirName?$dirName.'/':'').$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb |
7086 | 7883 | } |
@@ -7099,7 +7896,9 @@ discard block |
||
7099 | 7896 | { |
7100 | 7897 | global $conf, $langs; |
7101 | 7898 | |
7102 | - if (empty($conf->use_javascript_ajax)) return ''; |
|
7899 | + if (empty($conf->use_javascript_ajax)) { |
|
7900 | + return ''; |
|
7901 | + } |
|
7103 | 7902 | |
7104 | 7903 | $mime_preview = array('bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css', 'svg+xml'); |
7105 | 7904 | //$mime_preview[]='vnd.oasis.opendocument.presentation'; |
@@ -7108,14 +7907,20 @@ discard block |
||
7108 | 7907 | |
7109 | 7908 | if ($alldata == 1) |
7110 | 7909 | { |
7111 | - if ($num_mime !== false) return array('target'=>'_blank', 'css'=>'documentpreview', 'url'=>DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath), 'mime'=>dol_mimetype($relativepath), ); |
|
7112 | - else return array(); |
|
7910 | + if ($num_mime !== false) { |
|
7911 | + return array('target'=>'_blank', 'css'=>'documentpreview', 'url'=>DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath), 'mime'=>dol_mimetype($relativepath), ); |
|
7912 | + } else { |
|
7913 | + return array(); |
|
7914 | + } |
|
7113 | 7915 | } |
7114 | 7916 | |
7115 | 7917 | // old behavior |
7116 | - if ($num_mime !== false) return 'javascript:document_preview(\''.dol_escape_js(DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).($param?'&'.$param:'')).'\', \''.dol_mimetype($relativepath).'\', \''.dol_escape_js($langs->trans('Preview')).'\')'; |
|
7117 | - else return ''; |
|
7118 | -} |
|
7918 | + if ($num_mime !== false) { |
|
7919 | + return 'javascript:document_preview(\''.dol_escape_js(DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).($param?'&'.$param:'')).'\', \''.dol_mimetype($relativepath).'\', \''.dol_escape_js($langs->trans('Preview')).'\')'; |
|
7920 | + } else { |
|
7921 | + return ''; |
|
7922 | + } |
|
7923 | + } |
|
7119 | 7924 | |
7120 | 7925 | |
7121 | 7926 | /** |
@@ -7132,7 +7937,9 @@ discard block |
||
7132 | 7937 | jQuery("#'.$htmlname.'").click(function() { jQuery(this).select(); } ); |
7133 | 7938 | }); |
7134 | 7939 | </script>'; |
7135 | - if ($addlink) $out.=' <a href="'.$addlink.'" target="_blank">'.$langs->trans("Link").'</a>'; |
|
7940 | + if ($addlink) { |
|
7941 | + $out.=' <a href="'.$addlink.'" target="_blank">'.$langs->trans("Link").'</a>'; |
|
7942 | + } |
|
7136 | 7943 | return $out; |
7137 | 7944 | } |
7138 | 7945 | |
@@ -7269,7 +8076,9 @@ discard block |
||
7269 | 8076 | { |
7270 | 8077 | $dictvalues[$tablename] = array(); |
7271 | 8078 | $sql = 'SELECT * FROM '.$tablename.' WHERE 1'; |
7272 | - if ($checkentity) $sql.= ' entity IN (0,'.getEntity('').')'; |
|
8079 | + if ($checkentity) { |
|
8080 | + $sql.= ' entity IN (0,'.getEntity('').')'; |
|
8081 | + } |
|
7273 | 8082 | |
7274 | 8083 | $resql = $db->query($sql); |
7275 | 8084 | if ($resql) |
@@ -7278,17 +8087,21 @@ discard block |
||
7278 | 8087 | { |
7279 | 8088 | $dictvalues[$tablename][$obj->{$rowidfield}] = $obj; |
7280 | 8089 | } |
7281 | - } |
|
7282 | - else |
|
8090 | + } else |
|
7283 | 8091 | { |
7284 | 8092 | dol_print_error($db); |
7285 | 8093 | } |
7286 | 8094 | } |
7287 | 8095 | |
7288 | - if (!empty($dictvalues[$tablename][$id])) return $dictvalues[$tablename][$id]->{$field}; // Found |
|
8096 | + if (!empty($dictvalues[$tablename][$id])) { |
|
8097 | + return $dictvalues[$tablename][$id]->{$field}; |
|
8098 | + } |
|
8099 | + // Found |
|
7289 | 8100 | else // Not found |
7290 | 8101 | { |
7291 | - if ($id > 0) return $id; |
|
8102 | + if ($id > 0) { |
|
8103 | + return $id; |
|
8104 | + } |
|
7292 | 8105 | return ''; |
7293 | 8106 | } |
7294 | 8107 | } |
@@ -7306,13 +8119,14 @@ discard block |
||
7306 | 8119 | { |
7307 | 8120 | $res = 0; |
7308 | 8121 | $tmp=explode(',', $stringcolor); |
7309 | - if (count($tmp) > 1) // This is a comma RGB ('255','255','255') |
|
8122 | + if (count($tmp) > 1) { |
|
8123 | + // This is a comma RGB ('255','255','255') |
|
7310 | 8124 | { |
7311 | 8125 | $r = $tmp[0]; |
8126 | + } |
|
7312 | 8127 | $g = $tmp[1]; |
7313 | 8128 | $b = $tmp[2]; |
7314 | - } |
|
7315 | - else |
|
8129 | + } else |
|
7316 | 8130 | { |
7317 | 8131 | $hexr=$stringcolor[0].$stringcolor[1]; |
7318 | 8132 | $hexg=$stringcolor[2].$stringcolor[3]; |
@@ -7322,7 +8136,9 @@ discard block |
||
7322 | 8136 | $b = hexdec($hexb); |
7323 | 8137 | } |
7324 | 8138 | $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm |
7325 | - if ($bright > 0.6) $res = 1; |
|
8139 | + if ($bright > 0.6) { |
|
8140 | + $res = 1; |
|
8141 | + } |
|
7326 | 8142 | } |
7327 | 8143 | return $res; |
7328 | 8144 | } |
@@ -7341,7 +8157,10 @@ discard block |
||
7341 | 8157 | |
7342 | 8158 | //print 'type_user='.$type_user.' module='.$menuentry['module'].' enabled='.$menuentry['enabled'].' perms='.$menuentry['perms']; |
7343 | 8159 | //print 'ok='.in_array($menuentry['module'], $listofmodulesforexternal); |
7344 | - if (empty($menuentry['enabled'])) return 0; // Entry disabled by condition |
|
8160 | + if (empty($menuentry['enabled'])) { |
|
8161 | + return 0; |
|
8162 | + } |
|
8163 | + // Entry disabled by condition |
|
7345 | 8164 | if ($type_user && $menuentry['module']) |
7346 | 8165 | { |
7347 | 8166 | $tmploops=explode('|',$menuentry['module']); |
@@ -7352,10 +8171,22 @@ discard block |
||
7352 | 8171 | $found++; break; |
7353 | 8172 | } |
7354 | 8173 | } |
7355 | - if (! $found) return 0; // Entry is for menus all excluded to external users |
|
8174 | + if (! $found) { |
|
8175 | + return 0; |
|
8176 | + } |
|
8177 | + // Entry is for menus all excluded to external users |
|
8178 | + } |
|
8179 | + if (! $menuentry['perms'] && $type_user) { |
|
8180 | + return 0; |
|
8181 | + } |
|
8182 | + // No permissions and user is external |
|
8183 | + if (! $menuentry['perms'] && ! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) { |
|
8184 | + return 0; |
|
8185 | + } |
|
8186 | + // No permissions and option to hide when not allowed, even for internal user, is on |
|
8187 | + if (! $menuentry['perms']) { |
|
8188 | + return 2; |
|
7356 | 8189 | } |
7357 | - if (! $menuentry['perms'] && $type_user) return 0; // No permissions and user is external |
|
7358 | - if (! $menuentry['perms'] && ! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) return 0; // No permissions and option to hide when not allowed, even for internal user, is on |
|
7359 | - if (! $menuentry['perms']) return 2; // No permissions and user is external |
|
8190 | + // No permissions and user is external |
|
7360 | 8191 | return 1; |
7361 | 8192 | } |
@@ -97,16 +97,21 @@ discard block |
||
97 | 97 | // $hookmanager->resArray may contain array stacked by other modules |
98 | 98 | if (empty($reshook)) |
99 | 99 | { |
100 | - if (! is_dir($newpath)) return array(); |
|
100 | + if (! is_dir($newpath)) { |
|
101 | + return array(); |
|
102 | + } |
|
101 | 103 | |
102 | 104 | if ($dir = opendir($newpath)) |
103 | 105 | { |
104 | 106 | $filedate=''; |
105 | 107 | $filesize=''; |
106 | 108 | |
107 | - while (false !== ($file = readdir($dir))) // $file is always a basename (into directory $newpath) |
|
109 | + while (false !== ($file = readdir($dir))) { |
|
110 | + // $file is always a basename (into directory $newpath) |
|
108 | 111 | { |
109 | - if (! utf8_check($file)) $file=utf8_encode($file); // To be sure data is stored in utf8 in memory |
|
112 | + if (! utf8_check($file)) $file=utf8_encode($file); |
|
113 | + } |
|
114 | + // To be sure data is stored in utf8 in memory |
|
110 | 115 | $fullpathfile=($newpath?$newpath.'/':'').$file; |
111 | 116 | |
112 | 117 | $qualified=1; |
@@ -116,8 +121,9 @@ discard block |
||
116 | 121 | if (is_array($excludefilter)) |
117 | 122 | { |
118 | 123 | $excludefilterarray=array_merge($excludefilterarray,$excludefilter); |
124 | + } else if ($excludefilter) { |
|
125 | + $excludefilterarray[]=$excludefilter; |
|
119 | 126 | } |
120 | - else if ($excludefilter) $excludefilterarray[]=$excludefilter; |
|
121 | 127 | // Check if file is qualified |
122 | 128 | foreach($excludefilterarray as $filt) |
123 | 129 | { |
@@ -136,12 +142,18 @@ discard block |
||
136 | 142 | // Add entry into file_list array |
137 | 143 | if (($types=="directories") || ($types=="all")) |
138 | 144 | { |
139 | - if ($loaddate || $sortcriteria == 'date') $filedate=dol_filemtime($path."/".$file); |
|
140 | - if ($loadsize || $sortcriteria == 'size') $filesize=dol_filesize($path."/".$file); |
|
145 | + if ($loaddate || $sortcriteria == 'date') { |
|
146 | + $filedate=dol_filemtime($path."/".$file); |
|
147 | + } |
|
148 | + if ($loadsize || $sortcriteria == 'size') { |
|
149 | + $filesize=dol_filesize($path."/".$file); |
|
150 | + } |
|
141 | 151 | |
142 | - if (! $filter || preg_match('/'.$filter.'/i',$file)) // We do not search key $filter into all $path, only into $file part |
|
152 | + if (! $filter || preg_match('/'.$filter.'/i',$file)) { |
|
153 | + // We do not search key $filter into all $path, only into $file part |
|
143 | 154 | { |
144 | 155 | preg_match('/([^\/]+)\/[^\/]+$/',$path.'/'.$file,$reg); |
156 | + } |
|
145 | 157 | $level1name=(isset($reg[1])?$reg[1]:''); |
146 | 158 | $file_list[] = array( |
147 | 159 | "name" => $file, |
@@ -161,16 +173,21 @@ discard block |
||
161 | 173 | { |
162 | 174 | $file_list = array_merge($file_list, dol_dir_list($path."/".$file, $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder, $mode, $nohook, ($relativename!=''?$relativename.'/':'').$file)); |
163 | 175 | } |
164 | - } |
|
165 | - else if (! $isdir && (($types == "files") || ($types == "all"))) |
|
176 | + } else if (! $isdir && (($types == "files") || ($types == "all"))) |
|
166 | 177 | { |
167 | 178 | // Add file into file_list array |
168 | - if ($loaddate || $sortcriteria == 'date') $filedate=dol_filemtime($path."/".$file); |
|
169 | - if ($loadsize || $sortcriteria == 'size') $filesize=dol_filesize($path."/".$file); |
|
179 | + if ($loaddate || $sortcriteria == 'date') { |
|
180 | + $filedate=dol_filemtime($path."/".$file); |
|
181 | + } |
|
182 | + if ($loadsize || $sortcriteria == 'size') { |
|
183 | + $filesize=dol_filesize($path."/".$file); |
|
184 | + } |
|
170 | 185 | |
171 | - if (! $filter || preg_match('/'.$filter.'/i',$file)) // We do not search key $filter into $path, only into $file |
|
186 | + if (! $filter || preg_match('/'.$filter.'/i',$file)) { |
|
187 | + // We do not search key $filter into $path, only into $file |
|
172 | 188 | { |
173 | 189 | preg_match('/([^\/]+)\/[^\/]+$/',$path.'/'.$file,$reg); |
190 | + } |
|
174 | 191 | $level1name=(isset($reg[1])?$reg[1]:''); |
175 | 192 | $file_list[] = array( |
176 | 193 | "name" => $file, |
@@ -197,12 +214,16 @@ discard block |
||
197 | 214 | $myarray[$key] = (isset($row[$sortcriteria])?$row[$sortcriteria]:''); |
198 | 215 | } |
199 | 216 | // Sort the data |
200 | - if ($sortorder) array_multisort($myarray, $sortorder, $file_list); |
|
217 | + if ($sortorder) { |
|
218 | + array_multisort($myarray, $sortorder, $file_list); |
|
219 | + } |
|
201 | 220 | } |
202 | 221 | } |
203 | 222 | } |
204 | 223 | |
205 | - if (is_object($hookmanager) && is_array($hookmanager->resArray)) $file_list = array_merge($file_list, $hookmanager->resArray); |
|
224 | + if (is_object($hookmanager) && is_array($hookmanager->resArray)) { |
|
225 | + $file_list = array_merge($file_list, $hookmanager->resArray); |
|
226 | + } |
|
206 | 227 | |
207 | 228 | return $file_list; |
208 | 229 | } |
@@ -227,7 +248,9 @@ discard block |
||
227 | 248 | |
228 | 249 | $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,"; |
229 | 250 | $sql.=" acl, position, share"; |
230 | - if ($mode) $sql.=", description"; |
|
251 | + if ($mode) { |
|
252 | + $sql.=", description"; |
|
253 | + } |
|
231 | 254 | $sql.=" FROM ".MAIN_DB_PREFIX."ecm_files"; |
232 | 255 | $sql.=" WHERE filepath = '".$db->escape($path)."'"; |
233 | 256 | $sql.=" AND entity = ".$conf->entity; |
@@ -275,12 +298,13 @@ discard block |
||
275 | 298 | $myarray[$key] = (isset($row[$sortcriteria])?$row[$sortcriteria]:''); |
276 | 299 | } |
277 | 300 | // Sort the data |
278 | - if ($sortorder) array_multisort($myarray, $sortorder, $file_list); |
|
301 | + if ($sortorder) { |
|
302 | + array_multisort($myarray, $sortorder, $file_list); |
|
303 | + } |
|
279 | 304 | } |
280 | 305 | |
281 | 306 | return $file_list; |
282 | - } |
|
283 | - else |
|
307 | + } else |
|
284 | 308 | { |
285 | 309 | dol_print_error($db); |
286 | 310 | return array(); |
@@ -326,16 +350,21 @@ discard block |
||
326 | 350 | } |
327 | 351 | } |
328 | 352 | |
329 | - if (! $found) // This happen in transition toward version 6, or if files were added manually into os dir. |
|
353 | + if (! $found) { |
|
354 | + // This happen in transition toward version 6, or if files were added manually into os dir. |
|
330 | 355 | { |
331 | - $filearray[$key]['position']='999999'; // File not indexed are at end. So if we add a file, it will not replace an existing position |
|
356 | + $filearray[$key]['position']='999999'; |
|
357 | + } |
|
358 | + // File not indexed are at end. So if we add a file, it will not replace an existing position |
|
332 | 359 | $filearray[$key]['cover']=0; |
333 | 360 | $filearray[$key]['acl']=''; |
334 | 361 | |
335 | 362 | $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $filearray[$key]['fullname']); |
336 | - if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter)) // If not a tmp file |
|
363 | + if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter)) { |
|
364 | + // If not a tmp file |
|
337 | 365 | { |
338 | 366 | dol_syslog("list_of_documents We found a file called '".$filearray[$key]['name']."' not indexed into database. We add it"); |
367 | + } |
|
339 | 368 | include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
340 | 369 | $ecmfile=new EcmFiles($db); |
341 | 370 | |
@@ -356,13 +385,11 @@ discard block |
||
356 | 385 | if ($result < 0) |
357 | 386 | { |
358 | 387 | setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); |
359 | - } |
|
360 | - else |
|
388 | + } else |
|
361 | 389 | { |
362 | 390 | $filearray[$key]['rowid']=$result; |
363 | 391 | } |
364 | - } |
|
365 | - else |
|
392 | + } else |
|
366 | 393 | { |
367 | 394 | $filearray[$key]['rowid']=0; // Should not happened |
368 | 395 | } |
@@ -387,22 +414,27 @@ discard block |
||
387 | 414 | |
388 | 415 | $sortorder=strtoupper($sortorder); |
389 | 416 | |
390 | - if ($sortorder == 'ASC') { $retup=-1; $retdown=1; } |
|
391 | - else { $retup=1; $retdown=-1; } |
|
417 | + if ($sortorder == 'ASC') { $retup=-1; $retdown=1; } else { $retup=1; $retdown=-1; } |
|
392 | 418 | |
393 | 419 | if ($sortfield == 'name') |
394 | 420 | { |
395 | - if ($a->name == $b->name) return 0; |
|
421 | + if ($a->name == $b->name) { |
|
422 | + return 0; |
|
423 | + } |
|
396 | 424 | return ($a->name < $b->name) ? $retup : $retdown; |
397 | 425 | } |
398 | 426 | if ($sortfield == 'date') |
399 | 427 | { |
400 | - if ($a->date == $b->date) return 0; |
|
428 | + if ($a->date == $b->date) { |
|
429 | + return 0; |
|
430 | + } |
|
401 | 431 | return ($a->date < $b->date) ? $retup : $retdown; |
402 | 432 | } |
403 | 433 | if ($sortfield == 'size') |
404 | 434 | { |
405 | - if ($a->size == $b->size) return 0; |
|
435 | + if ($a->size == $b->size) { |
|
436 | + return 0; |
|
437 | + } |
|
406 | 438 | return ($a->size < $b->size) ? $retup : $retdown; |
407 | 439 | } |
408 | 440 | } |
@@ -417,9 +449,12 @@ discard block |
||
417 | 449 | function dol_is_dir($folder) |
418 | 450 | { |
419 | 451 | $newfolder=dol_osencode($folder); |
420 | - if (is_dir($newfolder)) return true; |
|
421 | - else return false; |
|
422 | -} |
|
452 | + if (is_dir($newfolder)) { |
|
453 | + return true; |
|
454 | + } else { |
|
455 | + return false; |
|
456 | + } |
|
457 | + } |
|
423 | 458 | |
424 | 459 | /** |
425 | 460 | * Return if path is a file |
@@ -444,7 +479,9 @@ discard block |
||
444 | 479 | $tmpprot=array('file','http','https','ftp','zlib','data','ssh','ssh2','ogg','expect'); |
445 | 480 | foreach($tmpprot as $prot) |
446 | 481 | { |
447 | - if (preg_match('/^'.$prot.':/i',$url)) return true; |
|
482 | + if (preg_match('/^'.$prot.':/i',$url)) { |
|
483 | + return true; |
|
484 | + } |
|
448 | 485 | } |
449 | 486 | return false; |
450 | 487 | } |
@@ -466,15 +503,21 @@ discard block |
||
466 | 503 | { |
467 | 504 | $name_array[] = $name; |
468 | 505 | } |
469 | - foreach($name_array as $temp) $folder_content .= $temp; |
|
506 | + foreach($name_array as $temp) { |
|
507 | + $folder_content .= $temp; |
|
508 | + } |
|
470 | 509 | |
471 | 510 | closedir($handle); |
472 | 511 | |
473 | - if ($folder_content == "...") return true; |
|
474 | - else return false; |
|
512 | + if ($folder_content == "...") { |
|
513 | + return true; |
|
514 | + } else { |
|
515 | + return false; |
|
516 | + } |
|
517 | + } else { |
|
518 | + return true; |
|
475 | 519 | } |
476 | - else |
|
477 | - return true; // Dir does not exists |
|
520 | + // Dir does not exists |
|
478 | 521 | } |
479 | 522 | |
480 | 523 | /** |
@@ -497,11 +540,12 @@ discard block |
||
497 | 540 | { |
498 | 541 | $line=fgets($fp); |
499 | 542 | // 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. |
500 | - if (! $line === false) $nb++; |
|
543 | + if (! $line === false) { |
|
544 | + $nb++; |
|
545 | + } |
|
501 | 546 | } |
502 | 547 | fclose($fp); |
503 | - } |
|
504 | - else |
|
548 | + } else |
|
505 | 549 | { |
506 | 550 | $nb=-1; |
507 | 551 | } |
@@ -551,11 +595,17 @@ discard block |
||
551 | 595 | |
552 | 596 | dol_syslog("files.lib.php::dolReplaceInFile srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." indexdatabase=".$indexdatabase); |
553 | 597 | |
554 | - if (empty($srcfile)) return -1; |
|
555 | - if (empty($destfile)) $destfile=$srcfile; |
|
598 | + if (empty($srcfile)) { |
|
599 | + return -1; |
|
600 | + } |
|
601 | + if (empty($destfile)) { |
|
602 | + $destfile=$srcfile; |
|
603 | + } |
|
556 | 604 | |
557 | 605 | $destexists=dol_is_file($destfile); |
558 | - if (($destfile != $srcfile) && $destexists) return 0; |
|
606 | + if (($destfile != $srcfile) && $destexists) { |
|
607 | + return 0; |
|
608 | + } |
|
559 | 609 | |
560 | 610 | $tmpdestfile=$destfile.'.tmp'; |
561 | 611 | |
@@ -592,10 +642,14 @@ discard block |
||
592 | 642 | dol_syslog("files.lib.php::dolReplaceInFile failed to move tmp file to final dest", LOG_WARNING); |
593 | 643 | return -3; |
594 | 644 | } |
595 | - if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; |
|
596 | - if (empty($newmask)) // This should no happen |
|
645 | + if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) { |
|
646 | + $newmask=$conf->global->MAIN_UMASK; |
|
647 | + } |
|
648 | + if (empty($newmask)) { |
|
649 | + // This should no happen |
|
597 | 650 | { |
598 | 651 | dol_syslog("Warning: dolReplaceInFile called with empty value for newmask and no default value defined", LOG_WARNING); |
652 | + } |
|
599 | 653 | $newmask='0664'; |
600 | 654 | } |
601 | 655 | |
@@ -637,10 +691,14 @@ discard block |
||
637 | 691 | |
638 | 692 | dol_syslog("files.lib.php::dol_copy srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwriteifexists=".$overwriteifexists); |
639 | 693 | |
640 | - if (empty($srcfile) || empty($destfile)) return -1; |
|
694 | + if (empty($srcfile) || empty($destfile)) { |
|
695 | + return -1; |
|
696 | + } |
|
641 | 697 | |
642 | 698 | $destexists=dol_is_file($destfile); |
643 | - if (! $overwriteifexists && $destexists) return 0; |
|
699 | + if (! $overwriteifexists && $destexists) { |
|
700 | + return 0; |
|
701 | + } |
|
644 | 702 | |
645 | 703 | $newpathofsrcfile=dol_osencode($srcfile); |
646 | 704 | $newpathofdestfile=dol_osencode($destfile); |
@@ -664,10 +722,14 @@ discard block |
||
664 | 722 | dol_syslog("files.lib.php::dol_copy failed to copy", LOG_WARNING); |
665 | 723 | return -3; |
666 | 724 | } |
667 | - if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; |
|
668 | - if (empty($newmask)) // This should no happen |
|
725 | + if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) { |
|
726 | + $newmask=$conf->global->MAIN_UMASK; |
|
727 | + } |
|
728 | + if (empty($newmask)) { |
|
729 | + // This should no happen |
|
669 | 730 | { |
670 | 731 | dol_syslog("Warning: dol_copy called with empty value for newmask and no default value defined", LOG_WARNING); |
732 | + } |
|
671 | 733 | $newmask='0664'; |
672 | 734 | } |
673 | 735 | |
@@ -695,7 +757,9 @@ discard block |
||
695 | 757 | |
696 | 758 | dol_syslog("files.lib.php::dolCopyDir srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwriteifexists=".$overwriteifexists); |
697 | 759 | |
698 | - if (empty($srcfile) || empty($destfile)) return -1; |
|
760 | + if (empty($srcfile) || empty($destfile)) { |
|
761 | + return -1; |
|
762 | + } |
|
699 | 763 | |
700 | 764 | $destexists=dol_is_dir($destfile); |
701 | 765 | //if (! $overwriteifexists && $destexists) return 0; // The overwriteifexists is for files only, so propagated to dol_copy only. |
@@ -705,7 +769,9 @@ discard block |
||
705 | 769 | // We must set mask just before creating dir, becaause it can be set differently by dol_copy |
706 | 770 | umask(0); |
707 | 771 | $dirmaskdec=octdec($newmask); |
708 | - if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $dirmaskdec=octdec($conf->global->MAIN_UMASK); |
|
772 | + if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) { |
|
773 | + $dirmaskdec=octdec($conf->global->MAIN_UMASK); |
|
774 | + } |
|
709 | 775 | $dirmaskdec |= octdec('0200'); // Set w bit required to be able to create content for recursive subdirs files |
710 | 776 | dol_mkdir($destfile, '', decoct($dirmaskdec)); |
711 | 777 | } |
@@ -725,8 +791,7 @@ discard block |
||
725 | 791 | { |
726 | 792 | //var_dump("xxx dolCopyDir $srcfile/$file, $destfile/$file, $newmask, $overwriteifexists"); |
727 | 793 | $tmpresult=dolCopyDir($srcfile."/".$file, $destfile."/".$file, $newmask, $overwriteifexists, $arrayreplacement); |
728 | - } |
|
729 | - else |
|
794 | + } else |
|
730 | 795 | { |
731 | 796 | $newfile = $file; |
732 | 797 | // Replace destination filename with a new one |
@@ -743,18 +808,18 @@ discard block |
||
743 | 808 | if ($result > 0 && $tmpresult >= 0) |
744 | 809 | { |
745 | 810 | // Do nothing, so we don't set result to 0 if tmpresult is 0 and result was success in a previous pass |
746 | - } |
|
747 | - else |
|
811 | + } else |
|
748 | 812 | { |
749 | 813 | $result=$tmpresult; |
750 | 814 | } |
751 | - if ($result < 0) break; |
|
815 | + if ($result < 0) { |
|
816 | + break; |
|
817 | + } |
|
752 | 818 | |
753 | 819 | } |
754 | 820 | } |
755 | 821 | closedir($dir_handle); |
756 | - } |
|
757 | - else |
|
822 | + } else |
|
758 | 823 | { |
759 | 824 | // Source directory does not exists |
760 | 825 | $result = -2; |
@@ -821,8 +886,9 @@ discard block |
||
821 | 886 | // We force delete and try again. Rename function sometimes fails to replace dest file with some windows NTFS partitions. |
822 | 887 | dol_delete_file($destfile); |
823 | 888 | $result=@rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @ |
889 | + } else { |
|
890 | + dol_syslog("files.lib.php::dol_move Failed.", LOG_WARNING); |
|
824 | 891 | } |
825 | - else dol_syslog("files.lib.php::dol_move Failed.", LOG_WARNING); |
|
826 | 892 | } |
827 | 893 | |
828 | 894 | // Move ok |
@@ -831,9 +897,11 @@ discard block |
||
831 | 897 | // Rename entry into ecm database |
832 | 898 | $rel_filetorenamebefore = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $srcfile); |
833 | 899 | $rel_filetorenameafter = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $destfile); |
834 | - if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter)) // If not a tmp file |
|
900 | + if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter)) { |
|
901 | + // If not a tmp file |
|
835 | 902 | { |
836 | 903 | $rel_filetorenamebefore = preg_replace('/^[\\/]/', '', $rel_filetorenamebefore); |
904 | + } |
|
837 | 905 | $rel_filetorenameafter = preg_replace('/^[\\/]/', '', $rel_filetorenameafter); |
838 | 906 | //var_dump($rel_filetorenamebefore.' - '.$rel_filetorenameafter); |
839 | 907 | |
@@ -842,16 +910,20 @@ discard block |
||
842 | 910 | |
843 | 911 | $ecmfiletarget=new EcmFiles($db); |
844 | 912 | $resultecmtarget = $ecmfiletarget->fetch(0, '', $rel_filetorenameafter); |
845 | - if ($resultecmtarget > 0) // An entry for target name already exists for target, we delete it, a new one will be created. |
|
913 | + if ($resultecmtarget > 0) { |
|
914 | + // An entry for target name already exists for target, we delete it, a new one will be created. |
|
846 | 915 | { |
847 | 916 | $ecmfiletarget->delete($user); |
848 | 917 | } |
918 | + } |
|
849 | 919 | |
850 | 920 | $ecmfile=new EcmFiles($db); |
851 | 921 | $resultecm = $ecmfile->fetch(0, '', $rel_filetorenamebefore); |
852 | - if ($resultecm > 0) // If an entry was found for src file, we use it to move entry |
|
922 | + if ($resultecm > 0) { |
|
923 | + // If an entry was found for src file, we use it to move entry |
|
853 | 924 | { |
854 | 925 | $filename = basename($rel_filetorenameafter); |
926 | + } |
|
855 | 927 | $rel_dir = dirname($rel_filetorenameafter); |
856 | 928 | $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
857 | 929 | $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
@@ -859,10 +931,11 @@ discard block |
||
859 | 931 | $ecmfile->filepath = $rel_dir; |
860 | 932 | $ecmfile->filename = $filename; |
861 | 933 | $resultecm = $ecmfile->update($user); |
862 | - } |
|
863 | - elseif ($resultecm == 0) // If no entry were found for src files, create/update target file |
|
934 | + } elseif ($resultecm == 0) { |
|
935 | + // If no entry were found for src files, create/update target file |
|
864 | 936 | { |
865 | 937 | $filename = basename($rel_filetorenameafter); |
938 | + } |
|
866 | 939 | $rel_dir = dirname($rel_filetorenameafter); |
867 | 940 | $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
868 | 941 | $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
@@ -879,18 +952,22 @@ discard block |
||
879 | 952 | { |
880 | 953 | setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); |
881 | 954 | } |
882 | - } |
|
883 | - elseif ($resultecm < 0) |
|
955 | + } elseif ($resultecm < 0) |
|
884 | 956 | { |
885 | 957 | setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); |
886 | 958 | } |
887 | 959 | |
888 | - if ($resultecm > 0) $result=true; |
|
889 | - else $result = false; |
|
960 | + if ($resultecm > 0) { |
|
961 | + $result=true; |
|
962 | + } else { |
|
963 | + $result = false; |
|
964 | + } |
|
890 | 965 | } |
891 | 966 | } |
892 | 967 | |
893 | - if (empty($newmask)) $newmask=empty($conf->global->MAIN_UMASK)?'0755':$conf->global->MAIN_UMASK; |
|
968 | + if (empty($newmask)) { |
|
969 | + $newmask=empty($conf->global->MAIN_UMASK)?'0755':$conf->global->MAIN_UMASK; |
|
970 | + } |
|
894 | 971 | $newmaskdec=octdec($newmask); |
895 | 972 | // Currently method is restricted to files (dol_delete_files previously used is for files, and mask usage if for files too) |
896 | 973 | // to allow mask usage for dir, we shoul introduce a new param "isdir" to 1 to complete newmask like this |
@@ -934,9 +1011,11 @@ discard block |
||
934 | 1011 | } |
935 | 1012 | $antivir=new AntiVir($db); |
936 | 1013 | $result = $antivir->dol_avscan_file($src_file); |
937 | - if ($result < 0) // If virus or error, we stop here |
|
1014 | + if ($result < 0) { |
|
1015 | + // If virus or error, we stop here |
|
938 | 1016 | { |
939 | 1017 | $reterrors=$antivir->errors; |
1018 | + } |
|
940 | 1019 | return $reterrors; |
941 | 1020 | } |
942 | 1021 | } |
@@ -1044,13 +1123,17 @@ discard block |
||
1044 | 1123 | } |
1045 | 1124 | } |
1046 | 1125 | |
1047 | - if ($reshook < 0) // At least one blocking error returned by one hook |
|
1126 | + if ($reshook < 0) { |
|
1127 | + // At least one blocking error returned by one hook |
|
1048 | 1128 | { |
1049 | 1129 | $errmsg = join(',', $hookmanager->errors); |
1050 | - if (empty($errmsg)) $errmsg = 'ErrorReturnedBySomeHooks'; // Should not occurs. Added if hook is bugged and does not set ->errors when there is error. |
|
1051 | - return $errmsg; |
|
1052 | 1130 | } |
1053 | - elseif (empty($reshook)) |
|
1131 | + if (empty($errmsg)) { |
|
1132 | + $errmsg = 'ErrorReturnedBySomeHooks'; |
|
1133 | + } |
|
1134 | + // Should not occurs. Added if hook is bugged and does not set ->errors when there is error. |
|
1135 | + return $errmsg; |
|
1136 | + } elseif (empty($reshook)) |
|
1054 | 1137 | { |
1055 | 1138 | // The file functions must be in OS filesystem encoding. |
1056 | 1139 | $src_file_osencoded=dol_osencode($src_file); |
@@ -1077,11 +1160,12 @@ discard block |
||
1077 | 1160 | $return=move_uploaded_file($src_file_osencoded, $file_name_osencoded); |
1078 | 1161 | if ($return) |
1079 | 1162 | { |
1080 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($file_name_osencoded, octdec($conf->global->MAIN_UMASK)); |
|
1163 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
1164 | + @chmod($file_name_osencoded, octdec($conf->global->MAIN_UMASK)); |
|
1165 | + } |
|
1081 | 1166 | dol_syslog("Files.lib::dol_move_uploaded_file Success to move ".$src_file." to ".$file_name." - Umask=".$conf->global->MAIN_UMASK, LOG_DEBUG); |
1082 | 1167 | return 1; // Success |
1083 | - } |
|
1084 | - else |
|
1168 | + } else |
|
1085 | 1169 | { |
1086 | 1170 | dol_syslog("Files.lib::dol_move_uploaded_file Failed to move ".$src_file." to ".$file_name, LOG_ERR); |
1087 | 1171 | return -3; // Unknown error |
@@ -1134,12 +1218,13 @@ discard block |
||
1134 | 1218 | $reshook=$hookmanager->executeHooks('deleteFile', $parameters, $object); |
1135 | 1219 | } |
1136 | 1220 | |
1137 | - if (empty($nohook) && $reshook != 0) // reshook = 0 to do standard actions, 1 = ok, -1 = ko |
|
1221 | + if (empty($nohook) && $reshook != 0) { |
|
1222 | + // reshook = 0 to do standard actions, 1 = ok, -1 = ko |
|
1138 | 1223 | { |
1139 | 1224 | if ($reshook < 0) return false; |
1140 | - return true; |
|
1141 | 1225 | } |
1142 | - else |
|
1226 | + return true; |
|
1227 | + } else |
|
1143 | 1228 | { |
1144 | 1229 | $error=0; |
1145 | 1230 | |
@@ -1155,17 +1240,22 @@ discard block |
||
1155 | 1240 | { |
1156 | 1241 | foreach ($listofdir as $filename) |
1157 | 1242 | { |
1158 | - if ($nophperrors) $ok=@unlink($filename); |
|
1159 | - else $ok=unlink($filename); |
|
1243 | + if ($nophperrors) { |
|
1244 | + $ok=@unlink($filename); |
|
1245 | + } else { |
|
1246 | + $ok=unlink($filename); |
|
1247 | + } |
|
1160 | 1248 | if ($ok) |
1161 | 1249 | { |
1162 | 1250 | dol_syslog("Removed file ".$filename, LOG_DEBUG); |
1163 | 1251 | |
1164 | 1252 | // Delete entry into ecm database |
1165 | 1253 | $rel_filetodelete = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $filename); |
1166 | - if (! preg_match('/(\/temp\/|\/thumbs\/|\.meta$)/', $rel_filetodelete)) // If not a tmp file |
|
1254 | + if (! preg_match('/(\/temp\/|\/thumbs\/|\.meta$)/', $rel_filetodelete)) { |
|
1255 | + // If not a tmp file |
|
1167 | 1256 | { |
1168 | 1257 | $rel_filetodelete = preg_replace('/^[\\/]/', '', $rel_filetodelete); |
1258 | + } |
|
1169 | 1259 | |
1170 | 1260 | dol_syslog("Try to remove also entries in database for full relative path = ".$rel_filetodelete, LOG_DEBUG); |
1171 | 1261 | include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
@@ -1180,21 +1270,28 @@ discard block |
||
1180 | 1270 | setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); |
1181 | 1271 | } |
1182 | 1272 | } |
1273 | + } else { |
|
1274 | + dol_syslog("Failed to remove file ".$filename, LOG_WARNING); |
|
1183 | 1275 | } |
1184 | - else dol_syslog("Failed to remove file ".$filename, LOG_WARNING); |
|
1185 | 1276 | // TODO Failure to remove can be because file was already removed or because of permission |
1186 | 1277 | // If error because of not exists, we must should return true and we should return false if this is a permission problem |
1187 | 1278 | } |
1279 | + } else { |
|
1280 | + dol_syslog("No files to delete found", LOG_DEBUG); |
|
1188 | 1281 | } |
1189 | - else dol_syslog("No files to delete found", LOG_DEBUG); |
|
1190 | - } |
|
1191 | - else |
|
1282 | + } else |
|
1192 | 1283 | { |
1193 | 1284 | $ok=false; |
1194 | - if ($nophperrors) $ok=@unlink($file_osencoded); |
|
1195 | - else $ok=unlink($file_osencoded); |
|
1196 | - if ($ok) dol_syslog("Removed file ".$file_osencoded, LOG_DEBUG); |
|
1197 | - else dol_syslog("Failed to remove file ".$file_osencoded, LOG_WARNING); |
|
1285 | + if ($nophperrors) { |
|
1286 | + $ok=@unlink($file_osencoded); |
|
1287 | + } else { |
|
1288 | + $ok=unlink($file_osencoded); |
|
1289 | + } |
|
1290 | + if ($ok) { |
|
1291 | + dol_syslog("Removed file ".$file_osencoded, LOG_DEBUG); |
|
1292 | + } else { |
|
1293 | + dol_syslog("Failed to remove file ".$file_osencoded, LOG_WARNING); |
|
1294 | + } |
|
1198 | 1295 | } |
1199 | 1296 | |
1200 | 1297 | return $ok; |
@@ -1244,19 +1341,23 @@ discard block |
||
1244 | 1341 | { |
1245 | 1342 | while (false !== ($item = readdir($handle))) |
1246 | 1343 | { |
1247 | - if (! utf8_check($item)) $item=utf8_encode($item); // should be useless |
|
1344 | + if (! utf8_check($item)) { |
|
1345 | + $item=utf8_encode($item); |
|
1346 | + } |
|
1347 | + // should be useless |
|
1248 | 1348 | |
1249 | 1349 | if ($item != "." && $item != "..") |
1250 | 1350 | { |
1251 | 1351 | if (is_dir(dol_osencode("$dir/$item")) && ! is_link(dol_osencode("$dir/$item"))) |
1252 | 1352 | { |
1253 | 1353 | $count=dol_delete_dir_recursive("$dir/$item", $count, $nophperrors, 0, $countdeleted); |
1254 | - } |
|
1255 | - else |
|
1354 | + } else |
|
1256 | 1355 | { |
1257 | 1356 | $result=dol_delete_file("$dir/$item", 1, $nophperrors); |
1258 | 1357 | $count++; |
1259 | - if ($result) $countdeleted++; |
|
1358 | + if ($result) { |
|
1359 | + $countdeleted++; |
|
1360 | + } |
|
1260 | 1361 | } |
1261 | 1362 | } |
1262 | 1363 | } |
@@ -1266,7 +1367,9 @@ discard block |
||
1266 | 1367 | { |
1267 | 1368 | $result=dol_delete_dir($dir, $nophperrors); |
1268 | 1369 | $count++; |
1269 | - if ($result) $countdeleted++; |
|
1370 | + if ($result) { |
|
1371 | + $countdeleted++; |
|
1372 | + } |
|
1270 | 1373 | } |
1271 | 1374 | } |
1272 | 1375 | } |
@@ -1290,15 +1393,25 @@ discard block |
||
1290 | 1393 | // Define parent dir of elements |
1291 | 1394 | $element = $object->element; |
1292 | 1395 | |
1293 | - if ($object->element == 'order_supplier') $dir = $conf->fournisseur->commande->dir_output; |
|
1294 | - elseif ($object->element == 'invoice_supplier') $dir = $conf->fournisseur->facture->dir_output; |
|
1295 | - elseif ($object->element == 'project') $dir = $conf->projet->dir_output; |
|
1296 | - elseif ($object->element == 'shipping') $dir = $conf->expedition->dir_output.'/sending'; |
|
1297 | - elseif ($object->element == 'delivery') $dir = $conf->expedition->dir_output.'/receipt'; |
|
1298 | - elseif ($object->element == 'fichinter') $dir = $conf->ficheinter->dir_output; |
|
1299 | - else $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output; |
|
1396 | + if ($object->element == 'order_supplier') { |
|
1397 | + $dir = $conf->fournisseur->commande->dir_output; |
|
1398 | + } elseif ($object->element == 'invoice_supplier') { |
|
1399 | + $dir = $conf->fournisseur->facture->dir_output; |
|
1400 | + } elseif ($object->element == 'project') { |
|
1401 | + $dir = $conf->projet->dir_output; |
|
1402 | + } elseif ($object->element == 'shipping') { |
|
1403 | + $dir = $conf->expedition->dir_output.'/sending'; |
|
1404 | + } elseif ($object->element == 'delivery') { |
|
1405 | + $dir = $conf->expedition->dir_output.'/receipt'; |
|
1406 | + } elseif ($object->element == 'fichinter') { |
|
1407 | + $dir = $conf->ficheinter->dir_output; |
|
1408 | + } else { |
|
1409 | + $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output; |
|
1410 | + } |
|
1300 | 1411 | |
1301 | - if (empty($dir)) return 'ErrorObjectNoSupportedByFunction'; |
|
1412 | + if (empty($dir)) { |
|
1413 | + return 'ErrorObjectNoSupportedByFunction'; |
|
1414 | + } |
|
1302 | 1415 | |
1303 | 1416 | $refsan = dol_sanitizeFileName($object->ref); |
1304 | 1417 | $dir = $dir . "/" . $refsan ; |
@@ -1331,8 +1444,7 @@ discard block |
||
1331 | 1444 | $object->error=$langs->trans("ErrorFailedToDeleteFile",$filepreviewold); |
1332 | 1445 | return 0; |
1333 | 1446 | } |
1334 | - } |
|
1335 | - else |
|
1447 | + } else |
|
1336 | 1448 | { |
1337 | 1449 | $multiple = $filepreviewold . "."; |
1338 | 1450 | for ($i = 0; $i < 20; $i++) |
@@ -1366,18 +1478,29 @@ discard block |
||
1366 | 1478 | global $conf; |
1367 | 1479 | |
1368 | 1480 | // Create meta file |
1369 | - if (empty($conf->global->MAIN_DOC_CREATE_METAFILE)) return 0; // By default, no metafile. |
|
1481 | + if (empty($conf->global->MAIN_DOC_CREATE_METAFILE)) { |
|
1482 | + return 0; |
|
1483 | + } |
|
1484 | + // By default, no metafile. |
|
1370 | 1485 | |
1371 | 1486 | // Define parent dir of elements |
1372 | 1487 | $element=$object->element; |
1373 | 1488 | |
1374 | - if ($object->element == 'order_supplier') $dir = $conf->fournisseur->dir_output.'/commande'; |
|
1375 | - elseif ($object->element == 'invoice_supplier') $dir = $conf->fournisseur->dir_output.'/facture'; |
|
1376 | - elseif ($object->element == 'project') $dir = $conf->projet->dir_output; |
|
1377 | - elseif ($object->element == 'shipping') $dir = $conf->expedition->dir_output.'/sending'; |
|
1378 | - elseif ($object->element == 'delivery') $dir = $conf->expedition->dir_output.'/receipt'; |
|
1379 | - elseif ($object->element == 'fichinter') $dir = $conf->ficheinter->dir_output; |
|
1380 | - else $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output; |
|
1489 | + if ($object->element == 'order_supplier') { |
|
1490 | + $dir = $conf->fournisseur->dir_output.'/commande'; |
|
1491 | + } elseif ($object->element == 'invoice_supplier') { |
|
1492 | + $dir = $conf->fournisseur->dir_output.'/facture'; |
|
1493 | + } elseif ($object->element == 'project') { |
|
1494 | + $dir = $conf->projet->dir_output; |
|
1495 | + } elseif ($object->element == 'shipping') { |
|
1496 | + $dir = $conf->expedition->dir_output.'/sending'; |
|
1497 | + } elseif ($object->element == 'delivery') { |
|
1498 | + $dir = $conf->expedition->dir_output.'/receipt'; |
|
1499 | + } elseif ($object->element == 'fichinter') { |
|
1500 | + $dir = $conf->ficheinter->dir_output; |
|
1501 | + } else { |
|
1502 | + $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output; |
|
1503 | + } |
|
1381 | 1504 | |
1382 | 1505 | if ($dir) |
1383 | 1506 | { |
@@ -1417,12 +1540,12 @@ discard block |
||
1417 | 1540 | $fp = fopen($file,"w"); |
1418 | 1541 | fputs($fp,$meta); |
1419 | 1542 | fclose($fp); |
1420 | - if (! empty($conf->global->MAIN_UMASK)) |
|
1421 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
1543 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
1544 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
1545 | + } |
|
1422 | 1546 | |
1423 | 1547 | return 1; |
1424 | - } |
|
1425 | - else |
|
1548 | + } else |
|
1426 | 1549 | { |
1427 | 1550 | dol_syslog('FailedToDetectDirInDolMetaCreateFor'.$object->element, LOG_WARNING); |
1428 | 1551 | } |
@@ -1484,9 +1607,11 @@ discard block |
||
1484 | 1607 | |
1485 | 1608 | $res = 0; |
1486 | 1609 | |
1487 | - if (! empty($_FILES[$varfiles])) // For view $_FILES[$varfiles]['error'] |
|
1610 | + if (! empty($_FILES[$varfiles])) { |
|
1611 | + // For view $_FILES[$varfiles]['error'] |
|
1488 | 1612 | { |
1489 | 1613 | dol_syslog('dol_add_file_process upload_dir='.$upload_dir.' allowoverwrite='.$allowoverwrite.' donotupdatesession='.$donotupdatesession.' savingdocmask='.$savingdocmask, LOG_DEBUG); |
1614 | + } |
|
1490 | 1615 | if (dol_mkdir($upload_dir) >= 0) |
1491 | 1616 | { |
1492 | 1617 | $TFile = $_FILES[$varfiles]; |
@@ -1520,9 +1645,11 @@ discard block |
||
1520 | 1645 | |
1521 | 1646 | $resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destfull, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles); |
1522 | 1647 | |
1523 | - if (is_numeric($resupload) && $resupload > 0) // $resupload can be 'ErrorFileAlreadyExists' |
|
1648 | + if (is_numeric($resupload) && $resupload > 0) { |
|
1649 | + // $resupload can be 'ErrorFileAlreadyExists' |
|
1524 | 1650 | { |
1525 | 1651 | global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini; |
1652 | + } |
|
1526 | 1653 | |
1527 | 1654 | include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; |
1528 | 1655 | |
@@ -1562,19 +1689,20 @@ discard block |
||
1562 | 1689 | } |
1563 | 1690 | |
1564 | 1691 | $nbok++; |
1565 | - } |
|
1566 | - else |
|
1692 | + } else |
|
1567 | 1693 | { |
1568 | 1694 | $langs->load("errors"); |
1569 | - if ($resupload < 0) // Unknown error |
|
1695 | + if ($resupload < 0) { |
|
1696 | + // Unknown error |
|
1570 | 1697 | { |
1571 | 1698 | setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors'); |
1572 | 1699 | } |
1573 | - else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus |
|
1700 | + } else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) { |
|
1701 | + // Files infected by a virus |
|
1574 | 1702 | { |
1575 | 1703 | setEventMessages($langs->trans("ErrorFileIsInfectedWithAVirus"), null, 'errors'); |
1576 | 1704 | } |
1577 | - else // Known error |
|
1705 | + } else // Known error |
|
1578 | 1706 | { |
1579 | 1707 | setEventMessages($langs->trans($resupload), null, 'errors'); |
1580 | 1708 | } |
@@ -1601,8 +1729,7 @@ discard block |
||
1601 | 1729 | } else { |
1602 | 1730 | setEventMessages($langs->trans("ErrorFileNotLinked"), null, 'errors'); |
1603 | 1731 | } |
1604 | - } |
|
1605 | - else |
|
1732 | + } else |
|
1606 | 1733 | { |
1607 | 1734 | $langs->load("errors"); |
1608 | 1735 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("File")), null, 'errors'); |
@@ -1633,16 +1760,27 @@ discard block |
||
1633 | 1760 | $listofnames=array(); |
1634 | 1761 | $listofmimes=array(); |
1635 | 1762 | $keytoavoidconflict = empty($trackid)?'':'-'.$trackid; |
1636 | - if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]); |
|
1637 | - if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]); |
|
1638 | - if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]); |
|
1763 | + if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) { |
|
1764 | + $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]); |
|
1765 | + } |
|
1766 | + if (! empty($_SESSION["listofnames".$keytoavoidconflict])) { |
|
1767 | + $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]); |
|
1768 | + } |
|
1769 | + if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) { |
|
1770 | + $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]); |
|
1771 | + } |
|
1639 | 1772 | |
1640 | 1773 | if ($keytodelete >= 0) |
1641 | 1774 | { |
1642 | 1775 | $pathtodelete=$listofpaths[$keytodelete]; |
1643 | 1776 | $filetodelete=$listofnames[$keytodelete]; |
1644 | - if (empty($donotdeletefile)) $result = dol_delete_file($pathtodelete,1); // The delete of ecm database is inside the function dol_delete_file |
|
1645 | - else $result=0; |
|
1777 | + if (empty($donotdeletefile)) { |
|
1778 | + $result = dol_delete_file($pathtodelete,1); |
|
1779 | + } |
|
1780 | + // The delete of ecm database is inside the function dol_delete_file |
|
1781 | + else { |
|
1782 | + $result=0; |
|
1783 | + } |
|
1646 | 1784 | if ($result >= 0) |
1647 | 1785 | { |
1648 | 1786 | if (empty($donotdeletefile)) |
@@ -1682,9 +1820,11 @@ discard block |
||
1682 | 1820 | |
1683 | 1821 | $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $dir); |
1684 | 1822 | |
1685 | - if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir |
|
1823 | + if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) { |
|
1824 | + // If not a tmp dir |
|
1686 | 1825 | { |
1687 | 1826 | $filename = basename($file); |
1827 | + } |
|
1688 | 1828 | $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); |
1689 | 1829 | $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); |
1690 | 1830 | |
@@ -1747,8 +1887,12 @@ discard block |
||
1747 | 1887 | $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'ecm_files'; |
1748 | 1888 | $sql.= ' WHERE entity = '.$conf->entity; |
1749 | 1889 | $sql.= " AND filepath = '" . $db->escape($rel_dir) . "'"; |
1750 | - if ($file) $sql.= " AND filename = '" . $db->escape($file) . "'"; |
|
1751 | - if ($mode) $sql.= " AND gen_or_uploaded = '" . $db->escape($mode) . "'"; |
|
1890 | + if ($file) { |
|
1891 | + $sql.= " AND filename = '" . $db->escape($file) . "'"; |
|
1892 | + } |
|
1893 | + if ($mode) { |
|
1894 | + $sql.= " AND gen_or_uploaded = '" . $db->escape($mode) . "'"; |
|
1895 | + } |
|
1752 | 1896 | |
1753 | 1897 | $resql = $db->query($sql); |
1754 | 1898 | if (!$resql) |
@@ -1796,32 +1940,33 @@ discard block |
||
1796 | 1940 | $ret = $image->setImageFormat($ext); |
1797 | 1941 | if ($ret) |
1798 | 1942 | { |
1799 | - if (empty($fileoutput)) $fileoutput=$fileinput.".".$ext; |
|
1943 | + if (empty($fileoutput)) { |
|
1944 | + $fileoutput=$fileinput.".".$ext; |
|
1945 | + } |
|
1800 | 1946 | |
1801 | 1947 | $count = $image->getNumberImages(); |
1802 | 1948 | |
1803 | 1949 | if (! dol_is_file($fileoutput) || is_writeable($fileoutput)) |
1804 | 1950 | { |
1805 | 1951 | $ret = $image->writeImages($fileoutput, true); |
1806 | - } |
|
1807 | - else |
|
1952 | + } else |
|
1808 | 1953 | { |
1809 | 1954 | dol_syslog("Warning: Failed to write cache preview file '.$fileoutput.'. Check permission on file/dir", LOG_ERR); |
1810 | 1955 | } |
1811 | - if ($ret) return $count; |
|
1812 | - else return -3; |
|
1813 | - } |
|
1814 | - else |
|
1956 | + if ($ret) { |
|
1957 | + return $count; |
|
1958 | + } else { |
|
1959 | + return -3; |
|
1960 | + } |
|
1961 | + } else |
|
1815 | 1962 | { |
1816 | 1963 | return -2; |
1817 | 1964 | } |
1818 | - } |
|
1819 | - else |
|
1965 | + } else |
|
1820 | 1966 | { |
1821 | 1967 | return -1; |
1822 | 1968 | } |
1823 | - } |
|
1824 | - else |
|
1969 | + } else |
|
1825 | 1970 | { |
1826 | 1971 | return 0; |
1827 | 1972 | } |
@@ -1843,9 +1988,7 @@ discard block |
||
1843 | 1988 | try |
1844 | 1989 | { |
1845 | 1990 | $data = implode("", file(dol_osencode($inputfile))); |
1846 | - if ($mode == 'gz') { $foundhandler=1; $compressdata = gzencode($data, 9); } |
|
1847 | - elseif ($mode == 'bz') { $foundhandler=1; $compressdata = bzcompress($data, 9); } |
|
1848 | - elseif ($mode == 'zip') |
|
1991 | + if ($mode == 'gz') { $foundhandler=1; $compressdata = gzencode($data, 9); } elseif ($mode == 'bz') { $foundhandler=1; $compressdata = bzcompress($data, 9); } elseif ($mode == 'zip') |
|
1849 | 1992 | { |
1850 | 1993 | if (defined('ODTPHP_PATHTOPCLZIP')) |
1851 | 1994 | { |
@@ -1865,14 +2008,12 @@ discard block |
||
1865 | 2008 | fwrite($fp, $compressdata); |
1866 | 2009 | fclose($fp); |
1867 | 2010 | return 1; |
1868 | - } |
|
1869 | - else |
|
2011 | + } else |
|
1870 | 2012 | { |
1871 | 2013 | dol_syslog("Try to zip with format ".$mode." with no handler for this format",LOG_ERR); |
1872 | 2014 | return -2; |
1873 | 2015 | } |
1874 | - } |
|
1875 | - catch (Exception $e) |
|
2016 | + } catch (Exception $e) |
|
1876 | 2017 | { |
1877 | 2018 | global $langs, $errormsg; |
1878 | 2019 | $langs->load("errors"); |
@@ -1900,8 +2041,9 @@ discard block |
||
1900 | 2041 | $archive = new PclZip($inputfile); |
1901 | 2042 | $result=$archive->extract(PCLZIP_OPT_PATH, $outputdir); |
1902 | 2043 | //var_dump($result); |
1903 | - if (! is_array($result) && $result <= 0) return array('error'=>$archive->errorInfo(true)); |
|
1904 | - else |
|
2044 | + if (! is_array($result) && $result <= 0) { |
|
2045 | + return array('error'=>$archive->errorInfo(true)); |
|
2046 | + } else |
|
1905 | 2047 | { |
1906 | 2048 | $ok=1; $errmsg=''; |
1907 | 2049 | // Loop on each file to check result for unzipping file |
@@ -1916,8 +2058,11 @@ discard block |
||
1916 | 2058 | } |
1917 | 2059 | } |
1918 | 2060 | |
1919 | - if ($ok) return array(); |
|
1920 | - else return array('error'=>$errmsg); |
|
2061 | + if ($ok) { |
|
2062 | + return array(); |
|
2063 | + } else { |
|
2064 | + return array('error'=>$errmsg); |
|
2065 | + } |
|
1921 | 2066 | } |
1922 | 2067 | } |
1923 | 2068 | |
@@ -1931,8 +2076,7 @@ discard block |
||
1931 | 2076 | $zip->extractTo($outputdir.'/'); |
1932 | 2077 | $zip->close(); |
1933 | 2078 | return array(); |
1934 | - } |
|
1935 | - else |
|
2079 | + } else |
|
1936 | 2080 | { |
1937 | 2081 | return array('error'=>'ErrUnzipFails'); |
1938 | 2082 | } |
@@ -1966,9 +2110,7 @@ discard block |
||
1966 | 2110 | |
1967 | 2111 | try |
1968 | 2112 | { |
1969 | - if ($mode == 'gz') { $foundhandler=0; } |
|
1970 | - elseif ($mode == 'bz') { $foundhandler=0; } |
|
1971 | - elseif ($mode == 'zip') |
|
2113 | + if ($mode == 'gz') { $foundhandler=0; } elseif ($mode == 'bz') { $foundhandler=0; } elseif ($mode == 'zip') |
|
1972 | 2114 | { |
1973 | 2115 | /*if (defined('ODTPHP_PATHTOPCLZIP')) |
1974 | 2116 | { |
@@ -2021,13 +2163,11 @@ discard block |
||
2021 | 2163 | { |
2022 | 2164 | dol_syslog("Try to zip with format ".$mode." with no handler for this format",LOG_ERR); |
2023 | 2165 | return -2; |
2024 | - } |
|
2025 | - else |
|
2166 | + } else |
|
2026 | 2167 | { |
2027 | 2168 | return 0; |
2028 | 2169 | } |
2029 | - } |
|
2030 | - catch (Exception $e) |
|
2170 | + } catch (Exception $e) |
|
2031 | 2171 | { |
2032 | 2172 | global $langs, $errormsg; |
2033 | 2173 | $langs->load("errors"); |
@@ -2073,13 +2213,20 @@ discard block |
||
2073 | 2213 | global $conf, $db, $user; |
2074 | 2214 | global $dolibarr_main_data_root, $dolibarr_main_document_root_alt; |
2075 | 2215 | |
2076 | - if (! is_object($fuser)) $fuser=$user; |
|
2216 | + if (! is_object($fuser)) { |
|
2217 | + $fuser=$user; |
|
2218 | + } |
|
2077 | 2219 | |
2078 | - if (empty($modulepart)) return 'ErrorBadParameter'; |
|
2220 | + if (empty($modulepart)) { |
|
2221 | + return 'ErrorBadParameter'; |
|
2222 | + } |
|
2079 | 2223 | if (empty($entity)) |
2080 | 2224 | { |
2081 | - if (empty($conf->multicompany->enabled)) $entity=1; |
|
2082 | - else $entity=0; |
|
2225 | + if (empty($conf->multicompany->enabled)) { |
|
2226 | + $entity=1; |
|
2227 | + } else { |
|
2228 | + $entity=0; |
|
2229 | + } |
|
2083 | 2230 | } |
2084 | 2231 | dol_syslog('modulepart='.$modulepart.' original_file='.$original_file.' entity='.$entity); |
2085 | 2232 | // We define $accessallowed and $sqlprotectagainstexternals |
@@ -2088,7 +2235,9 @@ discard block |
||
2088 | 2235 | $ret=array(); |
2089 | 2236 | |
2090 | 2237 | // Find the subdirectory name as the reference. For exemple original_file='10/myfile.pdf' -> refname='10' |
2091 | - if (empty($refname)) $refname=basename(dirname($original_file)."/"); |
|
2238 | + if (empty($refname)) { |
|
2239 | + $refname=basename(dirname($original_file)."/"); |
|
2240 | + } |
|
2092 | 2241 | |
2093 | 2242 | $relative_original_file = $original_file; |
2094 | 2243 | |
@@ -2102,7 +2251,9 @@ discard block |
||
2102 | 2251 | // Wrapping for miscellaneous medias files |
2103 | 2252 | if ($modulepart == 'medias' && !empty($dolibarr_main_data_root)) |
2104 | 2253 | { |
2105 | - if (empty($entity) || empty($conf->medias->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); |
|
2254 | + if (empty($entity) || empty($conf->medias->multidir_output[$entity])) { |
|
2255 | + return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); |
|
2256 | + } |
|
2106 | 2257 | $accessallowed=1; |
2107 | 2258 | $original_file=$conf->medias->multidir_output[$entity].'/'.$original_file; |
2108 | 2259 | } |
@@ -2143,132 +2294,176 @@ discard block |
||
2143 | 2294 | // Wrapping pour les apercu factures |
2144 | 2295 | elseif ($modulepart == 'apercufacture' && !empty($conf->facture->dir_output)) |
2145 | 2296 | { |
2146 | - if ($fuser->rights->facture->{$lire}) $accessallowed=1; |
|
2297 | + if ($fuser->rights->facture->{$lire}) { |
|
2298 | + $accessallowed=1; |
|
2299 | + } |
|
2147 | 2300 | $original_file=$conf->facture->dir_output.'/'.$original_file; |
2148 | 2301 | } |
2149 | 2302 | // Wrapping pour les apercu propal |
2150 | 2303 | elseif ($modulepart == 'apercupropal' && !empty($conf->propal->dir_output)) |
2151 | 2304 | { |
2152 | - if ($fuser->rights->propale->{$lire}) $accessallowed=1; |
|
2305 | + if ($fuser->rights->propale->{$lire}) { |
|
2306 | + $accessallowed=1; |
|
2307 | + } |
|
2153 | 2308 | $original_file=$conf->propal->dir_output.'/'.$original_file; |
2154 | 2309 | } |
2155 | 2310 | // Wrapping pour les apercu commande |
2156 | 2311 | elseif ($modulepart == 'apercucommande' && !empty($conf->commande->dir_output)) |
2157 | 2312 | { |
2158 | - if ($fuser->rights->commande->{$lire}) $accessallowed=1; |
|
2313 | + if ($fuser->rights->commande->{$lire}) { |
|
2314 | + $accessallowed=1; |
|
2315 | + } |
|
2159 | 2316 | $original_file=$conf->commande->dir_output.'/'.$original_file; |
2160 | 2317 | } |
2161 | 2318 | // Wrapping pour les apercu intervention |
2162 | 2319 | elseif (($modulepart == 'apercufichinter' || $modulepart == 'apercuficheinter') && !empty($conf->ficheinter->dir_output)) |
2163 | 2320 | { |
2164 | - if ($fuser->rights->ficheinter->{$lire}) $accessallowed=1; |
|
2321 | + if ($fuser->rights->ficheinter->{$lire}) { |
|
2322 | + $accessallowed=1; |
|
2323 | + } |
|
2165 | 2324 | $original_file=$conf->ficheinter->dir_output.'/'.$original_file; |
2166 | 2325 | } |
2167 | 2326 | // Wrapping pour les apercu conat |
2168 | 2327 | elseif (($modulepart == 'apercucontract') && !empty($conf->contrat->dir_output)) |
2169 | 2328 | { |
2170 | - if ($fuser->rights->contrat->{$lire}) $accessallowed=1; |
|
2329 | + if ($fuser->rights->contrat->{$lire}) { |
|
2330 | + $accessallowed=1; |
|
2331 | + } |
|
2171 | 2332 | $original_file=$conf->contrat->dir_output.'/'.$original_file; |
2172 | 2333 | } |
2173 | 2334 | // Wrapping pour les apercu supplier proposal |
2174 | 2335 | elseif (($modulepart == 'apercusupplier_proposal' || $modulepart == 'apercusupplier_proposal') && !empty($conf->supplier_proposal->dir_output)) |
2175 | 2336 | { |
2176 | - if ($fuser->rights->supplier_proposal->{$lire}) $accessallowed=1; |
|
2337 | + if ($fuser->rights->supplier_proposal->{$lire}) { |
|
2338 | + $accessallowed=1; |
|
2339 | + } |
|
2177 | 2340 | $original_file=$conf->supplier_proposal->dir_output.'/'.$original_file; |
2178 | 2341 | } |
2179 | 2342 | // Wrapping pour les apercu supplier order |
2180 | 2343 | elseif (($modulepart == 'apercusupplier_order' || $modulepart == 'apercusupplier_order') && !empty($conf->fournisseur->commande->dir_output)) |
2181 | 2344 | { |
2182 | - if ($fuser->rights->fournisseur->commande->{$lire}) $accessallowed=1; |
|
2345 | + if ($fuser->rights->fournisseur->commande->{$lire}) { |
|
2346 | + $accessallowed=1; |
|
2347 | + } |
|
2183 | 2348 | $original_file=$conf->fournisseur->commande->dir_output.'/'.$original_file; |
2184 | 2349 | } |
2185 | 2350 | // Wrapping pour les apercu supplier invoice |
2186 | 2351 | elseif (($modulepart == 'apercusupplier_invoice' || $modulepart == 'apercusupplier_invoice') && !empty($conf->fournisseur->facture->dir_output)) |
2187 | 2352 | { |
2188 | - if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed=1; |
|
2353 | + if ($fuser->rights->fournisseur->facture->{$lire}) { |
|
2354 | + $accessallowed=1; |
|
2355 | + } |
|
2189 | 2356 | $original_file=$conf->fournisseur->facture->dir_output.'/'.$original_file; |
2190 | 2357 | } |
2191 | 2358 | // Wrapping pour les apercu supplier invoice |
2192 | 2359 | elseif (($modulepart == 'apercuexpensereport') && !empty($conf->expensereport->dir_output)) |
2193 | 2360 | { |
2194 | - if ($fuser->rights->expensereport->{$lire}) $accessallowed=1; |
|
2361 | + if ($fuser->rights->expensereport->{$lire}) { |
|
2362 | + $accessallowed=1; |
|
2363 | + } |
|
2195 | 2364 | $original_file=$conf->expensereport->dir_output.'/'.$original_file; |
2196 | 2365 | } |
2197 | 2366 | // Wrapping pour les images des stats propales |
2198 | 2367 | elseif ($modulepart == 'propalstats' && !empty($conf->propal->dir_temp)) |
2199 | 2368 | { |
2200 | - if ($fuser->rights->propale->{$lire}) $accessallowed=1; |
|
2369 | + if ($fuser->rights->propale->{$lire}) { |
|
2370 | + $accessallowed=1; |
|
2371 | + } |
|
2201 | 2372 | $original_file=$conf->propal->dir_temp.'/'.$original_file; |
2202 | 2373 | } |
2203 | 2374 | // Wrapping pour les images des stats commandes |
2204 | 2375 | elseif ($modulepart == 'orderstats' && !empty($conf->commande->dir_temp)) |
2205 | 2376 | { |
2206 | - if ($fuser->rights->commande->{$lire}) $accessallowed=1; |
|
2377 | + if ($fuser->rights->commande->{$lire}) { |
|
2378 | + $accessallowed=1; |
|
2379 | + } |
|
2207 | 2380 | $original_file=$conf->commande->dir_temp.'/'.$original_file; |
2208 | - } |
|
2209 | - elseif ($modulepart == 'orderstatssupplier' && !empty($conf->fournisseur->dir_output)) |
|
2381 | + } elseif ($modulepart == 'orderstatssupplier' && !empty($conf->fournisseur->dir_output)) |
|
2210 | 2382 | { |
2211 | - if ($fuser->rights->fournisseur->commande->{$lire}) $accessallowed=1; |
|
2383 | + if ($fuser->rights->fournisseur->commande->{$lire}) { |
|
2384 | + $accessallowed=1; |
|
2385 | + } |
|
2212 | 2386 | $original_file=$conf->fournisseur->commande->dir_temp.'/'.$original_file; |
2213 | 2387 | } |
2214 | 2388 | // Wrapping pour les images des stats factures |
2215 | 2389 | elseif ($modulepart == 'billstats' && !empty($conf->facture->dir_temp)) |
2216 | 2390 | { |
2217 | - if ($fuser->rights->facture->{$lire}) $accessallowed=1; |
|
2391 | + if ($fuser->rights->facture->{$lire}) { |
|
2392 | + $accessallowed=1; |
|
2393 | + } |
|
2218 | 2394 | $original_file=$conf->facture->dir_temp.'/'.$original_file; |
2219 | - } |
|
2220 | - elseif ($modulepart == 'billstatssupplier' && !empty($conf->fournisseur->dir_output)) |
|
2395 | + } elseif ($modulepart == 'billstatssupplier' && !empty($conf->fournisseur->dir_output)) |
|
2221 | 2396 | { |
2222 | - if ($fuser->rights->fournisseur->facture->{$lire}) $accessallowed=1; |
|
2397 | + if ($fuser->rights->fournisseur->facture->{$lire}) { |
|
2398 | + $accessallowed=1; |
|
2399 | + } |
|
2223 | 2400 | $original_file=$conf->fournisseur->facture->dir_temp.'/'.$original_file; |
2224 | 2401 | } |
2225 | 2402 | // Wrapping pour les images des stats expeditions |
2226 | 2403 | elseif ($modulepart == 'expeditionstats' && !empty($conf->expedition->dir_temp)) |
2227 | 2404 | { |
2228 | - if ($fuser->rights->expedition->{$lire}) $accessallowed=1; |
|
2405 | + if ($fuser->rights->expedition->{$lire}) { |
|
2406 | + $accessallowed=1; |
|
2407 | + } |
|
2229 | 2408 | $original_file=$conf->expedition->dir_temp.'/'.$original_file; |
2230 | 2409 | } |
2231 | 2410 | // Wrapping pour les images des stats expeditions |
2232 | 2411 | elseif ($modulepart == 'tripsexpensesstats' && !empty($conf->deplacement->dir_temp)) |
2233 | 2412 | { |
2234 | - if ($fuser->rights->deplacement->{$lire}) $accessallowed=1; |
|
2413 | + if ($fuser->rights->deplacement->{$lire}) { |
|
2414 | + $accessallowed=1; |
|
2415 | + } |
|
2235 | 2416 | $original_file=$conf->deplacement->dir_temp.'/'.$original_file; |
2236 | 2417 | } |
2237 | 2418 | // Wrapping pour les images des stats expeditions |
2238 | 2419 | elseif ($modulepart == 'memberstats' && !empty($conf->adherent->dir_temp)) |
2239 | 2420 | { |
2240 | - if ($fuser->rights->adherent->{$lire}) $accessallowed=1; |
|
2421 | + if ($fuser->rights->adherent->{$lire}) { |
|
2422 | + $accessallowed=1; |
|
2423 | + } |
|
2241 | 2424 | $original_file=$conf->adherent->dir_temp.'/'.$original_file; |
2242 | 2425 | } |
2243 | 2426 | // Wrapping pour les images des stats produits |
2244 | 2427 | elseif (preg_match('/^productstats_/i',$modulepart) && !empty($conf->product->dir_temp)) |
2245 | 2428 | { |
2246 | - if ($fuser->rights->produit->{$lire} || $fuser->rights->service->{$lire}) $accessallowed=1; |
|
2429 | + if ($fuser->rights->produit->{$lire} || $fuser->rights->service->{$lire}) { |
|
2430 | + $accessallowed=1; |
|
2431 | + } |
|
2247 | 2432 | $original_file=(!empty($conf->product->multidir_temp[$entity])?$conf->product->multidir_temp[$entity]:$conf->service->multidir_temp[$entity]).'/'.$original_file; |
2248 | 2433 | } |
2249 | 2434 | // Wrapping for taxes |
2250 | 2435 | elseif ($modulepart == 'tax' && !empty($conf->tax->dir_output)) |
2251 | 2436 | { |
2252 | - if ($fuser->rights->tax->charges->{$lire}) $accessallowed=1; |
|
2437 | + if ($fuser->rights->tax->charges->{$lire}) { |
|
2438 | + $accessallowed=1; |
|
2439 | + } |
|
2253 | 2440 | $original_file=$conf->tax->dir_output.'/'.$original_file; |
2254 | 2441 | } |
2255 | 2442 | // Wrapping for events |
2256 | 2443 | elseif ($modulepart == 'actions' && !empty($conf->agenda->dir_output)) |
2257 | 2444 | { |
2258 | - if ($fuser->rights->agenda->myactions->{$read}) $accessallowed=1; |
|
2445 | + if ($fuser->rights->agenda->myactions->{$read}) { |
|
2446 | + $accessallowed=1; |
|
2447 | + } |
|
2259 | 2448 | $original_file=$conf->agenda->dir_output.'/'.$original_file; |
2260 | 2449 | } |
2261 | 2450 | // Wrapping for categories |
2262 | 2451 | elseif ($modulepart == 'category' && !empty($conf->categorie->dir_output)) |
2263 | 2452 | { |
2264 | - if (empty($entity) || empty($conf->categorie->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); |
|
2265 | - if ($fuser->rights->categorie->{$lire}) $accessallowed=1; |
|
2453 | + if (empty($entity) || empty($conf->categorie->multidir_output[$entity])) { |
|
2454 | + return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); |
|
2455 | + } |
|
2456 | + if ($fuser->rights->categorie->{$lire}) { |
|
2457 | + $accessallowed=1; |
|
2458 | + } |
|
2266 | 2459 | $original_file=$conf->categorie->multidir_output[$entity].'/'.$original_file; |
2267 | 2460 | } |
2268 | 2461 | // Wrapping pour les prelevements |
2269 | 2462 | elseif ($modulepart == 'prelevement' && !empty($conf->prelevement->dir_output)) |
2270 | 2463 | { |
2271 | - if ($fuser->rights->prelevement->bons->{$lire} || preg_match('/^specimen/i',$original_file)) $accessallowed=1; |
|
2464 | + if ($fuser->rights->prelevement->bons->{$lire} || preg_match('/^specimen/i',$original_file)) { |
|
2465 | + $accessallowed=1; |
|
2466 | + } |
|
2272 | 2467 | $original_file=$conf->prelevement->dir_output.'/'.$original_file; |
2273 | 2468 | } |
2274 | 2469 | // Wrapping pour les graph energie |
@@ -2331,7 +2526,9 @@ discard block |
||
2331 | 2526 | // Wrapping for third parties |
2332 | 2527 | else if (($modulepart == 'company' || $modulepart == 'societe') && !empty($conf->societe->dir_output)) |
2333 | 2528 | { |
2334 | - if (empty($entity) || empty($conf->societe->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); |
|
2529 | + if (empty($entity) || empty($conf->societe->multidir_output[$entity])) { |
|
2530 | + return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); |
|
2531 | + } |
|
2335 | 2532 | if ($fuser->rights->societe->{$lire} || preg_match('/^specimen/i',$original_file)) |
2336 | 2533 | { |
2337 | 2534 | $accessallowed=1; |
@@ -2343,7 +2540,9 @@ discard block |
||
2343 | 2540 | // Wrapping for contact |
2344 | 2541 | else if ($modulepart == 'contact' && !empty($conf->societe->dir_output)) |
2345 | 2542 | { |
2346 | - if (empty($entity) || empty($conf->societe->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); |
|
2543 | + if (empty($entity) || empty($conf->societe->multidir_output[$entity])) { |
|
2544 | + return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); |
|
2545 | + } |
|
2347 | 2546 | if ($fuser->rights->societe->{$lire}) |
2348 | 2547 | { |
2349 | 2548 | $accessallowed=1; |
@@ -2369,64 +2568,56 @@ discard block |
||
2369 | 2568 | $accessallowed=1; |
2370 | 2569 | } |
2371 | 2570 | $original_file=$conf->propal->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; |
2372 | - } |
|
2373 | - else if ($modulepart == 'massfilesarea_orders') |
|
2571 | + } else if ($modulepart == 'massfilesarea_orders') |
|
2374 | 2572 | { |
2375 | 2573 | if ($fuser->rights->commande->{$lire} || preg_match('/^specimen/i',$original_file)) |
2376 | 2574 | { |
2377 | 2575 | $accessallowed=1; |
2378 | 2576 | } |
2379 | 2577 | $original_file=$conf->commande->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; |
2380 | - } |
|
2381 | - else if ($modulepart == 'massfilesarea_invoices') |
|
2578 | + } else if ($modulepart == 'massfilesarea_invoices') |
|
2382 | 2579 | { |
2383 | 2580 | if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i',$original_file)) |
2384 | 2581 | { |
2385 | 2582 | $accessallowed=1; |
2386 | 2583 | } |
2387 | 2584 | $original_file=$conf->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; |
2388 | - } |
|
2389 | - else if ($modulepart == 'massfilesarea_expensereport') |
|
2585 | + } else if ($modulepart == 'massfilesarea_expensereport') |
|
2390 | 2586 | { |
2391 | 2587 | if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i',$original_file)) |
2392 | 2588 | { |
2393 | 2589 | $accessallowed=1; |
2394 | 2590 | } |
2395 | 2591 | $original_file=$conf->expensereport->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; |
2396 | - } |
|
2397 | - else if ($modulepart == 'massfilesarea_interventions') |
|
2592 | + } else if ($modulepart == 'massfilesarea_interventions') |
|
2398 | 2593 | { |
2399 | 2594 | if ($fuser->rights->ficheinter->{$lire} || preg_match('/^specimen/i',$original_file)) |
2400 | 2595 | { |
2401 | 2596 | $accessallowed=1; |
2402 | 2597 | } |
2403 | 2598 | $original_file=$conf->ficheinter->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; |
2404 | - } |
|
2405 | - else if ($modulepart == 'massfilesarea_supplier_proposal' && !empty($conf->propal->dir_output)) |
|
2599 | + } else if ($modulepart == 'massfilesarea_supplier_proposal' && !empty($conf->propal->dir_output)) |
|
2406 | 2600 | { |
2407 | 2601 | if ($fuser->rights->supplier_proposal->{$lire} || preg_match('/^specimen/i',$original_file)) |
2408 | 2602 | { |
2409 | 2603 | $accessallowed=1; |
2410 | 2604 | } |
2411 | 2605 | $original_file=$conf->supplier_proposal->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; |
2412 | - } |
|
2413 | - else if ($modulepart == 'massfilesarea_supplier_order') |
|
2606 | + } else if ($modulepart == 'massfilesarea_supplier_order') |
|
2414 | 2607 | { |
2415 | 2608 | if ($fuser->rights->fournisseur->commande->{$lire} || preg_match('/^specimen/i',$original_file)) |
2416 | 2609 | { |
2417 | 2610 | $accessallowed=1; |
2418 | 2611 | } |
2419 | 2612 | $original_file=$conf->fournisseur->commande->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; |
2420 | - } |
|
2421 | - else if ($modulepart == 'massfilesarea_supplier_invoice') |
|
2613 | + } else if ($modulepart == 'massfilesarea_supplier_invoice') |
|
2422 | 2614 | { |
2423 | 2615 | if ($fuser->rights->fournisseur->facture->{$lire} || preg_match('/^specimen/i',$original_file)) |
2424 | 2616 | { |
2425 | 2617 | $accessallowed=1; |
2426 | 2618 | } |
2427 | 2619 | $original_file=$conf->fournisseur->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; |
2428 | - } |
|
2429 | - else if ($modulepart == 'massfilesarea_contract' && !empty($conf->contrat->dir_output)) |
|
2620 | + } else if ($modulepart == 'massfilesarea_contract' && !empty($conf->contrat->dir_output)) |
|
2430 | 2621 | { |
2431 | 2622 | if ($fuser->rights->contrat->{$lire} || preg_match('/^specimen/i',$original_file)) |
2432 | 2623 | { |
@@ -2488,8 +2679,7 @@ discard block |
||
2488 | 2679 | } |
2489 | 2680 | $original_file=$conf->projet->dir_output.'/'.$original_file; |
2490 | 2681 | $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('project').")"; |
2491 | - } |
|
2492 | - else if ($modulepart == 'project_task' && !empty($conf->projet->dir_output)) |
|
2682 | + } else if ($modulepart == 'project_task' && !empty($conf->projet->dir_output)) |
|
2493 | 2683 | { |
2494 | 2684 | if ($fuser->rights->projet->{$lire} || preg_match('/^specimen/i',$original_file)) |
2495 | 2685 | { |
@@ -2538,8 +2728,11 @@ discard block |
||
2538 | 2728 | { |
2539 | 2729 | $accessallowed=1; |
2540 | 2730 | } |
2541 | - if ($fuser->societe_id > 0) $original_file=$conf->facture->dir_output.'/payments/private/'.$fuser->id.'/'.$original_file; |
|
2542 | - else $original_file=$conf->facture->dir_output.'/payments/'.$original_file; |
|
2731 | + if ($fuser->societe_id > 0) { |
|
2732 | + $original_file=$conf->facture->dir_output.'/payments/private/'.$fuser->id.'/'.$original_file; |
|
2733 | + } else { |
|
2734 | + $original_file=$conf->facture->dir_output.'/payments/'.$original_file; |
|
2735 | + } |
|
2543 | 2736 | } |
2544 | 2737 | |
2545 | 2738 | // Wrapping for accounting exports |
@@ -2594,13 +2787,18 @@ discard block |
||
2594 | 2787 | // Wrapping pour les produits et services |
2595 | 2788 | else if ($modulepart == 'product' || $modulepart == 'produit' || $modulepart == 'service' || $modulepart == 'produit|service') |
2596 | 2789 | { |
2597 | - 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'); |
|
2790 | + if (empty($entity) || (empty($conf->product->multidir_output[$entity]) && empty($conf->service->multidir_output[$entity]))) { |
|
2791 | + return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); |
|
2792 | + } |
|
2598 | 2793 | if (($fuser->rights->produit->{$lire} || $fuser->rights->service->{$lire}) || preg_match('/^specimen/i',$original_file)) |
2599 | 2794 | { |
2600 | 2795 | $accessallowed=1; |
2601 | 2796 | } |
2602 | - if (! empty($conf->product->enabled)) $original_file=$conf->product->multidir_output[$entity].'/'.$original_file; |
|
2603 | - elseif (! empty($conf->service->enabled)) $original_file=$conf->service->multidir_output[$entity].'/'.$original_file; |
|
2797 | + if (! empty($conf->product->enabled)) { |
|
2798 | + $original_file=$conf->product->multidir_output[$entity].'/'.$original_file; |
|
2799 | + } elseif (! empty($conf->service->enabled)) { |
|
2800 | + $original_file=$conf->service->multidir_output[$entity].'/'.$original_file; |
|
2801 | + } |
|
2604 | 2802 | } |
2605 | 2803 | |
2606 | 2804 | // Wrapping pour les contrats |
@@ -2681,14 +2879,18 @@ discard block |
||
2681 | 2879 | // Wrapping for backups |
2682 | 2880 | else if ($modulepart == 'systemtools' && !empty($conf->admin->dir_output)) |
2683 | 2881 | { |
2684 | - if ($fuser->admin) $accessallowed=1; |
|
2882 | + if ($fuser->admin) { |
|
2883 | + $accessallowed=1; |
|
2884 | + } |
|
2685 | 2885 | $original_file=$conf->admin->dir_output.'/'.$original_file; |
2686 | 2886 | } |
2687 | 2887 | |
2688 | 2888 | // Wrapping for upload file test |
2689 | 2889 | else if ($modulepart == 'admin_temp' && !empty($conf->admin->dir_temp)) |
2690 | 2890 | { |
2691 | - if ($fuser->admin) $accessallowed=1; |
|
2891 | + if ($fuser->admin) { |
|
2892 | + $accessallowed=1; |
|
2893 | + } |
|
2692 | 2894 | $original_file=$conf->admin->dir_temp.'/'.$original_file; |
2693 | 2895 | } |
2694 | 2896 | |
@@ -2697,7 +2899,9 @@ discard block |
||
2697 | 2899 | { |
2698 | 2900 | $accessallowed=1; |
2699 | 2901 | $dir='files'; |
2700 | - if (dol_mimetype($original_file) == 'application/x-bittorrent') $dir='torrents'; |
|
2902 | + if (dol_mimetype($original_file) == 'application/x-bittorrent') { |
|
2903 | + $dir='torrents'; |
|
2904 | + } |
|
2701 | 2905 | $original_file=$conf->bittorrent->dir_output.'/'.$dir.'/'.$original_file; |
2702 | 2906 | } |
2703 | 2907 | |
@@ -2725,45 +2929,62 @@ discard block |
||
2725 | 2929 | // If modulepart=module Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart |
2726 | 2930 | else |
2727 | 2931 | { |
2728 | - 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. |
|
2729 | - if ($fuser->admin) $accessallowed=1; // If user is admin |
|
2932 | + if (preg_match('/^specimen/i',$original_file)) { |
|
2933 | + $accessallowed=1; |
|
2934 | + } |
|
2935 | + // If link to a file called specimen. Test must be done before changing $original_file int full path. |
|
2936 | + if ($fuser->admin) { |
|
2937 | + $accessallowed=1; |
|
2938 | + } |
|
2939 | + // If user is admin |
|
2730 | 2940 | |
2731 | 2941 | // Define $accessallowed |
2732 | 2942 | if (preg_match('/^([a-z]+)_user_temp$/i',$modulepart,$reg)) |
2733 | 2943 | { |
2734 | - if (empty($conf->{$reg[1]}->dir_temp)) // modulepart not supported |
|
2944 | + if (empty($conf->{$reg[1]}->dir_temp)) { |
|
2945 | + // modulepart not supported |
|
2735 | 2946 | { |
2736 | 2947 | dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')'); |
2948 | + } |
|
2737 | 2949 | exit; |
2738 | 2950 | } |
2739 | - if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1; |
|
2951 | + if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) { |
|
2952 | + $accessallowed=1; |
|
2953 | + } |
|
2740 | 2954 | $original_file=$conf->{$reg[1]}->dir_temp.'/'.$fuser->id.'/'.$original_file; |
2741 | - } |
|
2742 | - else if (preg_match('/^([a-z]+)_temp$/i',$modulepart,$reg)) |
|
2955 | + } else if (preg_match('/^([a-z]+)_temp$/i',$modulepart,$reg)) |
|
2743 | 2956 | { |
2744 | - if (empty($conf->{$reg[1]}->dir_temp)) // modulepart not supported |
|
2957 | + if (empty($conf->{$reg[1]}->dir_temp)) { |
|
2958 | + // modulepart not supported |
|
2745 | 2959 | { |
2746 | 2960 | dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')'); |
2961 | + } |
|
2747 | 2962 | exit; |
2748 | 2963 | } |
2749 | - if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1; |
|
2964 | + if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) { |
|
2965 | + $accessallowed=1; |
|
2966 | + } |
|
2750 | 2967 | $original_file=$conf->{$reg[1]}->dir_temp.'/'.$original_file; |
2751 | - } |
|
2752 | - else if (preg_match('/^([a-z]+)_user$/i',$modulepart,$reg)) |
|
2968 | + } else if (preg_match('/^([a-z]+)_user$/i',$modulepart,$reg)) |
|
2753 | 2969 | { |
2754 | - if (empty($conf->{$reg[1]}->dir_output)) // modulepart not supported |
|
2970 | + if (empty($conf->{$reg[1]}->dir_output)) { |
|
2971 | + // modulepart not supported |
|
2755 | 2972 | { |
2756 | 2973 | dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')'); |
2974 | + } |
|
2757 | 2975 | exit; |
2758 | 2976 | } |
2759 | - if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) $accessallowed=1; |
|
2977 | + if ($fuser->rights->{$reg[1]}->{$lire} || $fuser->rights->{$reg[1]}->{$read} || ($fuser->rights->{$reg[1]}->{$download})) { |
|
2978 | + $accessallowed=1; |
|
2979 | + } |
|
2760 | 2980 | $original_file=$conf->{$reg[1]}->dir_output.'/'.$fuser->id.'/'.$original_file; |
2761 | - } |
|
2762 | - else |
|
2981 | + } else |
|
2763 | 2982 | { |
2764 | - if (empty($conf->$modulepart->dir_output)) // modulepart not supported |
|
2983 | + if (empty($conf->$modulepart->dir_output)) { |
|
2984 | + // modulepart not supported |
|
2765 | 2985 | { |
2766 | 2986 | dol_print_error('','Error call dol_check_secure_access_document with not supported value for modulepart parameter ('.$modulepart.')'); |
2987 | + } |
|
2767 | 2988 | exit; |
2768 | 2989 | } |
2769 | 2990 | |
@@ -2771,12 +2992,15 @@ discard block |
||
2771 | 2992 | $subperm=GETPOST('subperm'); |
2772 | 2993 | if ($perm || $subperm) |
2773 | 2994 | { |
2774 | - if (($perm && ! $subperm && $fuser->rights->$modulepart->$perm) || ($perm && $subperm && $fuser->rights->$modulepart->$perm->$subperm)) $accessallowed=1; |
|
2995 | + if (($perm && ! $subperm && $fuser->rights->$modulepart->$perm) || ($perm && $subperm && $fuser->rights->$modulepart->$perm->$subperm)) { |
|
2996 | + $accessallowed=1; |
|
2997 | + } |
|
2775 | 2998 | $original_file=$conf->$modulepart->dir_output.'/'.$original_file; |
2776 | - } |
|
2777 | - else |
|
2999 | + } else |
|
2778 | 3000 | { |
2779 | - if ($fuser->rights->$modulepart->{$lire} || $fuser->rights->$modulepart->{$read}) $accessallowed=1; |
|
3001 | + if ($fuser->rights->$modulepart->{$lire} || $fuser->rights->$modulepart->{$read}) { |
|
3002 | + $accessallowed=1; |
|
3003 | + } |
|
2780 | 3004 | $original_file=$conf->$modulepart->dir_output.'/'.$original_file; |
2781 | 3005 | } |
2782 | 3006 | } |
@@ -2794,11 +3018,13 @@ discard block |
||
2794 | 3018 | |
2795 | 3019 | // Define $sqlprotectagainstexternals for modules who want to protect access using a SQL query. |
2796 | 3020 | $sqlProtectConstName = strtoupper($modulepart).'_SQLPROTECTAGAINSTEXTERNALS_FOR_DOCUMENTS'; |
2797 | - if (! empty($conf->global->$sqlProtectConstName)) // If module want to define its own $sqlprotectagainstexternals |
|
3021 | + if (! empty($conf->global->$sqlProtectConstName)) { |
|
3022 | + // If module want to define its own $sqlprotectagainstexternals |
|
2798 | 3023 | { |
2799 | 3024 | // Example: mymodule__SQLPROTECTAGAINSTEXTERNALS_FOR_DOCUMENTS = "SELECT fk_soc FROM ".MAIN_DB_PREFIX.$modulepart." WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; |
2800 | 3025 | eval('$sqlprotectagainstexternals = "'.$conf->global->$sqlProtectConstName.'";'); |
2801 | 3026 | } |
3027 | + } |
|
2802 | 3028 | } |
2803 | 3029 | |
2804 | 3030 | $ret = array( |
@@ -2820,7 +3046,9 @@ discard block |
||
2820 | 3046 | */ |
2821 | 3047 | function dol_filecache($directory, $filename, $object) |
2822 | 3048 | { |
2823 | - if (! dol_is_dir($directory)) dol_mkdir($directory); |
|
3049 | + if (! dol_is_dir($directory)) { |
|
3050 | + dol_mkdir($directory); |
|
3051 | + } |
|
2824 | 3052 | $cachefile = $directory . $filename; |
2825 | 3053 | file_put_contents($cachefile, serialize($object), LOCK_EX); |
2826 | 3054 | @chmod($cachefile, 0644); |
@@ -2874,9 +3102,11 @@ discard block |
||
2874 | 3102 | |
2875 | 3103 | $exclude = 'install'; |
2876 | 3104 | |
2877 | - foreach ($dir->md5file as $file) // $file is a simpleXMLElement |
|
3105 | + foreach ($dir->md5file as $file) { |
|
3106 | + // $file is a simpleXMLElement |
|
2878 | 3107 | { |
2879 | 3108 | $filename = $path.$file['name']; |
3109 | + } |
|
2880 | 3110 | $file_list['insignature'][] = $filename; |
2881 | 3111 | $expectedmd5 = (string) $file; |
2882 | 3112 | |
@@ -2885,27 +3115,31 @@ discard block |
||
2885 | 3115 | if (!file_exists($pathref.'/'.$filename)) |
2886 | 3116 | { |
2887 | 3117 | $file_list['missing'][] = array('filename'=>$filename, 'expectedmd5'=>$expectedmd5); |
2888 | - } |
|
2889 | - else |
|
3118 | + } else |
|
2890 | 3119 | { |
2891 | 3120 | $md5_local = md5_file($pathref.'/'.$filename); |
2892 | 3121 | |
2893 | - 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 |
|
3122 | + if ($conffile == '/etc/dolibarr/conf.php' && $filename == '/filefunc.inc.php') { |
|
3123 | + // For install with deb or rpm, we ignore test on filefunc.inc.php that was modified by package |
|
2894 | 3124 | { |
2895 | 3125 | $checksumconcat[] = $expectedmd5; |
2896 | 3126 | } |
2897 | - else |
|
3127 | + } else |
|
2898 | 3128 | { |
2899 | - if ($md5_local != $expectedmd5) $file_list['updated'][] = array('filename'=>$filename, 'expectedmd5'=>$expectedmd5, 'md5'=>(string) $md5_local); |
|
3129 | + if ($md5_local != $expectedmd5) { |
|
3130 | + $file_list['updated'][] = array('filename'=>$filename, 'expectedmd5'=>$expectedmd5, 'md5'=>(string) $md5_local); |
|
3131 | + } |
|
2900 | 3132 | $checksumconcat[] = $md5_local; |
2901 | 3133 | } |
2902 | 3134 | } |
2903 | 3135 | } |
2904 | 3136 | |
2905 | - foreach ($dir->dir as $subdir) // $subdir['name'] is '' or '/accountancy/admin' for example |
|
3137 | + foreach ($dir->dir as $subdir) { |
|
3138 | + // $subdir['name'] is '' or '/accountancy/admin' for example |
|
2906 | 3139 | { |
2907 | 3140 | getFilesUpdated($file_list, $subdir, $path.$subdir['name'].'/', $pathref, $checksumconcat); |
2908 | 3141 | } |
3142 | + } |
|
2909 | 3143 | |
2910 | 3144 | return $file_list; |
2911 | 3145 | } |
@@ -446,15 +446,25 @@ discard block |
||
446 | 446 | $error=0; |
447 | 447 | |
448 | 448 | // Clean parameters |
449 | - if (empty($this->status)) $this->status=0; |
|
449 | + if (empty($this->status)) { |
|
450 | + $this->status=0; |
|
451 | + } |
|
450 | 452 | $this->name=$this->name?trim($this->name):trim($this->nom); |
451 | - if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name=ucwords($this->name); |
|
453 | + if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) { |
|
454 | + $this->name=ucwords($this->name); |
|
455 | + } |
|
452 | 456 | $this->nom=$this->name; // For backward compatibility |
453 | - if (empty($this->client)) $this->client=0; |
|
454 | - if (empty($this->fournisseur)) $this->fournisseur=0; |
|
457 | + if (empty($this->client)) { |
|
458 | + $this->client=0; |
|
459 | + } |
|
460 | + if (empty($this->fournisseur)) { |
|
461 | + $this->fournisseur=0; |
|
462 | + } |
|
455 | 463 | $this->import_key = trim($this->import_key); |
456 | 464 | |
457 | - if (!empty($this->multicurrency_code)) $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); |
|
465 | + if (!empty($this->multicurrency_code)) { |
|
466 | + $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); |
|
467 | + } |
|
458 | 468 | if (empty($this->fk_multicurrency)) |
459 | 469 | { |
460 | 470 | $this->multicurrency_code = ''; |
@@ -468,8 +478,12 @@ discard block |
||
468 | 478 | $this->db->begin(); |
469 | 479 | |
470 | 480 | // For automatic creation during create action (not used by Dolibarr GUI, can be used by scripts) |
471 | - if ($this->code_client == -1 || $this->code_client === 'auto') $this->get_codeclient($this,0); |
|
472 | - if ($this->code_fournisseur == -1 || $this->code_fournisseur === 'auto') $this->get_codefournisseur($this,1); |
|
481 | + if ($this->code_client == -1 || $this->code_client === 'auto') { |
|
482 | + $this->get_codeclient($this,0); |
|
483 | + } |
|
484 | + if ($this->code_fournisseur == -1 || $this->code_fournisseur === 'auto') { |
|
485 | + $this->get_codefournisseur($this,1); |
|
486 | + } |
|
473 | 487 | |
474 | 488 | // Check more parameters (including mandatory setup |
475 | 489 | // If error, this->errors[] is filled |
@@ -516,32 +530,32 @@ discard block |
||
516 | 530 | { |
517 | 531 | // Call trigger |
518 | 532 | $result=$this->call_trigger('COMPANY_CREATE',$user); |
519 | - if ($result < 0) $error++; |
|
533 | + if ($result < 0) { |
|
534 | + $error++; |
|
535 | + } |
|
520 | 536 | // End call triggers |
537 | + } else { |
|
538 | + $error++; |
|
521 | 539 | } |
522 | - else $error++; |
|
523 | 540 | |
524 | 541 | if (! $error) |
525 | 542 | { |
526 | 543 | dol_syslog(get_class($this)."::Create success id=".$this->id); |
527 | 544 | $this->db->commit(); |
528 | 545 | return $this->id; |
529 | - } |
|
530 | - else |
|
546 | + } else |
|
531 | 547 | { |
532 | 548 | dol_syslog(get_class($this)."::Create echec update ".$this->error." ".join(',',$this->errors), LOG_ERR); |
533 | 549 | $this->db->rollback(); |
534 | 550 | return -4; |
535 | 551 | } |
536 | - } |
|
537 | - else |
|
552 | + } else |
|
538 | 553 | { |
539 | 554 | if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') |
540 | 555 | { |
541 | 556 | $this->error=$langs->trans("ErrorCompanyNameAlreadyExists",$this->name); // duplicate on a field (code or profid or ...) |
542 | 557 | $result=-1; |
543 | - } |
|
544 | - else |
|
558 | + } else |
|
545 | 559 | { |
546 | 560 | $this->error=$this->db->lasterror(); |
547 | 561 | $result=-2; |
@@ -550,8 +564,7 @@ discard block |
||
550 | 564 | return $result; |
551 | 565 | } |
552 | 566 | |
553 | - } |
|
554 | - else |
|
567 | + } else |
|
555 | 568 | { |
556 | 569 | $this->db->rollback(); |
557 | 570 | dol_syslog(get_class($this)."::Create fails verify ".join(',',$this->errors), LOG_WARNING); |
@@ -703,8 +716,7 @@ discard block |
||
703 | 716 | } |
704 | 717 | } |
705 | 718 | } |
706 | - } |
|
707 | - else |
|
719 | + } else |
|
708 | 720 | { |
709 | 721 | //var_dump($conf->global->SOCIETE_EMAIL_UNIQUE); |
710 | 722 | //var_dump($conf->global->SOCIETE_EMAIL_MANDATORY); |
@@ -731,7 +743,9 @@ discard block |
||
731 | 743 | } |
732 | 744 | } |
733 | 745 | |
734 | - if ($error) $result = -4; |
|
746 | + if ($error) { |
|
747 | + $result = -4; |
|
748 | + } |
|
735 | 749 | |
736 | 750 | return $result; |
737 | 751 | } |
@@ -753,7 +767,9 @@ discard block |
||
753 | 767 | global $langs,$conf,$hookmanager; |
754 | 768 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
755 | 769 | |
756 | - if (empty($id)) $id = $this->id; |
|
770 | + if (empty($id)) { |
|
771 | + $id = $this->id; |
|
772 | + } |
|
757 | 773 | |
758 | 774 | $error=0; |
759 | 775 | |
@@ -796,9 +812,13 @@ discard block |
||
796 | 812 | |
797 | 813 | $this->tva_assuj = trim($this->tva_assuj); |
798 | 814 | $this->tva_intra = dol_sanitizeFileName($this->tva_intra,''); |
799 | - if (empty($this->status)) $this->status = 0; |
|
815 | + if (empty($this->status)) { |
|
816 | + $this->status = 0; |
|
817 | + } |
|
800 | 818 | |
801 | - if (!empty($this->multicurrency_code)) $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); |
|
819 | + if (!empty($this->multicurrency_code)) { |
|
820 | + $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); |
|
821 | + } |
|
802 | 822 | if (empty($this->fk_multicurrency)) |
803 | 823 | { |
804 | 824 | $this->multicurrency_code = ''; |
@@ -812,8 +832,13 @@ discard block |
||
812 | 832 | $this->localtax1_value=trim($this->localtax1_value); |
813 | 833 | $this->localtax2_value=trim($this->localtax2_value); |
814 | 834 | |
815 | - if ($this->capital != '') $this->capital=price2num(trim($this->capital)); |
|
816 | - if (! is_numeric($this->capital)) $this->capital = ''; // '' = undef |
|
835 | + if ($this->capital != '') { |
|
836 | + $this->capital=price2num(trim($this->capital)); |
|
837 | + } |
|
838 | + if (! is_numeric($this->capital)) { |
|
839 | + $this->capital = ''; |
|
840 | + } |
|
841 | + // '' = undef |
|
817 | 842 | |
818 | 843 | $this->effectif_id=trim($this->effectif_id); |
819 | 844 | $this->forme_juridique_code=trim($this->forme_juridique_code); |
@@ -822,8 +847,12 @@ discard block |
||
822 | 847 | $this->barcode=trim($this->barcode); |
823 | 848 | |
824 | 849 | // For automatic creation |
825 | - if ($this->code_client == -1 || $this->code_client === 'auto') $this->get_codeclient($this,0); |
|
826 | - if ($this->code_fournisseur == -1 || $this->code_fournisseur === 'auto') $this->get_codefournisseur($this,1); |
|
850 | + if ($this->code_client == -1 || $this->code_client === 'auto') { |
|
851 | + $this->get_codeclient($this,0); |
|
852 | + } |
|
853 | + if ($this->code_fournisseur == -1 || $this->code_fournisseur === 'auto') { |
|
854 | + $this->get_codefournisseur($this,1); |
|
855 | + } |
|
827 | 856 | |
828 | 857 | $this->code_compta=trim($this->code_compta); |
829 | 858 | $this->code_compta_fournisseur=trim($this->code_compta_fournisseur); |
@@ -843,7 +872,9 @@ discard block |
||
843 | 872 | if (empty($this->code_compta)) |
844 | 873 | { |
845 | 874 | $ret=$this->get_codecompta('customer'); |
846 | - if ($ret < 0) return -1; |
|
875 | + if ($ret < 0) { |
|
876 | + return -1; |
|
877 | + } |
|
847 | 878 | } |
848 | 879 | |
849 | 880 | $customer=true; |
@@ -856,7 +887,9 @@ discard block |
||
856 | 887 | if (empty($this->code_compta_fournisseur)) |
857 | 888 | { |
858 | 889 | $ret=$this->get_codecompta('supplier'); |
859 | - if ($ret < 0) return -1; |
|
890 | + if ($ret < 0) { |
|
891 | + return -1; |
|
892 | + } |
|
860 | 893 | } |
861 | 894 | |
862 | 895 | $supplier=true; |
@@ -926,22 +959,26 @@ discard block |
||
926 | 959 | if($this->localtax1_value!='') |
927 | 960 | { |
928 | 961 | $sql .=",localtax1_value =".$this->localtax1_value; |
962 | + } else { |
|
963 | + $sql .=",localtax1_value =0.000"; |
|
929 | 964 | } |
930 | - else $sql .=",localtax1_value =0.000"; |
|
931 | 965 | |
966 | + } else { |
|
967 | + $sql .=",localtax1_value =0.000"; |
|
932 | 968 | } |
933 | - else $sql .=",localtax1_value =0.000"; |
|
934 | 969 | |
935 | 970 | if($this->localtax2_assuj==1) |
936 | 971 | { |
937 | 972 | if($this->localtax2_value!='') |
938 | 973 | { |
939 | 974 | $sql .=",localtax2_value =".$this->localtax2_value; |
975 | + } else { |
|
976 | + $sql .=",localtax2_value =0.000"; |
|
940 | 977 | } |
941 | - else $sql .=",localtax2_value =0.000"; |
|
942 | 978 | |
979 | + } else { |
|
980 | + $sql .=",localtax2_value =0.000"; |
|
943 | 981 | } |
944 | - else $sql .=",localtax2_value =0.000"; |
|
945 | 982 | |
946 | 983 | $sql .= ",capital = ".($this->capital == '' ? "null" : $this->capital); |
947 | 984 | |
@@ -1034,8 +1071,7 @@ discard block |
||
1034 | 1071 | dol_syslog(get_class($this)."::update ".$this->error,LOG_ERR); |
1035 | 1072 | $error++; |
1036 | 1073 | } |
1037 | - } |
|
1038 | - else if ($result < 0) |
|
1074 | + } else if ($result < 0) |
|
1039 | 1075 | { |
1040 | 1076 | $this->error=$lmember->error; |
1041 | 1077 | $error++; |
@@ -1052,22 +1088,27 @@ discard block |
||
1052 | 1088 | $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
1053 | 1089 | if (empty($reshook)) |
1054 | 1090 | { |
1055 | - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used |
|
1091 | + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { |
|
1092 | + // For avoid conflicts if trigger used |
|
1056 | 1093 | { |
1057 | 1094 | $result=$this->insertExtraFields(); |
1095 | + } |
|
1058 | 1096 | if ($result < 0) |
1059 | 1097 | { |
1060 | 1098 | $error++; |
1061 | 1099 | } |
1062 | 1100 | } |
1101 | + } else if ($reshook < 0) { |
|
1102 | + $error++; |
|
1063 | 1103 | } |
1064 | - else if ($reshook < 0) $error++; |
|
1065 | 1104 | |
1066 | 1105 | if (! $error && $call_trigger) |
1067 | 1106 | { |
1068 | 1107 | // Call trigger |
1069 | 1108 | $result=$this->call_trigger('COMPANY_MODIFY',$user); |
1070 | - if ($result < 0) $error++; |
|
1109 | + if ($result < 0) { |
|
1110 | + $error++; |
|
1111 | + } |
|
1071 | 1112 | // End call triggers |
1072 | 1113 | } |
1073 | 1114 | |
@@ -1076,22 +1117,19 @@ discard block |
||
1076 | 1117 | dol_syslog(get_class($this)."::Update success"); |
1077 | 1118 | $this->db->commit(); |
1078 | 1119 | return 1; |
1079 | - } |
|
1080 | - else |
|
1120 | + } else |
|
1081 | 1121 | { |
1082 | 1122 | $this->db->rollback(); |
1083 | 1123 | return -1; |
1084 | 1124 | } |
1085 | - } |
|
1086 | - else |
|
1125 | + } else |
|
1087 | 1126 | { |
1088 | 1127 | if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') |
1089 | 1128 | { |
1090 | 1129 | // Doublon |
1091 | 1130 | $this->error = $langs->trans("ErrorDuplicateField"); |
1092 | 1131 | $result = -1; |
1093 | - } |
|
1094 | - else |
|
1132 | + } else |
|
1095 | 1133 | { |
1096 | 1134 | $this->error = $this->db->lasterror(); |
1097 | 1135 | $result = -2; |
@@ -1099,8 +1137,7 @@ discard block |
||
1099 | 1137 | $this->db->rollback(); |
1100 | 1138 | return $result; |
1101 | 1139 | } |
1102 | - } |
|
1103 | - else |
|
1140 | + } else |
|
1104 | 1141 | { |
1105 | 1142 | $this->db->rollback(); |
1106 | 1143 | dol_syslog(get_class($this)."::Update fails verify ".join(',',$this->errors), LOG_WARNING); |
@@ -1130,7 +1167,9 @@ discard block |
||
1130 | 1167 | global $langs; |
1131 | 1168 | global $conf; |
1132 | 1169 | |
1133 | - if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int) && empty($idprof1) && empty($idprof2) && empty($idprof3) && empty($idprof4) && empty($idprof5) && empty($idprof6) && empty($email)) return -1; |
|
1170 | + if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int) && empty($idprof1) && empty($idprof2) && empty($idprof3) && empty($idprof4) && empty($idprof5) && empty($idprof6) && empty($email)) { |
|
1171 | + return -1; |
|
1172 | + } |
|
1134 | 1173 | |
1135 | 1174 | $sql = 'SELECT s.rowid, s.nom as name, s.name_alias, s.entity, s.ref_ext, s.ref_int, s.address, s.datec as date_creation, s.prefix_comm'; |
1136 | 1175 | $sql .= ', s.status'; |
@@ -1167,18 +1206,42 @@ discard block |
||
1167 | 1206 | $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON s.fk_incoterms = i.rowid'; |
1168 | 1207 | |
1169 | 1208 | $sql .= ' WHERE s.entity IN ('.getEntity($this->element).')'; |
1170 | - if ($rowid) $sql .= ' AND s.rowid = '.$rowid; |
|
1171 | - if ($ref) $sql .= " AND s.nom = '".$this->db->escape($ref)."'"; |
|
1172 | - if ($ref_alias) $sql .= " AND s.nom_alias = '".$this->db->escape($nom_alias)."'"; |
|
1173 | - if ($ref_ext) $sql .= " AND s.ref_ext = '".$this->db->escape($ref_ext)."'"; |
|
1174 | - if ($ref_int) $sql .= " AND s.ref_int = '".$this->db->escape($ref_int)."'"; |
|
1175 | - if ($idprof1) $sql .= " AND s.siren = '".$this->db->escape($idprof1)."'"; |
|
1176 | - if ($idprof2) $sql .= " AND s.siret = '".$this->db->escape($idprof2)."'"; |
|
1177 | - if ($idprof3) $sql .= " AND s.ape = '".$this->db->escape($idprof3)."'"; |
|
1178 | - if ($idprof4) $sql .= " AND s.idprof4 = '".$this->db->escape($idprof4)."'"; |
|
1179 | - if ($idprof5) $sql .= " AND s.idprof5 = '".$this->db->escape($idprof5)."'"; |
|
1180 | - if ($idprof6) $sql .= " AND s.idprof6 = '".$this->db->escape($idprof6)."'"; |
|
1181 | - if ($email) $sql .= " AND s.email = '".$this->db->escape($email)."'"; |
|
1209 | + if ($rowid) { |
|
1210 | + $sql .= ' AND s.rowid = '.$rowid; |
|
1211 | + } |
|
1212 | + if ($ref) { |
|
1213 | + $sql .= " AND s.nom = '".$this->db->escape($ref)."'"; |
|
1214 | + } |
|
1215 | + if ($ref_alias) { |
|
1216 | + $sql .= " AND s.nom_alias = '".$this->db->escape($nom_alias)."'"; |
|
1217 | + } |
|
1218 | + if ($ref_ext) { |
|
1219 | + $sql .= " AND s.ref_ext = '".$this->db->escape($ref_ext)."'"; |
|
1220 | + } |
|
1221 | + if ($ref_int) { |
|
1222 | + $sql .= " AND s.ref_int = '".$this->db->escape($ref_int)."'"; |
|
1223 | + } |
|
1224 | + if ($idprof1) { |
|
1225 | + $sql .= " AND s.siren = '".$this->db->escape($idprof1)."'"; |
|
1226 | + } |
|
1227 | + if ($idprof2) { |
|
1228 | + $sql .= " AND s.siret = '".$this->db->escape($idprof2)."'"; |
|
1229 | + } |
|
1230 | + if ($idprof3) { |
|
1231 | + $sql .= " AND s.ape = '".$this->db->escape($idprof3)."'"; |
|
1232 | + } |
|
1233 | + if ($idprof4) { |
|
1234 | + $sql .= " AND s.idprof4 = '".$this->db->escape($idprof4)."'"; |
|
1235 | + } |
|
1236 | + if ($idprof5) { |
|
1237 | + $sql .= " AND s.idprof5 = '".$this->db->escape($idprof5)."'"; |
|
1238 | + } |
|
1239 | + if ($idprof6) { |
|
1240 | + $sql .= " AND s.idprof6 = '".$this->db->escape($idprof6)."'"; |
|
1241 | + } |
|
1242 | + if ($email) { |
|
1243 | + $sql .= " AND s.email = '".$this->db->escape($email)."'"; |
|
1244 | + } |
|
1182 | 1245 | |
1183 | 1246 | $resql=$this->db->query($sql); |
1184 | 1247 | if ($resql) |
@@ -1189,10 +1252,11 @@ discard block |
||
1189 | 1252 | $this->error='Fetch found several records. Rename one of tirdparties to avoid duplicate.'; |
1190 | 1253 | dol_syslog($this->error, LOG_ERR); |
1191 | 1254 | $result = -2; |
1192 | - } |
|
1193 | - elseif ($num) // $num = 1 |
|
1255 | + } elseif ($num) { |
|
1256 | + // $num = 1 |
|
1194 | 1257 | { |
1195 | 1258 | $obj = $this->db->fetch_object($resql); |
1259 | + } |
|
1196 | 1260 | |
1197 | 1261 | $this->id = $obj->rowid; |
1198 | 1262 | $this->entity = $obj->entity; |
@@ -1320,22 +1384,22 @@ discard block |
||
1320 | 1384 | // Retreive all extrafield |
1321 | 1385 | // fetch optionals attributes and labels |
1322 | 1386 | $this->fetch_optionals(); |
1323 | - } |
|
1324 | - else |
|
1387 | + } else |
|
1325 | 1388 | { |
1326 | 1389 | $result = 0; |
1327 | 1390 | } |
1328 | 1391 | |
1329 | 1392 | $this->db->free($resql); |
1330 | - } |
|
1331 | - else |
|
1393 | + } else |
|
1332 | 1394 | { |
1333 | 1395 | $this->error=$this->db->lasterror(); |
1334 | 1396 | $result = -3; |
1335 | 1397 | } |
1336 | 1398 | |
1337 | 1399 | // Use first price level if level not defined for third party |
1338 | - if (! empty($conf->global->PRODUIT_MULTIPRICES) && empty($this->price_level)) $this->price_level=1; |
|
1400 | + if (! empty($conf->global->PRODUIT_MULTIPRICES) && empty($this->price_level)) { |
|
1401 | + $this->price_level=1; |
|
1402 | + } |
|
1339 | 1403 | |
1340 | 1404 | return $result; |
1341 | 1405 | } |
@@ -1370,10 +1434,11 @@ discard block |
||
1370 | 1434 | $sql.= " WHERE entity IN (".getEntity('category').")"; |
1371 | 1435 | if (! empty($type)) |
1372 | 1436 | { |
1373 | - if ($type == 1 || $type == 2) |
|
1374 | - $sql.= " AND client = ".$type; |
|
1375 | - elseif ($type == 3) |
|
1376 | - $sql.= " AND fournisseur = 1"; |
|
1437 | + if ($type == 1 || $type == 2) { |
|
1438 | + $sql.= " AND client = ".$type; |
|
1439 | + } elseif ($type == 3) { |
|
1440 | + $sql.= " AND fournisseur = 1"; |
|
1441 | + } |
|
1377 | 1442 | } |
1378 | 1443 | if (! empty($name)) |
1379 | 1444 | { |
@@ -1382,27 +1447,27 @@ discard block |
||
1382 | 1447 | if (preg_match('/^([\*])?[^*]+([\*])?$/', $name, $regs) && count($regs) > 1) |
1383 | 1448 | { |
1384 | 1449 | $name = str_replace('*', '%', $name); |
1385 | - } |
|
1386 | - else |
|
1450 | + } else |
|
1387 | 1451 | { |
1388 | 1452 | $name = '%'.$name.'%'; |
1389 | 1453 | } |
1390 | 1454 | } |
1391 | 1455 | $sql.= " AND "; |
1392 | - if (is_array($filters) && ! empty($filters)) |
|
1393 | - $sql.= "("; |
|
1456 | + if (is_array($filters) && ! empty($filters)) { |
|
1457 | + $sql.= "("; |
|
1458 | + } |
|
1394 | 1459 | if ($similar) |
1395 | 1460 | { |
1396 | 1461 | // For test similitude (string inside name into database, or name into database inside string) |
1397 | 1462 | // Do not use this. Not compatible with other database. |
1398 | 1463 | $sql.= "(LOCATE('".$this->db->escape($name)."', nom) > 0 OR LOCATE(nom, '".$this->db->escape($name)."') > 0)"; |
1399 | - } |
|
1400 | - else |
|
1464 | + } else |
|
1401 | 1465 | { |
1402 | - if (! $case) |
|
1403 | - $sql.= "nom LIKE '".$this->db->escape($name)."'"; |
|
1404 | - else |
|
1405 | - $sql.= "nom LIKE BINARY '".$this->db->escape($name)."'"; |
|
1466 | + if (! $case) { |
|
1467 | + $sql.= "nom LIKE '".$this->db->escape($name)."'"; |
|
1468 | + } else { |
|
1469 | + $sql.= "nom LIKE BINARY '".$this->db->escape($name)."'"; |
|
1470 | + } |
|
1406 | 1471 | } |
1407 | 1472 | } |
1408 | 1473 | if (is_array($filters) && ! empty($filters)) |
@@ -1414,19 +1479,20 @@ discard block |
||
1414 | 1479 | if (preg_match('/^([\*])?[^*]+([\*])?$/', $value, $regs) && count($regs) > 1) |
1415 | 1480 | { |
1416 | 1481 | $value = str_replace('*', '%', $value); |
1417 | - } |
|
1418 | - else |
|
1482 | + } else |
|
1419 | 1483 | { |
1420 | 1484 | $value = '%'.$value.'%'; |
1421 | 1485 | } |
1422 | 1486 | } |
1423 | - if (! $case) |
|
1424 | - $sql.= " ".$clause." ".$field." LIKE '".$this->db->escape($value)."'"; |
|
1425 | - else |
|
1426 | - $sql.= " ".$clause." ".$field." LIKE BINARY '".$this->db->escape($value)."'"; |
|
1487 | + if (! $case) { |
|
1488 | + $sql.= " ".$clause." ".$field." LIKE '".$this->db->escape($value)."'"; |
|
1489 | + } else { |
|
1490 | + $sql.= " ".$clause." ".$field." LIKE BINARY '".$this->db->escape($value)."'"; |
|
1491 | + } |
|
1492 | + } |
|
1493 | + if (! empty($name)) { |
|
1494 | + $sql.= ")"; |
|
1427 | 1495 | } |
1428 | - if (! empty($name)) |
|
1429 | - $sql.= ")"; |
|
1430 | 1496 | } |
1431 | 1497 | |
1432 | 1498 | $res = $this->db->query($sql); |
@@ -1440,8 +1506,7 @@ discard block |
||
1440 | 1506 | } |
1441 | 1507 | |
1442 | 1508 | return $thirdparties; |
1443 | - } |
|
1444 | - else |
|
1509 | + } else |
|
1445 | 1510 | { |
1446 | 1511 | $this->error=$this->db->lasterror(); |
1447 | 1512 | return -1; |
@@ -1460,7 +1525,9 @@ discard block |
||
1460 | 1525 | { |
1461 | 1526 | global $langs, $conf, $user; |
1462 | 1527 | |
1463 | - if (empty($fuser)) $fuser=$user; |
|
1528 | + if (empty($fuser)) { |
|
1529 | + $fuser=$user; |
|
1530 | + } |
|
1464 | 1531 | |
1465 | 1532 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
1466 | 1533 | |
@@ -1480,7 +1547,9 @@ discard block |
||
1480 | 1547 | { |
1481 | 1548 | // Call trigger |
1482 | 1549 | $result=$this->call_trigger('COMPANY_DELETE',$fuser); |
1483 | - if ($result < 0) $error++; |
|
1550 | + if ($result < 0) { |
|
1551 | + $error++; |
|
1552 | + } |
|
1484 | 1553 | // End call triggers |
1485 | 1554 | } |
1486 | 1555 | |
@@ -1525,9 +1594,11 @@ discard block |
||
1525 | 1594 | } |
1526 | 1595 | |
1527 | 1596 | // Removed extrafields |
1528 | - if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used |
|
1597 | + if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) { |
|
1598 | + // For avoid conflicts if trigger used |
|
1529 | 1599 | { |
1530 | 1600 | $result=$this->deleteExtraFields(); |
1601 | + } |
|
1531 | 1602 | if ($result < 0) |
1532 | 1603 | { |
1533 | 1604 | $error++; |
@@ -1562,15 +1633,15 @@ discard block |
||
1562 | 1633 | } |
1563 | 1634 | |
1564 | 1635 | return 1; |
1565 | - } |
|
1566 | - else |
|
1636 | + } else |
|
1567 | 1637 | { |
1568 | 1638 | dol_syslog($this->error, LOG_ERR); |
1569 | 1639 | $this->db->rollback(); |
1570 | 1640 | return -1; |
1571 | 1641 | } |
1642 | + } else { |
|
1643 | + dol_syslog("Can't remove thirdparty with id ".$id.". There is ".$objectisused." childs", LOG_WARNING); |
|
1572 | 1644 | } |
1573 | - else dol_syslog("Can't remove thirdparty with id ".$id.". There is ".$objectisused." childs", LOG_WARNING); |
|
1574 | 1645 | return 0; |
1575 | 1646 | } |
1576 | 1647 | |
@@ -1584,7 +1655,10 @@ discard block |
||
1584 | 1655 | if ($this->id) |
1585 | 1656 | { |
1586 | 1657 | $newclient=1; |
1587 | - if ($this->client == 2 || $this->client == 3) $newclient=3; //If prospect, we keep prospect tag |
|
1658 | + if ($this->client == 2 || $this->client == 3) { |
|
1659 | + $newclient=3; |
|
1660 | + } |
|
1661 | + //If prospect, we keep prospect tag |
|
1588 | 1662 | $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; |
1589 | 1663 | $sql.= " SET client = ".$newclient; |
1590 | 1664 | $sql.= " WHERE rowid = " . $this->id; |
@@ -1594,8 +1668,9 @@ discard block |
||
1594 | 1668 | { |
1595 | 1669 | $this->client = $newclient; |
1596 | 1670 | return 1; |
1671 | + } else { |
|
1672 | + return -1; |
|
1597 | 1673 | } |
1598 | - else return -1; |
|
1599 | 1674 | } |
1600 | 1675 | return 0; |
1601 | 1676 | } |
@@ -1705,14 +1780,14 @@ discard block |
||
1705 | 1780 | if ($result > 0) |
1706 | 1781 | { |
1707 | 1782 | return $result; |
1708 | - } |
|
1709 | - else |
|
1783 | + } else |
|
1710 | 1784 | { |
1711 | 1785 | $this->error=$discount->error; |
1712 | 1786 | return -3; |
1713 | 1787 | } |
1788 | + } else { |
|
1789 | + return 0; |
|
1714 | 1790 | } |
1715 | - else return 0; |
|
1716 | 1791 | } |
1717 | 1792 | |
1718 | 1793 | /** |
@@ -1732,8 +1807,7 @@ discard block |
||
1732 | 1807 | if ($result >= 0) |
1733 | 1808 | { |
1734 | 1809 | return $result; |
1735 | - } |
|
1736 | - else |
|
1810 | + } else |
|
1737 | 1811 | { |
1738 | 1812 | $this->error=$discountstatic->error; |
1739 | 1813 | return -1; |
@@ -1760,9 +1834,9 @@ discard block |
||
1760 | 1834 | $sql.= " WHERE ((ug.fk_user = sc.fk_user"; |
1761 | 1835 | $sql.= " AND ug.entity = ".$conf->entity.")"; |
1762 | 1836 | $sql.= " OR u.admin = 1)"; |
1837 | + } else { |
|
1838 | + $sql.= " WHERE entity in (0, ".$conf->entity.")"; |
|
1763 | 1839 | } |
1764 | - else |
|
1765 | - $sql.= " WHERE entity in (0, ".$conf->entity.")"; |
|
1766 | 1840 | |
1767 | 1841 | $sql.= " AND u.rowid = sc.fk_user AND sc.fk_soc = ".$this->id; |
1768 | 1842 | |
@@ -1785,8 +1859,7 @@ discard block |
||
1785 | 1859 | $i++; |
1786 | 1860 | } |
1787 | 1861 | return $reparray; |
1788 | - } |
|
1789 | - else { |
|
1862 | + } else { |
|
1790 | 1863 | dol_print_error($this->db); |
1791 | 1864 | return -1; |
1792 | 1865 | } |
@@ -1892,7 +1965,10 @@ discard block |
||
1892 | 1965 | { |
1893 | 1966 | global $conf, $langs, $hookmanager; |
1894 | 1967 | |
1895 | - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips |
|
1968 | + if (! empty($conf->dol_no_mouse_hover)) { |
|
1969 | + $notooltip=1; |
|
1970 | + } |
|
1971 | + // Force disable tooltips |
|
1896 | 1972 | |
1897 | 1973 | $name=$this->name?$this->name:$this->nom; |
1898 | 1974 | |
@@ -1902,23 +1978,28 @@ discard block |
||
1902 | 1978 | && ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1 |
1903 | 1979 | || $conf->global->SOCIETE_ADD_REF_IN_LIST == 2 |
1904 | 1980 | ) |
1905 | - ) |
|
1906 | - $code = $this->code_client . ' - '; |
|
1981 | + ) { |
|
1982 | + $code = $this->code_client . ' - '; |
|
1983 | + } |
|
1907 | 1984 | |
1908 | 1985 | if (($this->fournisseur) && (! empty ( $this->code_fournisseur )) |
1909 | 1986 | && ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1 |
1910 | 1987 | || $conf->global->SOCIETE_ADD_REF_IN_LIST == 3 |
1911 | 1988 | ) |
1912 | - ) |
|
1913 | - $code .= $this->code_fournisseur . ' - '; |
|
1989 | + ) { |
|
1990 | + $code .= $this->code_fournisseur . ' - '; |
|
1991 | + } |
|
1914 | 1992 | |
1915 | - if ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1) |
|
1916 | - $name =$code.' '.$name; |
|
1917 | - else |
|
1918 | - $name =$code; |
|
1993 | + if ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1) { |
|
1994 | + $name =$code.' '.$name; |
|
1995 | + } else { |
|
1996 | + $name =$code; |
|
1997 | + } |
|
1919 | 1998 | } |
1920 | 1999 | |
1921 | - if (!empty($this->name_alias)) $name .= ' ('.$this->name_alias.')'; |
|
2000 | + if (!empty($this->name_alias)) { |
|
2001 | + $name .= ' ('.$this->name_alias.')'; |
|
2002 | + } |
|
1922 | 2003 | |
1923 | 2004 | $result=''; $label=''; |
1924 | 2005 | $linkstart=''; $linkend=''; |
@@ -1936,38 +2017,31 @@ discard block |
||
1936 | 2017 | { |
1937 | 2018 | $label.= '<u>' . $langs->trans("ShowCustomer") . '</u>'; |
1938 | 2019 | $linkstart = '<a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id; |
1939 | - } |
|
1940 | - else if ($option == 'prospect' && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) |
|
2020 | + } else if ($option == 'prospect' && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) |
|
1941 | 2021 | { |
1942 | 2022 | $label.= '<u>' . $langs->trans("ShowProspect") . '</u>'; |
1943 | 2023 | $linkstart = '<a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id; |
1944 | - } |
|
1945 | - else if ($option == 'supplier') |
|
2024 | + } else if ($option == 'supplier') |
|
1946 | 2025 | { |
1947 | 2026 | $label.= '<u>' . $langs->trans("ShowSupplier") . '</u>'; |
1948 | 2027 | $linkstart = '<a href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$this->id; |
1949 | - } |
|
1950 | - else if ($option == 'agenda') |
|
2028 | + } else if ($option == 'agenda') |
|
1951 | 2029 | { |
1952 | 2030 | $label.= '<u>' . $langs->trans("ShowAgenda") . '</u>'; |
1953 | 2031 | $linkstart = '<a href="'.DOL_URL_ROOT.'/societe/agenda.php?socid='.$this->id; |
1954 | - } |
|
1955 | - else if ($option == 'project') |
|
2032 | + } else if ($option == 'project') |
|
1956 | 2033 | { |
1957 | 2034 | $label.= '<u>' . $langs->trans("ShowProject") . '</u>'; |
1958 | 2035 | $linkstart = '<a href="'.DOL_URL_ROOT.'/societe/project.php?socid='.$this->id; |
1959 | - } |
|
1960 | - else if ($option == 'margin') |
|
2036 | + } else if ($option == 'margin') |
|
1961 | 2037 | { |
1962 | 2038 | $label.= '<u>' . $langs->trans("ShowMargin") . '</u>'; |
1963 | 2039 | $linkstart = '<a href="'.DOL_URL_ROOT.'/margin/tabs/thirdpartyMargins.php?socid='.$this->id.'&type=1'; |
1964 | - } |
|
1965 | - else if ($option == 'contact') |
|
2040 | + } else if ($option == 'contact') |
|
1966 | 2041 | { |
1967 | 2042 | $label.= '<u>' . $langs->trans("ShowContacts") . '</u>'; |
1968 | 2043 | $linkstart = '<a href="'.DOL_URL_ROOT.'/societe/contact.php?socid='.$this->id; |
1969 | - } |
|
1970 | - else if ($option == 'ban') |
|
2044 | + } else if ($option == 'ban') |
|
1971 | 2045 | { |
1972 | 2046 | $label.= '<u>' . $langs->trans("ShowBan") . '</u>'; |
1973 | 2047 | $linkstart = '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$this->id; |
@@ -1983,21 +2057,29 @@ discard block |
||
1983 | 2057 | if (! empty($this->name)) |
1984 | 2058 | { |
1985 | 2059 | $label.= '<br><b>' . $langs->trans('Name') . ':</b> '. $this->name; |
1986 | - if (! empty($this->name_alias)) $label.=' ('.$this->name_alias.')'; |
|
2060 | + if (! empty($this->name_alias)) { |
|
2061 | + $label.=' ('.$this->name_alias.')'; |
|
2062 | + } |
|
1987 | 2063 | $label.= '<br><b>' . $langs->trans('Email') . ':</b> '. $this->email; |
1988 | 2064 | } |
1989 | - if (! empty($this->country_code)) |
|
1990 | - $label.= '<br><b>' . $langs->trans('Country') . ':</b> '. $this->country_code; |
|
1991 | - if (! empty($this->tva_intra)) |
|
1992 | - $label.= '<br><b>' . $langs->trans('VATIntra') . ':</b> '. $this->tva_intra; |
|
1993 | - if (! empty($this->code_client) && $this->client) |
|
1994 | - $label.= '<br><b>' . $langs->trans('CustomerCode') . ':</b> '. $this->code_client; |
|
1995 | - if (! empty($this->code_fournisseur) && $this->fournisseur) |
|
1996 | - $label.= '<br><b>' . $langs->trans('SupplierCode') . ':</b> '. $this->code_fournisseur; |
|
1997 | - if (! empty($conf->accounting->enabled) && $this->client) |
|
1998 | - $label.= '<br><b>' . $langs->trans('CustomerAccountancyCode') . ':</b> '. ($this->code_compta ? $this->code_compta : $this->code_compta_client); |
|
1999 | - if (! empty($conf->accounting->enabled) && $this->fournisseur) |
|
2000 | - $label.= '<br><b>' . $langs->trans('SupplierAccountancyCode') . ':</b> '. $this->code_compta_fournisseur; |
|
2065 | + if (! empty($this->country_code)) { |
|
2066 | + $label.= '<br><b>' . $langs->trans('Country') . ':</b> '. $this->country_code; |
|
2067 | + } |
|
2068 | + if (! empty($this->tva_intra)) { |
|
2069 | + $label.= '<br><b>' . $langs->trans('VATIntra') . ':</b> '. $this->tva_intra; |
|
2070 | + } |
|
2071 | + if (! empty($this->code_client) && $this->client) { |
|
2072 | + $label.= '<br><b>' . $langs->trans('CustomerCode') . ':</b> '. $this->code_client; |
|
2073 | + } |
|
2074 | + if (! empty($this->code_fournisseur) && $this->fournisseur) { |
|
2075 | + $label.= '<br><b>' . $langs->trans('SupplierCode') . ':</b> '. $this->code_fournisseur; |
|
2076 | + } |
|
2077 | + if (! empty($conf->accounting->enabled) && $this->client) { |
|
2078 | + $label.= '<br><b>' . $langs->trans('CustomerAccountancyCode') . ':</b> '. ($this->code_compta ? $this->code_compta : $this->code_compta_client); |
|
2079 | + } |
|
2080 | + if (! empty($conf->accounting->enabled) && $this->fournisseur) { |
|
2081 | + $label.= '<br><b>' . $langs->trans('SupplierAccountancyCode') . ':</b> '. $this->code_compta_fournisseur; |
|
2082 | + } |
|
2001 | 2083 | |
2002 | 2084 | $label.= '</div>'; |
2003 | 2085 | |
@@ -2005,8 +2087,12 @@ discard block |
||
2005 | 2087 | $linkstart.=(!empty($this->canvas)?'&canvas='.$this->canvas:''); |
2006 | 2088 | // Add param to save lastsearch_values or not |
2007 | 2089 | $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); |
2008 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; |
|
2009 | - if ($add_save_lastsearch_values) $linkstart.='&save_lastsearch_values=1'; |
|
2090 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) { |
|
2091 | + $add_save_lastsearch_values=1; |
|
2092 | + } |
|
2093 | + if ($add_save_lastsearch_values) { |
|
2094 | + $linkstart.='&save_lastsearch_values=1'; |
|
2095 | + } |
|
2010 | 2096 | $linkstart.='"'; |
2011 | 2097 | |
2012 | 2098 | $linkclose=''; |
@@ -2028,7 +2114,9 @@ discard block |
||
2028 | 2114 | $hookmanager->initHooks(array('societedao')); |
2029 | 2115 | $parameters=array('id'=>$this->id); |
2030 | 2116 | $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
2031 | - if ($reshook > 0) $linkclose = $hookmanager->resPrint; |
|
2117 | + if ($reshook > 0) { |
|
2118 | + $linkclose = $hookmanager->resPrint; |
|
2119 | + } |
|
2032 | 2120 | } |
2033 | 2121 | $linkstart.=$linkclose.'>'; |
2034 | 2122 | $linkend='</a>'; |
@@ -2041,8 +2129,12 @@ discard block |
||
2041 | 2129 | } |
2042 | 2130 | |
2043 | 2131 | $result.=$linkstart; |
2044 | - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip valigntextbottom"'), 0, 0, $notooltip?0:1); |
|
2045 | - if ($withpicto != 2) $result.=($maxlen?dol_trunc($name,$maxlen):$name); |
|
2132 | + if ($withpicto) { |
|
2133 | + $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip valigntextbottom"'), 0, 0, $notooltip?0:1); |
|
2134 | + } |
|
2135 | + if ($withpicto != 2) { |
|
2136 | + $result.=($maxlen?dol_trunc($name,$maxlen):$name); |
|
2137 | + } |
|
2046 | 2138 | $result.=$linkend; |
2047 | 2139 | |
2048 | 2140 | return $result; |
@@ -2073,38 +2165,66 @@ discard block |
||
2073 | 2165 | |
2074 | 2166 | if ($mode == 0) |
2075 | 2167 | { |
2076 | - if ($statut==0) return $langs->trans("ActivityCeased"); |
|
2077 | - if ($statut==1) return $langs->trans("InActivity"); |
|
2168 | + if ($statut==0) { |
|
2169 | + return $langs->trans("ActivityCeased"); |
|
2170 | + } |
|
2171 | + if ($statut==1) { |
|
2172 | + return $langs->trans("InActivity"); |
|
2173 | + } |
|
2078 | 2174 | } |
2079 | 2175 | if ($mode == 1) |
2080 | 2176 | { |
2081 | - if ($statut==0) return $langs->trans("ActivityCeased"); |
|
2082 | - if ($statut==1) return $langs->trans("InActivity"); |
|
2177 | + if ($statut==0) { |
|
2178 | + return $langs->trans("ActivityCeased"); |
|
2179 | + } |
|
2180 | + if ($statut==1) { |
|
2181 | + return $langs->trans("InActivity"); |
|
2182 | + } |
|
2083 | 2183 | } |
2084 | 2184 | if ($mode == 2) |
2085 | 2185 | { |
2086 | - if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); |
|
2087 | - if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); |
|
2186 | + if ($statut==0) { |
|
2187 | + return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); |
|
2188 | + } |
|
2189 | + if ($statut==1) { |
|
2190 | + return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); |
|
2191 | + } |
|
2088 | 2192 | } |
2089 | 2193 | if ($mode == 3) |
2090 | 2194 | { |
2091 | - if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); |
|
2092 | - if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); |
|
2195 | + if ($statut==0) { |
|
2196 | + return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); |
|
2197 | + } |
|
2198 | + if ($statut==1) { |
|
2199 | + return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); |
|
2200 | + } |
|
2093 | 2201 | } |
2094 | 2202 | if ($mode == 4) |
2095 | 2203 | { |
2096 | - if ($statut==0) return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); |
|
2097 | - if ($statut==1) return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); |
|
2204 | + if ($statut==0) { |
|
2205 | + return img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"').' '.$langs->trans("ActivityCeased"); |
|
2206 | + } |
|
2207 | + if ($statut==1) { |
|
2208 | + return img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"').' '.$langs->trans("InActivity"); |
|
2209 | + } |
|
2098 | 2210 | } |
2099 | 2211 | if ($mode == 5) |
2100 | 2212 | { |
2101 | - if ($statut==0) return '<span class="hideonsmartphone">'.$langs->trans("ActivityCeased").'</span> '.img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); |
|
2102 | - if ($statut==1) return '<span class="hideonsmartphone">'.$langs->trans("InActivity").'</span> '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); |
|
2213 | + if ($statut==0) { |
|
2214 | + return '<span class="hideonsmartphone">'.$langs->trans("ActivityCeased").'</span> '.img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); |
|
2215 | + } |
|
2216 | + if ($statut==1) { |
|
2217 | + return '<span class="hideonsmartphone">'.$langs->trans("InActivity").'</span> '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); |
|
2218 | + } |
|
2103 | 2219 | } |
2104 | 2220 | if ($mode == 6) |
2105 | 2221 | { |
2106 | - if ($statut==0) return '<span class="hideonsmartphone">'.$langs->trans("ActivityCeased").'</span> '.img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); |
|
2107 | - if ($statut==1) return '<span class="hideonsmartphone">'.$langs->trans("InActivity").'</span> '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); |
|
2222 | + if ($statut==0) { |
|
2223 | + return '<span class="hideonsmartphone">'.$langs->trans("ActivityCeased").'</span> '.img_picto($langs->trans("ActivityCeased"),'statut5', 'class="pictostatus"'); |
|
2224 | + } |
|
2225 | + if ($statut==1) { |
|
2226 | + return '<span class="hideonsmartphone">'.$langs->trans("InActivity").'</span> '.img_picto($langs->trans("InActivity"),'statut4', 'class="pictostatus"'); |
|
2227 | + } |
|
2108 | 2228 | } |
2109 | 2229 | } |
2110 | 2230 | |
@@ -2121,7 +2241,9 @@ discard block |
||
2121 | 2241 | $contact_emails = $this->contact_property_array('email',1); |
2122 | 2242 | if ($this->email && $addthirdparty) |
2123 | 2243 | { |
2124 | - if (empty($this->name)) $this->name=$this->nom; |
|
2244 | + if (empty($this->name)) { |
|
2245 | + $this->name=$this->nom; |
|
2246 | + } |
|
2125 | 2247 | $contact_emails['thirdparty']=$langs->transnoentitiesnoconv("ThirdParty").': '.dol_trunc($this->name,16)." <".$this->email.">"; |
2126 | 2248 | } |
2127 | 2249 | //var_dump($contact_emails) |
@@ -2139,9 +2261,11 @@ discard block |
||
2139 | 2261 | |
2140 | 2262 | $contact_phone = $this->contact_property_array('mobile'); |
2141 | 2263 | |
2142 | - if (! empty($this->phone)) // If a phone of thirdparty is defined, we add it ot mobile of contacts |
|
2264 | + if (! empty($this->phone)) { |
|
2265 | + // If a phone of thirdparty is defined, we add it ot mobile of contacts |
|
2143 | 2266 | { |
2144 | 2267 | if (empty($this->name)) $this->name=$this->nom; |
2268 | + } |
|
2145 | 2269 | // TODO: Tester si tel non deja present dans tableau contact |
2146 | 2270 | $contact_phone['thirdparty']=$langs->transnoentitiesnoconv("ThirdParty").': '.dol_trunc($this->name,16)." <".$this->phone.">"; |
2147 | 2271 | } |
@@ -2182,24 +2306,30 @@ discard block |
||
2182 | 2306 | while ($i < $nump) |
2183 | 2307 | { |
2184 | 2308 | $obj = $this->db->fetch_object($resql); |
2185 | - if ($mode == 'email') $property=$obj->email; |
|
2186 | - else if ($mode == 'mobile') $property=$obj->phone_mobile; |
|
2187 | - else $property=$obj->$mode; |
|
2309 | + if ($mode == 'email') { |
|
2310 | + $property=$obj->email; |
|
2311 | + } else if ($mode == 'mobile') { |
|
2312 | + $property=$obj->phone_mobile; |
|
2313 | + } else { |
|
2314 | + $property=$obj->$mode; |
|
2315 | + } |
|
2188 | 2316 | |
2189 | 2317 | // Show all contact. If hidedisabled is 1, showonly contacts with status = 1 |
2190 | 2318 | if ($obj->statut == 1 || empty($hidedisabled)) |
2191 | 2319 | { |
2192 | 2320 | if (empty($property)) |
2193 | 2321 | { |
2194 | - if ($mode == 'email') $property=$langs->transnoentitiesnoconv("NoEMail"); |
|
2195 | - else if ($mode == 'mobile') $property=$langs->transnoentitiesnoconv("NoMobilePhone"); |
|
2322 | + if ($mode == 'email') { |
|
2323 | + $property=$langs->transnoentitiesnoconv("NoEMail"); |
|
2324 | + } else if ($mode == 'mobile') { |
|
2325 | + $property=$langs->transnoentitiesnoconv("NoMobilePhone"); |
|
2326 | + } |
|
2196 | 2327 | } |
2197 | 2328 | |
2198 | 2329 | if (!empty($obj->poste)) |
2199 | 2330 | { |
2200 | 2331 | $contact_property[$obj->rowid] = trim(dolGetFirstLastname($obj->firstname,$obj->lastname)).($obj->poste?" - ".$obj->poste:"").(($mode != 'poste' && $property)?" ".$sepa.$property.$sepb:''); |
2201 | - } |
|
2202 | - else |
|
2332 | + } else |
|
2203 | 2333 | { |
2204 | 2334 | $contact_property[$obj->rowid] = trim(dolGetFirstLastname($obj->firstname,$obj->lastname)).(($mode != 'poste' && $property)?" ".$sepa.$property.$sepb:''); |
2205 | 2335 | } |
@@ -2207,8 +2337,7 @@ discard block |
||
2207 | 2337 | $i++; |
2208 | 2338 | } |
2209 | 2339 | } |
2210 | - } |
|
2211 | - else |
|
2340 | + } else |
|
2212 | 2341 | { |
2213 | 2342 | dol_print_error($this->db); |
2214 | 2343 | } |
@@ -2240,8 +2369,7 @@ discard block |
||
2240 | 2369 | $i++; |
2241 | 2370 | } |
2242 | 2371 | } |
2243 | - } |
|
2244 | - else |
|
2372 | + } else |
|
2245 | 2373 | { |
2246 | 2374 | dol_print_error($this->db); |
2247 | 2375 | } |
@@ -2275,8 +2403,7 @@ discard block |
||
2275 | 2403 | $i++; |
2276 | 2404 | } |
2277 | 2405 | } |
2278 | - } |
|
2279 | - else |
|
2406 | + } else |
|
2280 | 2407 | { |
2281 | 2408 | dol_print_error($this->db); |
2282 | 2409 | } |
@@ -2294,7 +2421,9 @@ discard block |
||
2294 | 2421 | { |
2295 | 2422 | $contact_property=''; |
2296 | 2423 | |
2297 | - if (empty($rowid)) return ''; |
|
2424 | + if (empty($rowid)) { |
|
2425 | + return ''; |
|
2426 | + } |
|
2298 | 2427 | |
2299 | 2428 | $sql = "SELECT rowid, email, phone_mobile, lastname, firstname"; |
2300 | 2429 | $sql.= " FROM ".MAIN_DB_PREFIX."socpeople"; |
@@ -2309,12 +2438,14 @@ discard block |
||
2309 | 2438 | { |
2310 | 2439 | $obj = $this->db->fetch_object($resql); |
2311 | 2440 | |
2312 | - if ($mode == 'email') $contact_property = dolGetFirstLastname($obj->firstname, $obj->lastname)." <".$obj->email.">"; |
|
2313 | - else if ($mode == 'mobile') $contact_property = $obj->phone_mobile; |
|
2441 | + if ($mode == 'email') { |
|
2442 | + $contact_property = dolGetFirstLastname($obj->firstname, $obj->lastname)." <".$obj->email.">"; |
|
2443 | + } else if ($mode == 'mobile') { |
|
2444 | + $contact_property = $obj->phone_mobile; |
|
2445 | + } |
|
2314 | 2446 | } |
2315 | 2447 | return $contact_property; |
2316 | - } |
|
2317 | - else |
|
2448 | + } else |
|
2318 | 2449 | { |
2319 | 2450 | dol_print_error($this->db); |
2320 | 2451 | } |
@@ -2338,8 +2469,7 @@ discard block |
||
2338 | 2469 | if ($mode == 'label') |
2339 | 2470 | { |
2340 | 2471 | return $bac->getRibLabel(true); |
2341 | - } |
|
2342 | - elseif ($mode == 'rum') |
|
2472 | + } elseif ($mode == 'rum') |
|
2343 | 2473 | { |
2344 | 2474 | if (empty($bac->rum)) |
2345 | 2475 | { |
@@ -2349,8 +2479,7 @@ discard block |
||
2349 | 2479 | $bac->rum = $prelevement->buildRumNumber($bac->thirdparty->code_client, $bac->datec, $bac->id); |
2350 | 2480 | } |
2351 | 2481 | return $bac->rum; |
2352 | - } |
|
2353 | - elseif ($mode == 'format') |
|
2482 | + } elseif ($mode == 'format') |
|
2354 | 2483 | { |
2355 | 2484 | return $bac->frstrecur; |
2356 | 2485 | } |
@@ -2405,7 +2534,9 @@ discard block |
||
2405 | 2534 | foreach ($dirsociete as $dirroot) |
2406 | 2535 | { |
2407 | 2536 | $res=dol_include_once($dirroot.$module.'.php'); |
2408 | - if ($res) break; |
|
2537 | + if ($res) { |
|
2538 | + break; |
|
2539 | + } |
|
2409 | 2540 | } |
2410 | 2541 | $mod = new $module(); |
2411 | 2542 | |
@@ -2435,7 +2566,9 @@ discard block |
||
2435 | 2566 | foreach ($dirsociete as $dirroot) |
2436 | 2567 | { |
2437 | 2568 | $res=dol_include_once($dirroot.$module.'.php'); |
2438 | - if ($res) break; |
|
2569 | + if ($res) { |
|
2570 | + break; |
|
2571 | + } |
|
2439 | 2572 | } |
2440 | 2573 | $mod = new $module(); |
2441 | 2574 | |
@@ -2462,18 +2595,26 @@ discard block |
||
2462 | 2595 | foreach ($dirsociete as $dirroot) |
2463 | 2596 | { |
2464 | 2597 | $res=dol_include_once($dirroot.$module.'.php'); |
2465 | - if ($res) break; |
|
2598 | + if ($res) { |
|
2599 | + break; |
|
2600 | + } |
|
2466 | 2601 | } |
2467 | 2602 | |
2468 | 2603 | $mod = new $module(); |
2469 | 2604 | |
2470 | 2605 | dol_syslog(get_class($this)."::codeclient_modifiable code_client=".$this->code_client." module=".$module); |
2471 | - if ($mod->code_modifiable_null && ! $this->code_client) return 1; |
|
2472 | - if ($mod->code_modifiable_invalide && $this->check_codeclient() < 0) return 1; |
|
2473 | - if ($mod->code_modifiable) return 1; // A mettre en dernier |
|
2606 | + if ($mod->code_modifiable_null && ! $this->code_client) { |
|
2607 | + return 1; |
|
2608 | + } |
|
2609 | + if ($mod->code_modifiable_invalide && $this->check_codeclient() < 0) { |
|
2610 | + return 1; |
|
2611 | + } |
|
2612 | + if ($mod->code_modifiable) { |
|
2613 | + return 1; |
|
2614 | + } |
|
2615 | + // A mettre en dernier |
|
2474 | 2616 | return 0; |
2475 | - } |
|
2476 | - else |
|
2617 | + } else |
|
2477 | 2618 | { |
2478 | 2619 | return 0; |
2479 | 2620 | } |
@@ -2496,18 +2637,26 @@ discard block |
||
2496 | 2637 | foreach ($dirsociete as $dirroot) |
2497 | 2638 | { |
2498 | 2639 | $res=dol_include_once($dirroot.$module.'.php'); |
2499 | - if ($res) break; |
|
2640 | + if ($res) { |
|
2641 | + break; |
|
2642 | + } |
|
2500 | 2643 | } |
2501 | 2644 | |
2502 | 2645 | $mod = new $module(); |
2503 | 2646 | |
2504 | 2647 | dol_syslog(get_class($this)."::codefournisseur_modifiable code_founisseur=".$this->code_fournisseur." module=".$module); |
2505 | - if ($mod->code_modifiable_null && ! $this->code_fournisseur) return 1; |
|
2506 | - if ($mod->code_modifiable_invalide && $this->check_codefournisseur() < 0) return 1; |
|
2507 | - if ($mod->code_modifiable) return 1; // A mettre en dernier |
|
2648 | + if ($mod->code_modifiable_null && ! $this->code_fournisseur) { |
|
2649 | + return 1; |
|
2650 | + } |
|
2651 | + if ($mod->code_modifiable_invalide && $this->check_codefournisseur() < 0) { |
|
2652 | + return 1; |
|
2653 | + } |
|
2654 | + if ($mod->code_modifiable) { |
|
2655 | + return 1; |
|
2656 | + } |
|
2657 | + // A mettre en dernier |
|
2508 | 2658 | return 0; |
2509 | - } |
|
2510 | - else |
|
2659 | + } else |
|
2511 | 2660 | { |
2512 | 2661 | return 0; |
2513 | 2662 | } |
@@ -2534,7 +2683,9 @@ discard block |
||
2534 | 2683 | foreach ($dirsociete as $dirroot) |
2535 | 2684 | { |
2536 | 2685 | $res=dol_include_once($dirroot.$module.'.php'); |
2537 | - if ($res) break; |
|
2686 | + if ($res) { |
|
2687 | + break; |
|
2688 | + } |
|
2538 | 2689 | } |
2539 | 2690 | |
2540 | 2691 | $mod = new $module(); |
@@ -2542,8 +2693,7 @@ discard block |
||
2542 | 2693 | dol_syslog(get_class($this)."::check_codeclient code_client=".$this->code_client." module=".$module); |
2543 | 2694 | $result = $mod->verif($this->db, $this->code_client, $this, 0); |
2544 | 2695 | return $result; |
2545 | - } |
|
2546 | - else |
|
2696 | + } else |
|
2547 | 2697 | { |
2548 | 2698 | return 0; |
2549 | 2699 | } |
@@ -2569,7 +2719,9 @@ discard block |
||
2569 | 2719 | foreach ($dirsociete as $dirroot) |
2570 | 2720 | { |
2571 | 2721 | $res=dol_include_once($dirroot.$module.'.php'); |
2572 | - if ($res) break; |
|
2722 | + if ($res) { |
|
2723 | + break; |
|
2724 | + } |
|
2573 | 2725 | } |
2574 | 2726 | |
2575 | 2727 | $mod = new $module(); |
@@ -2577,8 +2729,7 @@ discard block |
||
2577 | 2729 | dol_syslog(get_class($this)."::check_codefournisseur code_fournisseur=".$this->code_fournisseur." module=".$module); |
2578 | 2730 | $result = $mod->verif($this->db, $this->code_fournisseur, $this, 1); |
2579 | 2731 | return $result; |
2580 | - } |
|
2581 | - else |
|
2732 | + } else |
|
2582 | 2733 | { |
2583 | 2734 | return 0; |
2584 | 2735 | } |
@@ -2619,21 +2770,25 @@ discard block |
||
2619 | 2770 | // Defini code compta dans $mod->code |
2620 | 2771 | $result = $mod->get_code($this->db, $this, $type); |
2621 | 2772 | |
2622 | - if ($type == 'customer') $this->code_compta = $mod->code; |
|
2623 | - else if ($type == 'supplier') $this->code_compta_fournisseur = $mod->code; |
|
2773 | + if ($type == 'customer') { |
|
2774 | + $this->code_compta = $mod->code; |
|
2775 | + } else if ($type == 'supplier') { |
|
2776 | + $this->code_compta_fournisseur = $mod->code; |
|
2777 | + } |
|
2624 | 2778 | |
2625 | 2779 | return $result; |
2626 | - } |
|
2627 | - else |
|
2780 | + } else |
|
2628 | 2781 | { |
2629 | 2782 | $this->error = 'ErrorAccountancyCodeNotDefined'; |
2630 | 2783 | return -1; |
2631 | 2784 | } |
2632 | - } |
|
2633 | - else |
|
2785 | + } else |
|
2634 | 2786 | { |
2635 | - if ($type == 'customer') $this->code_compta = ''; |
|
2636 | - else if ($type == 'supplier') $this->code_compta_fournisseur = ''; |
|
2787 | + if ($type == 'customer') { |
|
2788 | + $this->code_compta = ''; |
|
2789 | + } else if ($type == 'supplier') { |
|
2790 | + $this->code_compta_fournisseur = ''; |
|
2791 | + } |
|
2637 | 2792 | |
2638 | 2793 | return 0; |
2639 | 2794 | } |
@@ -2658,13 +2813,13 @@ discard block |
||
2658 | 2813 | { |
2659 | 2814 | $this->parent = $id; |
2660 | 2815 | return 1; |
2661 | - } |
|
2662 | - else |
|
2816 | + } else |
|
2663 | 2817 | { |
2664 | 2818 | return -1; |
2665 | 2819 | } |
2820 | + } else { |
|
2821 | + return -1; |
|
2666 | 2822 | } |
2667 | - else return -1; |
|
2668 | 2823 | } |
2669 | 2824 | |
2670 | 2825 | /** |
@@ -2744,22 +2899,26 @@ discard block |
||
2744 | 2899 | |
2745 | 2900 | //Verify duplicate entries |
2746 | 2901 | $sql = "SELECT COUNT(*) as idprof FROM ".MAIN_DB_PREFIX."societe WHERE ".$field." = '".$value."' AND entity IN (".getEntity('societe').")"; |
2747 | - if($socid) $sql .= " AND rowid <> ".$socid; |
|
2902 | + if($socid) { |
|
2903 | + $sql .= " AND rowid <> ".$socid; |
|
2904 | + } |
|
2748 | 2905 | $resql = $this->db->query($sql); |
2749 | 2906 | if ($resql) |
2750 | 2907 | { |
2751 | 2908 | $obj = $this->db->fetch_object($resql); |
2752 | 2909 | $count = $obj->idprof; |
2753 | - } |
|
2754 | - else |
|
2910 | + } else |
|
2755 | 2911 | { |
2756 | 2912 | $count = 0; |
2757 | 2913 | print $this->db->error(); |
2758 | 2914 | } |
2759 | 2915 | $this->db->free($resql); |
2760 | 2916 | |
2761 | - if ($count > 0) return true; |
|
2762 | - else return false; |
|
2917 | + if ($count > 0) { |
|
2918 | + return true; |
|
2919 | + } else { |
|
2920 | + return false; |
|
2921 | + } |
|
2763 | 2922 | } |
2764 | 2923 | |
2765 | 2924 | /** |
@@ -2776,7 +2935,9 @@ discard block |
||
2776 | 2935 | |
2777 | 2936 | $ok=1; |
2778 | 2937 | |
2779 | - if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) return 1; |
|
2938 | + if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) { |
|
2939 | + return 1; |
|
2940 | + } |
|
2780 | 2941 | |
2781 | 2942 | // Verifie SIREN si pays FR |
2782 | 2943 | if ($idprof == 1 && $soc->country_code == 'FR') |
@@ -2784,7 +2945,9 @@ discard block |
||
2784 | 2945 | $chaine=trim($this->idprof1); |
2785 | 2946 | $chaine=preg_replace('/(\s)/','',$chaine); |
2786 | 2947 | |
2787 | - if (dol_strlen($chaine) != 9) return -1; |
|
2948 | + if (dol_strlen($chaine) != 9) { |
|
2949 | + return -1; |
|
2950 | + } |
|
2788 | 2951 | |
2789 | 2952 | $sum = 0; |
2790 | 2953 | |
@@ -2804,7 +2967,9 @@ discard block |
||
2804 | 2967 | $sum = $sum + $ps; |
2805 | 2968 | } |
2806 | 2969 | |
2807 | - if (substr($sum, -1) != 0) return -1; |
|
2970 | + if (substr($sum, -1) != 0) { |
|
2971 | + return -1; |
|
2972 | + } |
|
2808 | 2973 | } |
2809 | 2974 | |
2810 | 2975 | // Verifie SIRET si pays FR |
@@ -2813,7 +2978,9 @@ discard block |
||
2813 | 2978 | $chaine=trim($this->idprof2); |
2814 | 2979 | $chaine=preg_replace('/(\s)/','',$chaine); |
2815 | 2980 | |
2816 | - if (dol_strlen($chaine) != 14) return -1; |
|
2981 | + if (dol_strlen($chaine) != 14) { |
|
2982 | + return -1; |
|
2983 | + } |
|
2817 | 2984 | } |
2818 | 2985 | |
2819 | 2986 | //Verify CIF/NIF/NIE if pays ES |
@@ -2824,53 +2991,61 @@ discard block |
||
2824 | 2991 | $string=preg_replace('/(\s)/','',$string); |
2825 | 2992 | $string = strtoupper($string); |
2826 | 2993 | |
2827 | - for ($i = 0; $i < 9; $i ++) |
|
2828 | - $num[$i] = substr($string, $i, 1); |
|
2994 | + for ($i = 0; $i < 9; $i ++) { |
|
2995 | + $num[$i] = substr($string, $i, 1); |
|
2996 | + } |
|
2829 | 2997 | |
2830 | 2998 | //Check format |
2831 | - if (!preg_match('/((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)/', $string)) |
|
2832 | - return 0; |
|
2999 | + if (!preg_match('/((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)/', $string)) { |
|
3000 | + return 0; |
|
3001 | + } |
|
2833 | 3002 | |
2834 | 3003 | //Check NIF |
2835 | - if (preg_match('/(^[0-9]{8}[A-Z]{1}$)/', $string)) |
|
2836 | - if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 0, 8) % 23, 1)) |
|
3004 | + if (preg_match('/(^[0-9]{8}[A-Z]{1}$)/', $string)) { |
|
3005 | + if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 0, 8) % 23, 1)) |
|
2837 | 3006 | return 1; |
2838 | - else |
|
2839 | - return -1; |
|
3007 | + } else { |
|
3008 | + return -1; |
|
3009 | + } |
|
2840 | 3010 | |
2841 | 3011 | //algorithm checking type code CIF |
2842 | 3012 | $sum = $num[2] + $num[4] + $num[6]; |
2843 | - for ($i = 1; $i < 8; $i += 2) |
|
2844 | - $sum += substr((2 * $num[$i]),0,1) + substr((2 * $num[$i]),1,1); |
|
3013 | + for ($i = 1; $i < 8; $i += 2) { |
|
3014 | + $sum += substr((2 * $num[$i]),0,1) + substr((2 * $num[$i]),1,1); |
|
3015 | + } |
|
2845 | 3016 | $n = 10 - substr($sum, strlen($sum) - 1, 1); |
2846 | 3017 | |
2847 | 3018 | //Chek special NIF |
2848 | - if (preg_match('/^[KLM]{1}/', $string)) |
|
2849 | - if ($num[8] == chr(64 + $n) || $num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 1, 8) % 23, 1)) |
|
3019 | + if (preg_match('/^[KLM]{1}/', $string)) { |
|
3020 | + if ($num[8] == chr(64 + $n) || $num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 1, 8) % 23, 1)) |
|
2850 | 3021 | return 1; |
2851 | - else |
|
2852 | - return -1; |
|
3022 | + } else { |
|
3023 | + return -1; |
|
3024 | + } |
|
2853 | 3025 | |
2854 | 3026 | //Check CIF |
2855 | - if (preg_match('/^[ABCDEFGHJNPQRSUVW]{1}/', $string)) |
|
2856 | - if ($num[8] == chr(64 + $n) || $num[8] == substr($n, strlen($n) - 1, 1)) |
|
3027 | + if (preg_match('/^[ABCDEFGHJNPQRSUVW]{1}/', $string)) { |
|
3028 | + if ($num[8] == chr(64 + $n) || $num[8] == substr($n, strlen($n) - 1, 1)) |
|
2857 | 3029 | return 2; |
2858 | - else |
|
2859 | - return -2; |
|
3030 | + } else { |
|
3031 | + return -2; |
|
3032 | + } |
|
2860 | 3033 | |
2861 | 3034 | //Check NIE T |
2862 | - if (preg_match('/^[T]{1}/', $string)) |
|
2863 | - if ($num[8] == preg_match('/^[T]{1}[A-Z0-9]{8}$/', $string)) |
|
3035 | + if (preg_match('/^[T]{1}/', $string)) { |
|
3036 | + if ($num[8] == preg_match('/^[T]{1}[A-Z0-9]{8}$/', $string)) |
|
2864 | 3037 | return 3; |
2865 | - else |
|
2866 | - return -3; |
|
3038 | + } else { |
|
3039 | + return -3; |
|
3040 | + } |
|
2867 | 3041 | |
2868 | 3042 | //Check NIE XYZ |
2869 | - if (preg_match('/^[XYZ]{1}/', $string)) |
|
2870 | - if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X','Y','Z'), array('0','1','2'), $string), 0, 8) % 23, 1)) |
|
3043 | + if (preg_match('/^[XYZ]{1}/', $string)) { |
|
3044 | + if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X','Y','Z'), array('0','1','2'), $string), 0, 8) % 23, 1)) |
|
2871 | 3045 | return 3; |
2872 | - else |
|
2873 | - return -3; |
|
3046 | + } else { |
|
3047 | + return -3; |
|
3048 | + } |
|
2874 | 3049 | |
2875 | 3050 | //Can not be verified |
2876 | 3051 | return -4; |
@@ -2899,17 +3074,27 @@ discard block |
||
2899 | 3074 | $reshook=$hookmanager->executeHooks('getIdProfUrl',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
2900 | 3075 | if (empty($reshook)) |
2901 | 3076 | { |
2902 | - if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) return ''; |
|
3077 | + if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) { |
|
3078 | + return ''; |
|
3079 | + } |
|
2903 | 3080 | |
2904 | 3081 | // TODO Move links to validate professional ID into a dictionary table "country" + "link" |
2905 | - if ($idprof == 1 && $thirdparty->country_code == 'FR') $url='http://www.societe.com/cgi-bin/search?champs='.$thirdparty->idprof1; // See also http://avis-situation-sirene.insee.fr/ |
|
3082 | + if ($idprof == 1 && $thirdparty->country_code == 'FR') { |
|
3083 | + $url='http://www.societe.com/cgi-bin/search?champs='.$thirdparty->idprof1; |
|
3084 | + } |
|
3085 | + // See also http://avis-situation-sirene.insee.fr/ |
|
2906 | 3086 | //if ($idprof == 1 && ($thirdparty->country_code == 'GB' || $thirdparty->country_code == 'UK')) $url='http://www.companieshouse.gov.uk/WebCHeck/findinfolink/'; // Link no more valid |
2907 | - if ($idprof == 1 && $thirdparty->country_code == 'ES') $url='http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/'.$thirdparty->idprof1; |
|
2908 | - if ($idprof == 1 && $thirdparty->country_code == 'IN') $url='http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$thirdparty->idprof1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp'; |
|
3087 | + if ($idprof == 1 && $thirdparty->country_code == 'ES') { |
|
3088 | + $url='http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/'.$thirdparty->idprof1; |
|
3089 | + } |
|
3090 | + if ($idprof == 1 && $thirdparty->country_code == 'IN') { |
|
3091 | + $url='http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$thirdparty->idprof1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp'; |
|
3092 | + } |
|
2909 | 3093 | |
2910 | - if ($url) return '<a target="_blank" href="'.$url.'">'.$langs->trans("Check").'</a>'; |
|
2911 | - } |
|
2912 | - else |
|
3094 | + if ($url) { |
|
3095 | + return '<a target="_blank" href="'.$url.'">'.$langs->trans("Check").'</a>'; |
|
3096 | + } |
|
3097 | + } else |
|
2913 | 3098 | { |
2914 | 3099 | return $hookmanager->resPrint; |
2915 | 3100 | } |
@@ -2930,8 +3115,7 @@ discard block |
||
2930 | 3115 | { |
2931 | 3116 | $obj = $this->db->fetch_object($resql); |
2932 | 3117 | $count = $obj->numproj; |
2933 | - } |
|
2934 | - else |
|
3118 | + } else |
|
2935 | 3119 | { |
2936 | 3120 | $count = 0; |
2937 | 3121 | print $this->db->error(); |
@@ -2982,8 +3166,7 @@ discard block |
||
2982 | 3166 | |
2983 | 3167 | $this->db->free($result); |
2984 | 3168 | |
2985 | - } |
|
2986 | - else |
|
3169 | + } else |
|
2987 | 3170 | { |
2988 | 3171 | dol_print_error($this->db); |
2989 | 3172 | } |
@@ -3000,9 +3183,13 @@ discard block |
||
3000 | 3183 | |
3001 | 3184 | // Define if third party is treated as company (or not) when nature is unknown |
3002 | 3185 | $isacompany=empty($conf->global->MAIN_UNKNOWN_CUSTOMERS_ARE_COMPANIES)?0:1; // 0 by default |
3003 | - if (! empty($this->tva_intra)) $isacompany=1; |
|
3004 | - else if (! empty($this->typent_code) && in_array($this->typent_code,array('TE_PRIVATE'))) $isacompany=0; |
|
3005 | - else if (! empty($this->typent_code) && in_array($this->typent_code,array('TE_SMALL','TE_MEDIUM','TE_LARGE','TE_GROUP'))) $isacompany=1; |
|
3186 | + if (! empty($this->tva_intra)) { |
|
3187 | + $isacompany=1; |
|
3188 | + } else if (! empty($this->typent_code) && in_array($this->typent_code,array('TE_PRIVATE'))) { |
|
3189 | + $isacompany=0; |
|
3190 | + } else if (! empty($this->typent_code) && in_array($this->typent_code,array('TE_SMALL','TE_MEDIUM','TE_LARGE','TE_GROUP'))) { |
|
3191 | + $isacompany=1; |
|
3192 | + } |
|
3006 | 3193 | |
3007 | 3194 | return $isacompany; |
3008 | 3195 | } |
@@ -3027,8 +3214,7 @@ discard block |
||
3027 | 3214 | $this->SupplierCategories[$obj->rowid] = $obj->label; |
3028 | 3215 | } |
3029 | 3216 | return 0; |
3030 | - } |
|
3031 | - else |
|
3217 | + } else |
|
3032 | 3218 | { |
3033 | 3219 | return -1; |
3034 | 3220 | } |
@@ -3047,9 +3233,10 @@ discard block |
||
3047 | 3233 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_fournisseur (fk_categorie, fk_soc) "; |
3048 | 3234 | $sql.= " VALUES (".$categorie_id.", ".$this->id.")"; |
3049 | 3235 | |
3050 | - if ($resql=$this->db->query($sql)) return 0; |
|
3051 | - } |
|
3052 | - else |
|
3236 | + if ($resql=$this->db->query($sql)) { |
|
3237 | + return 0; |
|
3238 | + } |
|
3239 | + } else |
|
3053 | 3240 | { |
3054 | 3241 | return 0; |
3055 | 3242 | } |
@@ -3070,7 +3257,9 @@ discard block |
||
3070 | 3257 | global $user,$langs; |
3071 | 3258 | |
3072 | 3259 | $name = $socname?$socname:$member->societe; |
3073 | - if (empty($name)) $name=$member->getFullName($langs); |
|
3260 | + if (empty($name)) { |
|
3261 | + $name=$member->getFullName($langs); |
|
3262 | + } |
|
3074 | 3263 | |
3075 | 3264 | $alias = $socalias?$socalias:''; |
3076 | 3265 | |
@@ -3107,16 +3296,14 @@ discard block |
||
3107 | 3296 | { |
3108 | 3297 | $this->db->commit(); |
3109 | 3298 | return $this->id; |
3110 | - } |
|
3111 | - else |
|
3299 | + } else |
|
3112 | 3300 | { |
3113 | 3301 | $this->error=$this->db->error(); |
3114 | 3302 | |
3115 | 3303 | $this->db->rollback(); |
3116 | 3304 | return -1; |
3117 | 3305 | } |
3118 | - } |
|
3119 | - else |
|
3306 | + } else |
|
3120 | 3307 | { |
3121 | 3308 | // $this->error deja positionne |
3122 | 3309 | dol_syslog(get_class($this)."::create_from_member - 2 - ".$this->error." - ".join(',',$this->errors), LOG_ERR); |
@@ -3162,12 +3349,13 @@ discard block |
||
3162 | 3349 | { |
3163 | 3350 | $tmp=explode(':',$conf->global->MAIN_INFO_SOCIETE_COUNTRY); |
3164 | 3351 | $country_id=$tmp[0]; |
3165 | - if (! empty($tmp[1])) // If $conf->global->MAIN_INFO_SOCIETE_COUNTRY is "id:code:label" |
|
3352 | + if (! empty($tmp[1])) { |
|
3353 | + // If $conf->global->MAIN_INFO_SOCIETE_COUNTRY is "id:code:label" |
|
3166 | 3354 | { |
3167 | 3355 | $country_code=$tmp[1]; |
3168 | - $country_label=$tmp[2]; |
|
3169 | 3356 | } |
3170 | - else // For backward compatibility |
|
3357 | + $country_label=$tmp[2]; |
|
3358 | + } else // For backward compatibility |
|
3171 | 3359 | { |
3172 | 3360 | dol_syslog("Your country setup use an old syntax. Reedit it using setup area.", LOG_ERR); |
3173 | 3361 | include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
@@ -3178,7 +3366,9 @@ discard block |
||
3178 | 3366 | $this->country_id=$country_id; |
3179 | 3367 | $this->country_code=$country_code; |
3180 | 3368 | $this->country=$country_label; |
3181 | - if (is_object($langs)) $this->country=($langs->trans('Country'.$country_code)!='Country'.$country_code)?$langs->trans('Country'.$country_code):$country_label; |
|
3369 | + if (is_object($langs)) { |
|
3370 | + $this->country=($langs->trans('Country'.$country_code)!='Country'.$country_code)?$langs->trans('Country'.$country_code):$country_label; |
|
3371 | + } |
|
3182 | 3372 | |
3183 | 3373 | $this->phone=empty($conf->global->MAIN_INFO_SOCIETE_TEL)?'':$conf->global->MAIN_INFO_SOCIETE_TEL; |
3184 | 3374 | $this->fax=empty($conf->global->MAIN_INFO_SOCIETE_FAX)?'':$conf->global->MAIN_INFO_SOCIETE_FAX; |
@@ -3270,17 +3460,22 @@ discard block |
||
3270 | 3460 | $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; |
3271 | 3461 | $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$this->db->escape($this->country_code)."'"; |
3272 | 3462 | $sql .= " AND t.active = 1"; |
3273 | - if (empty($localTaxNum)) $sql .= " AND (t.localtax1_type <> '0' OR t.localtax2_type <> '0')"; |
|
3274 | - elseif ($localTaxNum == 1) $sql .= " AND t.localtax1_type <> '0'"; |
|
3275 | - elseif ($localTaxNum == 2) $sql .= " AND t.localtax2_type <> '0'"; |
|
3463 | + if (empty($localTaxNum)) { |
|
3464 | + $sql .= " AND (t.localtax1_type <> '0' OR t.localtax2_type <> '0')"; |
|
3465 | + } elseif ($localTaxNum == 1) { |
|
3466 | + $sql .= " AND t.localtax1_type <> '0'"; |
|
3467 | + } elseif ($localTaxNum == 2) { |
|
3468 | + $sql .= " AND t.localtax2_type <> '0'"; |
|
3469 | + } |
|
3276 | 3470 | |
3277 | 3471 | dol_syslog("useLocalTax", LOG_DEBUG); |
3278 | 3472 | $resql=$this->db->query($sql); |
3279 | 3473 | if ($resql) |
3280 | 3474 | { |
3281 | 3475 | return ($this->db->num_rows($resql) > 0); |
3476 | + } else { |
|
3477 | + return false; |
|
3282 | 3478 | } |
3283 | - else return false; |
|
3284 | 3479 | } |
3285 | 3480 | |
3286 | 3481 | /** |
@@ -3300,8 +3495,9 @@ discard block |
||
3300 | 3495 | if ($resql) |
3301 | 3496 | { |
3302 | 3497 | return ($this->db->num_rows($resql) > 0); |
3498 | + } else { |
|
3499 | + return false; |
|
3303 | 3500 | } |
3304 | - else return false; |
|
3305 | 3501 | } |
3306 | 3502 | |
3307 | 3503 | /** |
@@ -3322,8 +3518,7 @@ discard block |
||
3322 | 3518 | { |
3323 | 3519 | $obj=$this->db->fetch_object($resql); |
3324 | 3520 | return (($obj->nb > 0)?true:false); |
3325 | - } |
|
3326 | - else |
|
3521 | + } else |
|
3327 | 3522 | { |
3328 | 3523 | $this->error=$this->db->lasterror(); |
3329 | 3524 | return false; |
@@ -3399,36 +3594,51 @@ discard block |
||
3399 | 3594 | |
3400 | 3595 | if ($mode == 2) |
3401 | 3596 | { |
3402 | - if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"),-1).' '.$langs->trans("StatusProspect-1"); |
|
3403 | - elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); |
|
3404 | - elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); |
|
3405 | - elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); |
|
3406 | - elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); |
|
3407 | - else |
|
3597 | + if ($statut == '-1' || $statut == 'ST_NO') { |
|
3598 | + return img_action($langs->trans("StatusProspect-1"),-1).' '.$langs->trans("StatusProspect-1"); |
|
3599 | + } elseif ($statut == '0' || $statut == 'ST_NEVER') { |
|
3600 | + return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); |
|
3601 | + } elseif ($statut == '1' || $statut == 'ST_TODO') { |
|
3602 | + return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); |
|
3603 | + } elseif ($statut == '2' || $statut == 'ST_PEND') { |
|
3604 | + return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); |
|
3605 | + } elseif ($statut == '3' || $statut == 'ST_DONE') { |
|
3606 | + return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); |
|
3607 | + } else |
|
3408 | 3608 | { |
3409 | 3609 | return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label); |
3410 | 3610 | } |
3411 | 3611 | } |
3412 | 3612 | if ($mode == 3) |
3413 | 3613 | { |
3414 | - if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"),-1); |
|
3415 | - elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0); |
|
3416 | - elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1); |
|
3417 | - elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2); |
|
3418 | - elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3); |
|
3419 | - else |
|
3614 | + if ($statut == '-1' || $statut == 'ST_NO') { |
|
3615 | + return img_action($langs->trans("StatusProspect-1"),-1); |
|
3616 | + } elseif ($statut == '0' || $statut == 'ST_NEVER') { |
|
3617 | + return img_action($langs->trans("StatusProspect0"), 0); |
|
3618 | + } elseif ($statut == '1' || $statut == 'ST_TODO') { |
|
3619 | + return img_action($langs->trans("StatusProspect1"), 1); |
|
3620 | + } elseif ($statut == '2' || $statut == 'ST_PEND') { |
|
3621 | + return img_action($langs->trans("StatusProspect2"), 2); |
|
3622 | + } elseif ($statut == '3' || $statut == 'ST_DONE') { |
|
3623 | + return img_action($langs->trans("StatusProspect3"), 3); |
|
3624 | + } else |
|
3420 | 3625 | { |
3421 | 3626 | return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0); |
3422 | 3627 | } |
3423 | 3628 | } |
3424 | 3629 | if ($mode == 4) |
3425 | 3630 | { |
3426 | - if ($statut == '-1' || $statut == 'ST_NO') return img_action($langs->trans("StatusProspect-1"),-1).' '.$langs->trans("StatusProspect-1"); |
|
3427 | - elseif ($statut == '0' || $statut == 'ST_NEVER') return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); |
|
3428 | - elseif ($statut == '1' || $statut == 'ST_TODO') return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); |
|
3429 | - elseif ($statut == '2' || $statut == 'ST_PEND') return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); |
|
3430 | - elseif ($statut == '3' || $statut == 'ST_DONE') return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); |
|
3431 | - else |
|
3631 | + if ($statut == '-1' || $statut == 'ST_NO') { |
|
3632 | + return img_action($langs->trans("StatusProspect-1"),-1).' '.$langs->trans("StatusProspect-1"); |
|
3633 | + } elseif ($statut == '0' || $statut == 'ST_NEVER') { |
|
3634 | + return img_action($langs->trans("StatusProspect0"), 0).' '.$langs->trans("StatusProspect0"); |
|
3635 | + } elseif ($statut == '1' || $statut == 'ST_TODO') { |
|
3636 | + return img_action($langs->trans("StatusProspect1"), 1).' '.$langs->trans("StatusProspect1"); |
|
3637 | + } elseif ($statut == '2' || $statut == 'ST_PEND') { |
|
3638 | + return img_action($langs->trans("StatusProspect2"), 2).' '.$langs->trans("StatusProspect2"); |
|
3639 | + } elseif ($statut == '3' || $statut == 'ST_DONE') { |
|
3640 | + return img_action($langs->trans("StatusProspect3"), 3).' '.$langs->trans("StatusProspect3"); |
|
3641 | + } else |
|
3432 | 3642 | { |
3433 | 3643 | return img_action(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label, 0).' '.(($langs->trans("StatusProspect".$statut) != "StatusProspect".$statut) ? $langs->trans("StatusProspect".$statut) : $label); |
3434 | 3644 | } |
@@ -3458,7 +3668,9 @@ discard block |
||
3458 | 3668 | function getOutstandingProposals($mode='customer') |
3459 | 3669 | { |
3460 | 3670 | $table='propal'; |
3461 | - if ($mode == 'supplier') $table = 'supplier_proposal'; |
|
3671 | + if ($mode == 'supplier') { |
|
3672 | + $table = 'supplier_proposal'; |
|
3673 | + } |
|
3462 | 3674 | |
3463 | 3675 | $sql = "SELECT rowid, total_ht, total as total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f"; |
3464 | 3676 | $sql .= " WHERE fk_soc = ". $this->id; |
@@ -3478,15 +3690,17 @@ discard block |
||
3478 | 3690 | while($obj=$this->db->fetch_object($resql)) { |
3479 | 3691 | $outstandingTotal+= $obj->total_ht; |
3480 | 3692 | $outstandingTotalIncTax+= $obj->total_ttc; |
3481 | - if ($obj->fk_statut != 0) // Not a draft |
|
3693 | + if ($obj->fk_statut != 0) { |
|
3694 | + // Not a draft |
|
3482 | 3695 | { |
3483 | 3696 | $outstandingOpened+=$obj->total_ttc; |
3484 | 3697 | } |
3698 | + } |
|
3485 | 3699 | } |
3486 | 3700 | return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' |
3701 | + } else { |
|
3702 | + return array(); |
|
3487 | 3703 | } |
3488 | - else |
|
3489 | - return array(); |
|
3490 | 3704 | } |
3491 | 3705 | |
3492 | 3706 | /** |
@@ -3498,7 +3712,9 @@ discard block |
||
3498 | 3712 | function getOutstandingOrders($mode='customer') |
3499 | 3713 | { |
3500 | 3714 | $table='commande'; |
3501 | - if ($mode == 'supplier') $table = 'commande_fournisseur'; |
|
3715 | + if ($mode == 'supplier') { |
|
3716 | + $table = 'commande_fournisseur'; |
|
3717 | + } |
|
3502 | 3718 | |
3503 | 3719 | $sql = "SELECT rowid, total_ht, total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f"; |
3504 | 3720 | $sql .= " WHERE fk_soc = ". $this->id; |
@@ -3518,15 +3734,17 @@ discard block |
||
3518 | 3734 | while($obj=$this->db->fetch_object($resql)) { |
3519 | 3735 | $outstandingTotal+= $obj->total_ht; |
3520 | 3736 | $outstandingTotalIncTax+= $obj->total_ttc; |
3521 | - if ($obj->fk_statut != 0) // Not a draft |
|
3737 | + if ($obj->fk_statut != 0) { |
|
3738 | + // Not a draft |
|
3522 | 3739 | { |
3523 | 3740 | $outstandingOpened+=$obj->total_ttc; |
3524 | 3741 | } |
3742 | + } |
|
3525 | 3743 | } |
3526 | 3744 | return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' |
3745 | + } else { |
|
3746 | + return array(); |
|
3527 | 3747 | } |
3528 | - else |
|
3529 | - return array(); |
|
3530 | 3748 | } |
3531 | 3749 | |
3532 | 3750 | /** |
@@ -3538,7 +3756,9 @@ discard block |
||
3538 | 3756 | function getOutstandingBills($mode='customer') |
3539 | 3757 | { |
3540 | 3758 | $table='facture'; |
3541 | - if ($mode == 'supplier') $table = 'facture_fourn'; |
|
3759 | + if ($mode == 'supplier') { |
|
3760 | + $table = 'facture_fourn'; |
|
3761 | + } |
|
3542 | 3762 | |
3543 | 3763 | /* Accurate value of remain to pay is to sum remaintopay for each invoice |
3544 | 3764 | $paiement = $invoice->getSommePaiement(); |
@@ -3547,8 +3767,11 @@ discard block |
||
3547 | 3767 | $alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT'); |
3548 | 3768 | $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); |
3549 | 3769 | */ |
3550 | - if ($mode == 'supplier') $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; |
|
3551 | - else $sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; |
|
3770 | + if ($mode == 'supplier') { |
|
3771 | + $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; |
|
3772 | + } else { |
|
3773 | + $sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; |
|
3774 | + } |
|
3552 | 3775 | $sql .= " WHERE fk_soc = ". $this->id; |
3553 | 3776 | if ($mode == 'supplier') { |
3554 | 3777 | $sql .= " AND entity IN (".getEntity('facture_fourn').")"; |
@@ -3567,8 +3790,7 @@ discard block |
||
3567 | 3790 | { |
3568 | 3791 | require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
3569 | 3792 | $tmpobject=new FactureFournisseur($this->db); |
3570 | - } |
|
3571 | - else |
|
3793 | + } else |
|
3572 | 3794 | { |
3573 | 3795 | require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
3574 | 3796 | $tmpobject=new Facture($this->db); |
@@ -3585,18 +3807,19 @@ discard block |
||
3585 | 3807 | if ($obj->paye == 0 |
3586 | 3808 | && $obj->fk_statut != 0 // Not a draft |
3587 | 3809 | && $obj->fk_statut != 3 // Not abandonned |
3588 | - && $obj->fk_statut != 2) // Not classified as paid |
|
3810 | + && $obj->fk_statut != 2) { |
|
3811 | + // Not classified as paid |
|
3589 | 3812 | //$sql .= " AND (fk_statut <> 3 OR close_code <> 'abandon')"; // Not abandonned for undefined reason |
3590 | 3813 | { |
3591 | 3814 | $paiement = $tmpobject->getSommePaiement(); |
3815 | + } |
|
3592 | 3816 | $creditnotes = $tmpobject->getSumCreditNotesUsed(); |
3593 | 3817 | $deposits = $tmpobject->getSumDepositsUsed(); |
3594 | 3818 | $outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits; |
3595 | 3819 | } |
3596 | 3820 | } |
3597 | 3821 | return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' |
3598 | - } |
|
3599 | - else |
|
3822 | + } else |
|
3600 | 3823 | { |
3601 | 3824 | return array(); |
3602 | 3825 | } |
@@ -3640,9 +3863,9 @@ discard block |
||
3640 | 3863 | $outstandingAmount+= $obj->total_ttc - $paiement - $creditnotes - $deposits; |
3641 | 3864 | } |
3642 | 3865 | return $outstandingAmount; |
3866 | + } else { |
|
3867 | + return 0; |
|
3643 | 3868 | } |
3644 | - else |
|
3645 | - return 0; |
|
3646 | 3869 | } |
3647 | 3870 | |
3648 | 3871 | /** |
@@ -3666,10 +3889,18 @@ discard block |
||
3666 | 3889 | global $langs; |
3667 | 3890 | $langs->load('companies'); |
3668 | 3891 | |
3669 | - if ($statut==0) return $langs->trans("NorProspectNorCustomer"); |
|
3670 | - if ($statut==1) return $langs->trans("Customer"); |
|
3671 | - if ($statut==2) return $langs->trans("Prospect"); |
|
3672 | - if ($statut==3) return $langs->trans("ProspectCustomer"); |
|
3892 | + if ($statut==0) { |
|
3893 | + return $langs->trans("NorProspectNorCustomer"); |
|
3894 | + } |
|
3895 | + if ($statut==1) { |
|
3896 | + return $langs->trans("Customer"); |
|
3897 | + } |
|
3898 | + if ($statut==2) { |
|
3899 | + return $langs->trans("Prospect"); |
|
3900 | + } |
|
3901 | + if ($statut==3) { |
|
3902 | + return $langs->trans("ProspectCustomer"); |
|
3903 | + } |
|
3673 | 3904 | |
3674 | 3905 | } |
3675 | 3906 | |
@@ -3696,10 +3927,11 @@ discard block |
||
3696 | 3927 | include_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; |
3697 | 3928 | $companybankaccount = new CompanyBankAccount($this->db); |
3698 | 3929 | $result = $companybankaccount->fetch($moreparams['use_companybankid']); |
3699 | - if (! $result) dol_print_error($this->db, $companybankaccount->error, $companybankaccount->errors); |
|
3930 | + if (! $result) { |
|
3931 | + dol_print_error($this->db, $companybankaccount->error, $companybankaccount->errors); |
|
3932 | + } |
|
3700 | 3933 | $result=$companybankaccount->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); |
3701 | - } |
|
3702 | - else |
|
3934 | + } else |
|
3703 | 3935 | { |
3704 | 3936 | // Positionne le modele sur le nom du modele a utiliser |
3705 | 3937 | if (! dol_strlen($modele)) |
@@ -3707,8 +3939,7 @@ discard block |
||
3707 | 3939 | if (! empty($conf->global->COMPANY_ADDON_PDF)) |
3708 | 3940 | { |
3709 | 3941 | $modele = $conf->global->COMPANY_ADDON_PDF; |
3710 | - } |
|
3711 | - else |
|
3942 | + } else |
|
3712 | 3943 | { |
3713 | 3944 | print $langs->trans("Error")." ".$langs->trans("Error_COMPANY_ADDON_PDF_NotDefined"); |
3714 | 3945 | return 0; |
@@ -42,16 +42,24 @@ discard block |
||
42 | 42 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
43 | 43 | require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; |
44 | 44 | require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
45 | -if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
|
45 | +if (! empty($conf->adherent->enabled)) { |
|
46 | + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
|
47 | +} |
|
46 | 48 | |
47 | 49 | $langs->load("companies"); |
48 | 50 | $langs->load("commercial"); |
49 | 51 | $langs->load("bills"); |
50 | 52 | $langs->load("banks"); |
51 | 53 | $langs->load("users"); |
52 | -if (! empty($conf->categorie->enabled)) $langs->load("categories"); |
|
53 | -if (! empty($conf->incoterm->enabled)) $langs->load("incoterm"); |
|
54 | -if (! empty($conf->notification->enabled)) $langs->load("mails"); |
|
54 | +if (! empty($conf->categorie->enabled)) { |
|
55 | + $langs->load("categories"); |
|
56 | +} |
|
57 | +if (! empty($conf->incoterm->enabled)) { |
|
58 | + $langs->load("incoterm"); |
|
59 | +} |
|
60 | +if (! empty($conf->notification->enabled)) { |
|
61 | + $langs->load("mails"); |
|
62 | +} |
|
55 | 63 | |
56 | 64 | $mesg=''; $error=0; $errors=array(); |
57 | 65 | |
@@ -61,8 +69,12 @@ discard block |
||
61 | 69 | $confirm = GETPOST('confirm'); |
62 | 70 | |
63 | 71 | $socid = GETPOST('socid','int')?GETPOST('socid','int'):GETPOST('id','int'); |
64 | -if ($user->societe_id) $socid=$user->societe_id; |
|
65 | -if (empty($socid) && $action == 'view') $action='create'; |
|
72 | +if ($user->societe_id) { |
|
73 | + $socid=$user->societe_id; |
|
74 | +} |
|
75 | +if (empty($socid) && $action == 'view') { |
|
76 | + $action='create'; |
|
77 | +} |
|
66 | 78 | |
67 | 79 | $object = new Societe($db); |
68 | 80 | $extrafields = new ExtraFields($db); |
@@ -101,7 +113,9 @@ discard block |
||
101 | 113 | |
102 | 114 | $parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas); |
103 | 115 | $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
104 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
116 | +if ($reshook < 0) { |
|
117 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
118 | +} |
|
105 | 119 | |
106 | 120 | if (empty($reshook)) |
107 | 121 | { |
@@ -128,8 +142,7 @@ discard block |
||
128 | 142 | $langs->load('errors'); |
129 | 143 | $langs->load('companies'); |
130 | 144 | setEventMessages($langs->trans('ErrorThirdPartyIdIsMandatory', $langs->trans('MergeOriginThirdparty')), null, 'errors'); |
131 | - } |
|
132 | - else |
|
145 | + } else |
|
133 | 146 | { |
134 | 147 | if (!$error && $soc_origin->fetch($soc_origin_id) < 1) |
135 | 148 | { |
@@ -156,7 +169,9 @@ discard block |
||
156 | 169 | ); |
157 | 170 | foreach ($listofproperties as $property) |
158 | 171 | { |
159 | - if (empty($object->$property)) $object->$property = $soc_origin->$property; |
|
172 | + if (empty($object->$property)) { |
|
173 | + $object->$property = $soc_origin->$property; |
|
174 | + } |
|
160 | 175 | } |
161 | 176 | |
162 | 177 | // Concat some data |
@@ -173,7 +188,9 @@ discard block |
||
173 | 188 | { |
174 | 189 | foreach ($soc_origin->array_options as $key => $val) |
175 | 190 | { |
176 | - if (empty($object->array_options[$key])) $object->array_options[$key] = $val; |
|
191 | + if (empty($object->array_options[$key])) { |
|
192 | + $object->array_options[$key] = $val; |
|
193 | + } |
|
177 | 194 | } |
178 | 195 | } |
179 | 196 | |
@@ -286,8 +303,7 @@ discard block |
||
286 | 303 | { |
287 | 304 | setEventMessages($langs->trans('ThirdpartiesMergeSuccess'), null, 'mesgs'); |
288 | 305 | $db->commit(); |
289 | - } |
|
290 | - else |
|
306 | + } else |
|
291 | 307 | { |
292 | 308 | $langs->load("errors"); |
293 | 309 | setEventMessages($langs->trans('ErrorsThirdpartyMerge'), null, 'errors'); |
@@ -332,7 +348,9 @@ discard block |
||
332 | 348 | // Fill array 'array_options' with data from update form |
333 | 349 | $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); |
334 | 350 | $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); |
335 | - if ($ret < 0) $error++; |
|
351 | + if ($ret < 0) { |
|
352 | + $error++; |
|
353 | + } |
|
336 | 354 | |
337 | 355 | if (! $error) |
338 | 356 | { |
@@ -344,7 +362,9 @@ discard block |
||
344 | 362 | } |
345 | 363 | } |
346 | 364 | |
347 | - if ($error) $action = 'edit_extras'; |
|
365 | + if ($error) { |
|
366 | + $action = 'edit_extras'; |
|
367 | + } |
|
348 | 368 | } |
349 | 369 | |
350 | 370 | // Add new or update third party |
@@ -376,20 +396,22 @@ discard block |
||
376 | 396 | { |
377 | 397 | $ret=$object->fetch($socid); |
378 | 398 | $object->oldcopy = clone $object; |
379 | - } |
|
380 | - else $object->canvas=$canvas; |
|
399 | + } else { |
|
400 | + $object->canvas=$canvas; |
|
401 | + } |
|
381 | 402 | |
382 | - if (GETPOST("private") == 1) // Ask to create a contact |
|
403 | + if (GETPOST("private") == 1) { |
|
404 | + // Ask to create a contact |
|
383 | 405 | { |
384 | 406 | $object->particulier = GETPOST("private"); |
407 | + } |
|
385 | 408 | |
386 | 409 | $object->name = dolGetFirstLastname(GETPOST('firstname','alpha'),GETPOST('name','alpha')); |
387 | 410 | $object->civility_id = GETPOST('civility_id'); // Note: civility id is a code, not an int |
388 | 411 | // Add non official properties |
389 | 412 | $object->name_bis = GETPOST('name','alpha'); |
390 | 413 | $object->firstname = GETPOST('firstname','alpha'); |
391 | - } |
|
392 | - else |
|
414 | + } else |
|
393 | 415 | { |
394 | 416 | $object->name = GETPOST('name', 'alpha'); |
395 | 417 | } |
@@ -464,8 +486,11 @@ discard block |
||
464 | 486 | $error++; |
465 | 487 | } |
466 | 488 | |
467 | - if (GETPOST('deletephoto')) $object->logo = ''; |
|
468 | - else if (! empty($_FILES['photo']['name'])) $object->logo = dol_sanitizeFileName($_FILES['photo']['name']); |
|
489 | + if (GETPOST('deletephoto')) { |
|
490 | + $object->logo = ''; |
|
491 | + } else if (! empty($_FILES['photo']['name'])) { |
|
492 | + $object->logo = dol_sanitizeFileName($_FILES['photo']['name']); |
|
493 | + } |
|
469 | 494 | |
470 | 495 | // Check parameters |
471 | 496 | if (! GETPOST('cancel','alpha')) |
@@ -517,8 +542,12 @@ discard block |
||
517 | 542 | |
518 | 543 | $db->begin(); |
519 | 544 | |
520 | - if (empty($object->client)) $object->code_client=''; |
|
521 | - if (empty($object->fournisseur)) $object->code_fournisseur=''; |
|
545 | + if (empty($object->client)) { |
|
546 | + $object->code_client=''; |
|
547 | + } |
|
548 | + if (empty($object->fournisseur)) { |
|
549 | + $object->code_fournisseur=''; |
|
550 | + } |
|
522 | 551 | |
523 | 552 | $result = $object->create($user); |
524 | 553 | |
@@ -570,16 +599,14 @@ discard block |
||
570 | 599 | if (! $result > 0) |
571 | 600 | { |
572 | 601 | $errors[] = "ErrorFailedToSaveFile"; |
573 | - } |
|
574 | - else |
|
602 | + } else |
|
575 | 603 | { |
576 | 604 | // Create thumbs |
577 | 605 | $object->addThumbs($newfile); |
578 | 606 | } |
579 | 607 | } |
580 | 608 | } |
581 | - } |
|
582 | - else |
|
609 | + } else |
|
583 | 610 | { |
584 | 611 | switch($_FILES['photo']['error']) |
585 | 612 | { |
@@ -593,12 +620,13 @@ discard block |
||
593 | 620 | } |
594 | 621 | } |
595 | 622 | // Gestion du logo de la société |
596 | - } |
|
597 | - else |
|
623 | + } else |
|
598 | 624 | { |
599 | - if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') // TODO Sometime errors on duplicate on profid and not on code, so we must manage this case |
|
625 | + if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { |
|
626 | + // TODO Sometime errors on duplicate on profid and not on code, so we must manage this case |
|
600 | 627 | { |
601 | 628 | $duplicate_code_error = true; |
629 | + } |
|
602 | 630 | $object->code_fournisseur = null; |
603 | 631 | $object->code_client = null; |
604 | 632 | } |
@@ -613,21 +641,24 @@ discard block |
||
613 | 641 | |
614 | 642 | if (! empty($backtopage)) |
615 | 643 | { |
616 | - if (preg_match('/\?/', $backtopage)) $backtopage.='&socid='.$object->id; |
|
644 | + if (preg_match('/\?/', $backtopage)) { |
|
645 | + $backtopage.='&socid='.$object->id; |
|
646 | + } |
|
617 | 647 | header("Location: ".$backtopage); |
618 | 648 | exit; |
619 | - } |
|
620 | - else |
|
649 | + } else |
|
621 | 650 | { |
622 | 651 | $url=$_SERVER["PHP_SELF"]."?socid=".$object->id; |
623 | - if (($object->client == 1 || $object->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $url=DOL_URL_ROOT."/comm/card.php?socid=".$object->id; |
|
624 | - else if ($object->fournisseur == 1) $url=DOL_URL_ROOT."/fourn/card.php?socid=".$object->id; |
|
652 | + if (($object->client == 1 || $object->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { |
|
653 | + $url=DOL_URL_ROOT."/comm/card.php?socid=".$object->id; |
|
654 | + } else if ($object->fournisseur == 1) { |
|
655 | + $url=DOL_URL_ROOT."/fourn/card.php?socid=".$object->id; |
|
656 | + } |
|
625 | 657 | |
626 | 658 | header("Location: ".$url); |
627 | 659 | exit; |
628 | 660 | } |
629 | - } |
|
630 | - else |
|
661 | + } else |
|
631 | 662 | { |
632 | 663 | $db->rollback(); |
633 | 664 | $action='create'; |
@@ -644,8 +675,7 @@ discard block |
||
644 | 675 | { |
645 | 676 | header("Location: ".$backtopage); |
646 | 677 | exit; |
647 | - } |
|
648 | - else |
|
678 | + } else |
|
649 | 679 | { |
650 | 680 | header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid); |
651 | 681 | exit; |
@@ -653,8 +683,12 @@ discard block |
||
653 | 683 | } |
654 | 684 | |
655 | 685 | // To not set code if third party is not concerned. But if it had values, we keep them. |
656 | - if (empty($object->client) && empty($object->oldcopy->code_client)) $object->code_client=''; |
|
657 | - if (empty($object->fournisseur)&& empty($object->oldcopy->code_fournisseur)) $object->code_fournisseur=''; |
|
686 | + if (empty($object->client) && empty($object->oldcopy->code_client)) { |
|
687 | + $object->code_client=''; |
|
688 | + } |
|
689 | + if (empty($object->fournisseur)&& empty($object->oldcopy->code_fournisseur)) { |
|
690 | + $object->code_fournisseur=''; |
|
691 | + } |
|
658 | 692 | //var_dump($object);exit; |
659 | 693 | |
660 | 694 | $result = $object->update($socid, $user, 1, $object->oldcopy->codeclient_modifiable(), $object->oldcopy->codefournisseur_modifiable(), 'update', 0); |
@@ -710,8 +744,7 @@ discard block |
||
710 | 744 | if (! $result > 0) |
711 | 745 | { |
712 | 746 | $errors[] = "ErrorFailedToSaveFile"; |
713 | - } |
|
714 | - else |
|
747 | + } else |
|
715 | 748 | { |
716 | 749 | // Create thumbs |
717 | 750 | $object->addThumbs($newfile); |
@@ -727,13 +760,11 @@ discard block |
||
727 | 760 | } |
728 | 761 | } |
729 | 762 | } |
730 | - } |
|
731 | - else |
|
763 | + } else |
|
732 | 764 | { |
733 | 765 | $errors[] = "ErrorBadImageFormat"; |
734 | 766 | } |
735 | - } |
|
736 | - else |
|
767 | + } else |
|
737 | 768 | { |
738 | 769 | switch($_FILES['photo']['error']) |
739 | 770 | { |
@@ -768,21 +799,18 @@ discard block |
||
768 | 799 | { |
769 | 800 | header("Location: ".$backtopage); |
770 | 801 | exit; |
771 | - } |
|
772 | - else |
|
802 | + } else |
|
773 | 803 | { |
774 | 804 | header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid); |
775 | 805 | exit; |
776 | 806 | } |
777 | - } |
|
778 | - else |
|
807 | + } else |
|
779 | 808 | { |
780 | 809 | $object->id = $socid; |
781 | 810 | $action= "edit"; |
782 | 811 | } |
783 | 812 | } |
784 | - } |
|
785 | - else |
|
813 | + } else |
|
786 | 814 | { |
787 | 815 | $action = ($action=='add'?'create':'edit'); |
788 | 816 | } |
@@ -798,8 +826,7 @@ discard block |
||
798 | 826 | { |
799 | 827 | header("Location: ".DOL_URL_ROOT."/societe/list.php?delsoc=".urlencode($object->name)); |
800 | 828 | exit; |
801 | - } |
|
802 | - else |
|
829 | + } else |
|
803 | 830 | { |
804 | 831 | $langs->load("errors"); |
805 | 832 | setEventMessages($object->error, $object->errors, 'errors'); |
@@ -850,11 +877,15 @@ discard block |
||
850 | 877 | if ($socid > 0 && empty($object->id)) |
851 | 878 | { |
852 | 879 | $result=$object->fetch($socid); |
853 | - if ($result <= 0) dol_print_error('',$object->error); |
|
854 | -} |
|
880 | + if ($result <= 0) { |
|
881 | + dol_print_error('',$object->error); |
|
882 | + } |
|
883 | + } |
|
855 | 884 | |
856 | 885 | $title=$langs->trans("ThirdParty"); |
857 | -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$langs->trans('Card'); |
|
886 | +if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) { |
|
887 | + $title=$object->name." - ".$langs->trans('Card'); |
|
888 | +} |
|
858 | 889 | $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; |
859 | 890 | llxHeader('',$title,$help_url); |
860 | 891 | |
@@ -867,8 +898,7 @@ discard block |
||
867 | 898 | // ----------------------------------------- |
868 | 899 | $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates |
869 | 900 | $objcanvas->display_canvas($action); // Show template |
870 | -} |
|
871 | -else |
|
901 | +} else |
|
872 | 902 | { |
873 | 903 | // ----------------------------------------- |
874 | 904 | // When used in standard mode |
@@ -879,8 +909,12 @@ discard block |
||
879 | 909 | * Creation |
880 | 910 | */ |
881 | 911 | $private=GETPOST("private","int"); |
882 | - if (! empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT) && ! isset($_GET['private']) && ! isset($_POST['private'])) $private=1; |
|
883 | - if (empty($private)) $private=0; |
|
912 | + if (! empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT) && ! isset($_GET['private']) && ! isset($_POST['private'])) { |
|
913 | + $private=1; |
|
914 | + } |
|
915 | + if (empty($private)) { |
|
916 | + $private=0; |
|
917 | + } |
|
884 | 918 | |
885 | 919 | // Load object modCodeTiers |
886 | 920 | $module=(! empty($conf->global->SOCIETE_CODECLIENT_ADDON)?$conf->global->SOCIETE_CODECLIENT_ADDON:'mod_codeclient_leopard'); |
@@ -892,7 +926,9 @@ discard block |
||
892 | 926 | foreach ($dirsociete as $dirroot) |
893 | 927 | { |
894 | 928 | $res=dol_include_once($dirroot.$module.'.php'); |
895 | - if ($res) break; |
|
929 | + if ($res) { |
|
930 | + break; |
|
931 | + } |
|
896 | 932 | } |
897 | 933 | $modCodeClient = new $module; |
898 | 934 | // Load object modCodeFournisseur |
@@ -905,7 +941,9 @@ discard block |
||
905 | 941 | foreach ($dirsociete as $dirroot) |
906 | 942 | { |
907 | 943 | $res=dol_include_once($dirroot.$module.'.php'); |
908 | - if ($res) break; |
|
944 | + if ($res) { |
|
945 | + break; |
|
946 | + } |
|
909 | 947 | } |
910 | 948 | $modCodeFournisseur = new $module; |
911 | 949 | |
@@ -928,8 +966,7 @@ discard block |
||
928 | 966 | if(empty($duplicate_code_error)) { |
929 | 967 | $object->code_client = GETPOST('code_client', 'alpha'); |
930 | 968 | $object->fournisseur = GETPOST('fournisseur')?GETPOST('fournisseur'):$object->fournisseur; |
931 | - } |
|
932 | - else { |
|
969 | + } else { |
|
933 | 970 | setEventMessages($langs->trans('NewCustomerSupplierCodeProposed'),'', 'warnings'); |
934 | 971 | } |
935 | 972 | |
@@ -989,8 +1026,7 @@ discard block |
||
989 | 1026 | if (! $result > 0) |
990 | 1027 | { |
991 | 1028 | $errors[] = "ErrorFailedToSaveFile"; |
992 | - } |
|
993 | - else |
|
1029 | + } else |
|
994 | 1030 | { |
995 | 1031 | // Create thumbs |
996 | 1032 | $object->addThumbs($newfile); |
@@ -1078,7 +1114,9 @@ discard block |
||
1078 | 1114 | print '<input type="hidden" name="type" value='.GETPOST("type",'alpha').'>'; |
1079 | 1115 | print '<input type="hidden" name="LastName" value="'.$langs->trans('ThirdPartyName').' / '.$langs->trans('LastName').'">'; |
1080 | 1116 | print '<input type="hidden" name="ThirdPartyName" value="'.$langs->trans('ThirdPartyName').'">'; |
1081 | - if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print '<input type="hidden" name="code_auto" value="1">'; |
|
1117 | + if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) { |
|
1118 | + print '<input type="hidden" name="code_auto" value="1">'; |
|
1119 | + } |
|
1082 | 1120 | |
1083 | 1121 | dol_fiche_head(null, 'card', '', 0, ''); |
1084 | 1122 | |
@@ -1089,17 +1127,18 @@ discard block |
||
1089 | 1127 | if ($object->particulier || $private) |
1090 | 1128 | { |
1091 | 1129 | print '<span id="TypeName" class="fieldrequired">'.$langs->trans('ThirdPartyName').' / '.$langs->trans('LastName','name').'</span>'; |
1092 | - } |
|
1093 | - else |
|
1130 | + } else |
|
1094 | 1131 | { |
1095 | 1132 | print '<span id="TypeName" class="fieldrequired">'.fieldLabel('ThirdPartyName','name').'</span>'; |
1096 | 1133 | } |
1097 | 1134 | print '</td><td'.(empty($conf->global->SOCIETE_USEPREFIX)?' colspan="3"':'').'>'; |
1098 | 1135 | print '<input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.$object->name.'" autofocus="autofocus"></td>'; |
1099 | - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
1136 | + if (! empty($conf->global->SOCIETE_USEPREFIX)) { |
|
1137 | + // Old not used prefix field |
|
1100 | 1138 | { |
1101 | 1139 | print '<td>'.$langs->trans('Prefix').'</td><td><input type="text" size="5" maxlength="5" name="prefix_comm" value="'.$object->prefix_comm.'"></td>'; |
1102 | 1140 | } |
1141 | + } |
|
1103 | 1142 | print '</tr>'; |
1104 | 1143 | |
1105 | 1144 | // If javascript on, we show option individual |
@@ -1123,17 +1162,27 @@ discard block |
||
1123 | 1162 | print '<td class="maxwidthonsmartphone">'; |
1124 | 1163 | $selected=GETPOST('client','int')!=''?GETPOST('client','int'):$object->client; |
1125 | 1164 | print '<select class="flat" name="client" id="customerprospect">'; |
1126 | - if (GETPOST("type") == '') print '<option value="-1"> </option>'; |
|
1127 | - if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="2"'.($selected==2?' selected':'').'>'.$langs->trans('Prospect').'</option>'; |
|
1128 | - if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) print '<option value="3"'.($selected==3?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>'; |
|
1129 | - if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="1"'.($selected==1?' selected':'').'>'.$langs->trans('Customer').'</option>'; |
|
1165 | + if (GETPOST("type") == '') { |
|
1166 | + print '<option value="-1"> </option>'; |
|
1167 | + } |
|
1168 | + if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { |
|
1169 | + print '<option value="2"'.($selected==2?' selected':'').'>'.$langs->trans('Prospect').'</option>'; |
|
1170 | + } |
|
1171 | + if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) { |
|
1172 | + print '<option value="3"'.($selected==3?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>'; |
|
1173 | + } |
|
1174 | + if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { |
|
1175 | + print '<option value="1"'.($selected==1?' selected':'').'>'.$langs->trans('Customer').'</option>'; |
|
1176 | + } |
|
1130 | 1177 | print '<option value="0"'.((string) $selected == '0'?' selected':'').'>'.$langs->trans('NorProspectNorCustomer').'</option>'; |
1131 | 1178 | print '</select></td>'; |
1132 | 1179 | |
1133 | 1180 | print '<td>'.fieldLabel('CustomerCode','customer_code').'</td><td>'; |
1134 | 1181 | print '<table class="nobordernopadding"><tr><td>'; |
1135 | 1182 | $tmpcode=$object->code_client; |
1136 | - if (empty($tmpcode) && ! empty($modCodeClient->code_auto)) $tmpcode=$modCodeClient->getNextValue($object,0); |
|
1183 | + if (empty($tmpcode) && ! empty($modCodeClient->code_auto)) { |
|
1184 | + $tmpcode=$modCodeClient->getNextValue($object,0); |
|
1185 | + } |
|
1137 | 1186 | print '<input type="text" name="code_client" id="customer_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).'" maxlength="15">'; |
1138 | 1187 | print '</td><td>'; |
1139 | 1188 | $s=$modCodeClient->getToolTip($langs,$object,0); |
@@ -1147,13 +1196,17 @@ discard block |
||
1147 | 1196 | print '<tr>'; |
1148 | 1197 | print '<td>'.fieldLabel('Supplier','fournisseur',1).'</td><td>'; |
1149 | 1198 | $default = -1; |
1150 | - if (! empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)) $default=1; |
|
1199 | + if (! empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)) { |
|
1200 | + $default=1; |
|
1201 | + } |
|
1151 | 1202 | print $form->selectyesno("fournisseur", (GETPOST('fournisseur','int')!=''?GETPOST('fournisseur','int'):(GETPOST("type",'alpha') == '' ? $default : $object->fournisseur)), 1, 0, (GETPOST("type",'alpha') == '' ? 1 : 0)); |
1152 | 1203 | print '</td>'; |
1153 | 1204 | print '<td>'.fieldLabel('SupplierCode','supplier_code').'</td><td>'; |
1154 | 1205 | print '<table class="nobordernopadding"><tr><td>'; |
1155 | 1206 | $tmpcode=$object->code_fournisseur; |
1156 | - if (empty($tmpcode) && ! empty($modCodeFournisseur->code_auto)) $tmpcode=$modCodeFournisseur->getNextValue($object,1); |
|
1207 | + if (empty($tmpcode) && ! empty($modCodeFournisseur->code_auto)) { |
|
1208 | + $tmpcode=$modCodeFournisseur->getNextValue($object,1); |
|
1209 | + } |
|
1157 | 1210 | print '<input type="text" name="code_fournisseur" id="supplier_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).'" maxlength="15">'; |
1158 | 1211 | print '</td><td>'; |
1159 | 1212 | $s=$modCodeFournisseur->getToolTip($langs,$object,1); |
@@ -1191,7 +1244,9 @@ discard block |
||
1191 | 1244 | // Country |
1192 | 1245 | print '<tr><td>'.fieldLabel('Country','selectcountry_id').'</td><td colspan="3" class="maxwidthonsmartphone">'; |
1193 | 1246 | print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id)); |
1194 | - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
1247 | + if ($user->admin) { |
|
1248 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
1249 | + } |
|
1195 | 1250 | print '</td></tr>'; |
1196 | 1251 | |
1197 | 1252 | // State |
@@ -1200,14 +1255,16 @@ discard block |
||
1200 | 1255 | if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) |
1201 | 1256 | { |
1202 | 1257 | print '<tr><td>'.fieldLabel('Region-State','state_id').'</td><td colspan="3" class="maxwidthonsmartphone">'; |
1203 | - } |
|
1204 | - else |
|
1258 | + } else |
|
1205 | 1259 | { |
1206 | 1260 | print '<tr><td>'.fieldLabel('State','state_id').'</td><td colspan="3" class="maxwidthonsmartphone">'; |
1207 | 1261 | } |
1208 | 1262 | |
1209 | - if ($object->country_id) print $formcompany->select_state($object->state_id,$object->country_code); |
|
1210 | - else print $countrynotdefined; |
|
1263 | + if ($object->country_id) { |
|
1264 | + print $formcompany->select_state($object->state_id,$object->country_code); |
|
1265 | + } else { |
|
1266 | + print $countrynotdefined; |
|
1267 | + } |
|
1211 | 1268 | print '</td></tr>'; |
1212 | 1269 | } |
1213 | 1270 | |
@@ -1239,19 +1296,25 @@ discard block |
||
1239 | 1296 | { |
1240 | 1297 | $key='idprof'.$i; |
1241 | 1298 | |
1242 | - if (($j % 2) == 0) print '<tr>'; |
|
1299 | + if (($j % 2) == 0) { |
|
1300 | + print '<tr>'; |
|
1301 | + } |
|
1243 | 1302 | |
1244 | 1303 | $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; |
1245 | 1304 | print '<td>'.fieldLabel($idprof,$key, (empty($conf->global->$idprof_mandatory)?0:1)).'</td><td>'; |
1246 | 1305 | |
1247 | 1306 | print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code); |
1248 | 1307 | print '</td>'; |
1249 | - if (($j % 2) == 1) print '</tr>'; |
|
1308 | + if (($j % 2) == 1) { |
|
1309 | + print '</tr>'; |
|
1310 | + } |
|
1250 | 1311 | $j++; |
1251 | 1312 | } |
1252 | 1313 | $i++; |
1253 | 1314 | } |
1254 | - if ($j % 2 == 1) print '<td colspan="2"></td></tr>'; |
|
1315 | + if ($j % 2 == 1) { |
|
1316 | + print '<td colspan="2"></td></tr>'; |
|
1317 | + } |
|
1255 | 1318 | |
1256 | 1319 | // Vat is used |
1257 | 1320 | print '<tr><td>'.fieldLabel('VATIsUsed','assujtva_value').'</td>'; |
@@ -1277,8 +1340,7 @@ discard block |
||
1277 | 1340 | print "\n"; |
1278 | 1341 | $s.='<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>'; |
1279 | 1342 | $s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); |
1280 | - } |
|
1281 | - else |
|
1343 | + } else |
|
1282 | 1344 | { |
1283 | 1345 | $s.='<a href="'.$langs->transcountry("VATIntraCheckURL",$object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>'; |
1284 | 1346 | } |
@@ -1297,14 +1359,12 @@ discard block |
||
1297 | 1359 | print $form->selectyesno('localtax2assuj_value',(isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2:0),1); |
1298 | 1360 | print '</td></tr>'; |
1299 | 1361 | |
1300 | - } |
|
1301 | - elseif($mysoc->localtax1_assuj=="1") |
|
1362 | + } elseif($mysoc->localtax1_assuj=="1") |
|
1302 | 1363 | { |
1303 | 1364 | print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code).'</td><td colspan="3">'; |
1304 | 1365 | print $form->selectyesno('localtax1assuj_value',(isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1:0),1); |
1305 | 1366 | print '</td></tr>'; |
1306 | - } |
|
1307 | - elseif($mysoc->localtax2_assuj=="1") |
|
1367 | + } elseif($mysoc->localtax2_assuj=="1") |
|
1308 | 1368 | { |
1309 | 1369 | print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td colspan="3">'; |
1310 | 1370 | print $form->selectyesno('localtax2assuj_value',(isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2:0),1); |
@@ -1315,11 +1375,15 @@ discard block |
||
1315 | 1375 | print '<tr><td>'.fieldLabel('ThirdPartyType','typent_id').'</td><td class="maxwidthonsmartphone">'."\n"; |
1316 | 1376 | $sortparam=(empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. |
1317 | 1377 | print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 0, 0, 0, '', 0, 0, 0, $sortparam); |
1318 | - if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
1378 | + if ($user->admin) { |
|
1379 | + print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
1380 | + } |
|
1319 | 1381 | print '</td>'; |
1320 | 1382 | print '<td>'.fieldLabel('Staff','effectif_id').'</td><td class="maxwidthonsmartphone">'; |
1321 | 1383 | print $form->selectarray("effectif_id", $formcompany->effectif_array(0), $object->effectif_id); |
1322 | - if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
1384 | + if ($user->admin) { |
|
1385 | + print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
1386 | + } |
|
1323 | 1387 | print '</td></tr>'; |
1324 | 1388 | |
1325 | 1389 | // Legal Form |
@@ -1328,8 +1392,7 @@ discard block |
||
1328 | 1392 | if ($object->country_id) |
1329 | 1393 | { |
1330 | 1394 | print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code'); |
1331 | - } |
|
1332 | - else |
|
1395 | + } else |
|
1333 | 1396 | { |
1334 | 1397 | print $countrynotdefined; |
1335 | 1398 | } |
@@ -1429,8 +1492,7 @@ discard block |
||
1429 | 1492 | { |
1430 | 1493 | print ' '; |
1431 | 1494 | print '<input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">'; |
1432 | - } |
|
1433 | - else |
|
1495 | + } else |
|
1434 | 1496 | { |
1435 | 1497 | print ' '; |
1436 | 1498 | print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">'; |
@@ -1438,8 +1500,7 @@ discard block |
||
1438 | 1500 | print '</div>'."\n"; |
1439 | 1501 | |
1440 | 1502 | print '</form>'."\n"; |
1441 | - } |
|
1442 | - elseif ($action == 'edit') |
|
1503 | + } elseif ($action == 'edit') |
|
1443 | 1504 | { |
1444 | 1505 | /* |
1445 | 1506 | * Edition |
@@ -1465,7 +1526,9 @@ discard block |
||
1465 | 1526 | foreach ($dirsociete as $dirroot) |
1466 | 1527 | { |
1467 | 1528 | $res=dol_include_once($dirroot.$module.'.php'); |
1468 | - if ($res) break; |
|
1529 | + if ($res) { |
|
1530 | + break; |
|
1531 | + } |
|
1469 | 1532 | } |
1470 | 1533 | $modCodeClient = new $module($db); |
1471 | 1534 | // We verified if the tag prefix is used |
@@ -1482,7 +1545,9 @@ discard block |
||
1482 | 1545 | foreach ($dirsociete as $dirroot) |
1483 | 1546 | { |
1484 | 1547 | $res=dol_include_once($dirroot.$module.'.php'); |
1485 | - if ($res) break; |
|
1548 | + if ($res) { |
|
1549 | + break; |
|
1550 | + } |
|
1486 | 1551 | } |
1487 | 1552 | $modCodeFournisseur = new $module($db); |
1488 | 1553 | // On verifie si la balise prefix est utilisee |
@@ -1558,10 +1623,10 @@ discard block |
||
1558 | 1623 | |
1559 | 1624 | if($object->localtax1_assuj==0){ |
1560 | 1625 | $sub=0; |
1561 | - }else{$sub=1;} |
|
1626 | + } else{$sub=1;} |
|
1562 | 1627 | if($object->localtax2_assuj==0){ |
1563 | 1628 | $sub2=0; |
1564 | - }else{$sub2=1;} |
|
1629 | + } else{$sub2=1;} |
|
1565 | 1630 | |
1566 | 1631 | print "\n".'<script type="text/javascript">'; |
1567 | 1632 | print '$(document).ready(function () { |
@@ -1618,7 +1683,9 @@ discard block |
||
1618 | 1683 | print '<input type="hidden" name="action" value="update">'; |
1619 | 1684 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
1620 | 1685 | print '<input type="hidden" name="socid" value="'.$object->id.'">'; |
1621 | - if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print '<input type="hidden" name="code_auto" value="1">'; |
|
1686 | + if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) { |
|
1687 | + print '<input type="hidden" name="code_auto" value="1">'; |
|
1688 | + } |
|
1622 | 1689 | |
1623 | 1690 | |
1624 | 1691 | dol_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company'); |
@@ -1643,16 +1710,17 @@ discard block |
||
1643 | 1710 | print '<td colspan="3"><input type="text" class="minwidth300" name="name_alias" id="name_alias_input" value="'.dol_escape_htmltag($object->name_alias).'"></td></tr>'; |
1644 | 1711 | |
1645 | 1712 | // Prefix |
1646 | - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
1713 | + if (! empty($conf->global->SOCIETE_USEPREFIX)) { |
|
1714 | + // Old not used prefix field |
|
1647 | 1715 | { |
1648 | 1716 | print '<tr><td>'.fieldLabel('Prefix','prefix').'</td><td colspan="3">'; |
1717 | + } |
|
1649 | 1718 | // It does not change the prefix mode using the auto numbering prefix |
1650 | 1719 | if (($prefixCustomerIsUsed || $prefixSupplierIsUsed) && $object->prefix_comm) |
1651 | 1720 | { |
1652 | 1721 | print '<input type="hidden" name="prefix_comm" value="'.dol_escape_htmltag($object->prefix_comm).'">'; |
1653 | 1722 | print $object->prefix_comm; |
1654 | - } |
|
1655 | - else |
|
1723 | + } else |
|
1656 | 1724 | { |
1657 | 1725 | print '<input type="text" size="5" maxlength="5" name="prefix_comm" id="prefix" value="'.dol_escape_htmltag($object->prefix_comm).'">'; |
1658 | 1726 | } |
@@ -1662,9 +1730,15 @@ discard block |
||
1662 | 1730 | // Prospect/Customer |
1663 | 1731 | print '<tr><td>'.fieldLabel('ProspectCustomer','customerprospect',1).'</td>'; |
1664 | 1732 | print '<td class="maxwidthonsmartphone"><select class="flat" name="client" id="customerprospect">'; |
1665 | - if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="2"'.($object->client==2?' selected':'').'>'.$langs->trans('Prospect').'</option>'; |
|
1666 | - if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="3"'.($object->client==3?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>'; |
|
1667 | - if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="1"'.($object->client==1?' selected':'').'>'.$langs->trans('Customer').'</option>'; |
|
1733 | + if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { |
|
1734 | + print '<option value="2"'.($object->client==2?' selected':'').'>'.$langs->trans('Prospect').'</option>'; |
|
1735 | + } |
|
1736 | + if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { |
|
1737 | + print '<option value="3"'.($object->client==3?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>'; |
|
1738 | + } |
|
1739 | + if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { |
|
1740 | + print '<option value="1"'.($object->client==1?' selected':'').'>'.$langs->trans('Customer').'</option>'; |
|
1741 | + } |
|
1668 | 1742 | print '<option value="0"'.($object->client==0?' selected':'').'>'.$langs->trans('NorProspectNorCustomer').'</option>'; |
1669 | 1743 | print '</select></td>'; |
1670 | 1744 | print '<td>'.fieldLabel('CustomerCode','customer_code').'</td><td>'; |
@@ -1673,15 +1747,18 @@ discard block |
||
1673 | 1747 | if ((!$object->code_client || $object->code_client == -1) && $modCodeClient->code_auto) |
1674 | 1748 | { |
1675 | 1749 | $tmpcode=$object->code_client; |
1676 | - if (empty($tmpcode) && ! empty($object->oldcopy->code_client)) $tmpcode=$object->oldcopy->code_client; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value. |
|
1677 | - if (empty($tmpcode) && ! empty($modCodeClient->code_auto)) $tmpcode=$modCodeClient->getNextValue($object,0); |
|
1750 | + if (empty($tmpcode) && ! empty($object->oldcopy->code_client)) { |
|
1751 | + $tmpcode=$object->oldcopy->code_client; |
|
1752 | + } |
|
1753 | + // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value. |
|
1754 | + if (empty($tmpcode) && ! empty($modCodeClient->code_auto)) { |
|
1755 | + $tmpcode=$modCodeClient->getNextValue($object,0); |
|
1756 | + } |
|
1678 | 1757 | print '<input type="text" name="code_client" id="customer_code" size="16" value="'.dol_escape_htmltag($tmpcode).'" maxlength="15">'; |
1679 | - } |
|
1680 | - else if ($object->codeclient_modifiable()) |
|
1758 | + } else if ($object->codeclient_modifiable()) |
|
1681 | 1759 | { |
1682 | 1760 | print '<input type="text" name="code_client" id="customer_code" size="16" value="'.$object->code_client.'" maxlength="15">'; |
1683 | - } |
|
1684 | - else |
|
1761 | + } else |
|
1685 | 1762 | { |
1686 | 1763 | print $object->code_client; |
1687 | 1764 | print '<input type="hidden" name="code_client" value="'.$object->code_client.'">'; |
@@ -1706,15 +1783,18 @@ discard block |
||
1706 | 1783 | if ((!$object->code_fournisseur || $object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) |
1707 | 1784 | { |
1708 | 1785 | $tmpcode=$object->code_fournisseur; |
1709 | - if (empty($tmpcode) && ! empty($object->oldcopy->code_fournisseur)) $tmpcode=$object->oldcopy->code_fournisseur; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value. |
|
1710 | - if (empty($tmpcode) && ! empty($modCodeFournisseur->code_auto)) $tmpcode=$modCodeFournisseur->getNextValue($object,1); |
|
1786 | + if (empty($tmpcode) && ! empty($object->oldcopy->code_fournisseur)) { |
|
1787 | + $tmpcode=$object->oldcopy->code_fournisseur; |
|
1788 | + } |
|
1789 | + // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value. |
|
1790 | + if (empty($tmpcode) && ! empty($modCodeFournisseur->code_auto)) { |
|
1791 | + $tmpcode=$modCodeFournisseur->getNextValue($object,1); |
|
1792 | + } |
|
1711 | 1793 | print '<input type="text" name="code_fournisseur" id="supplier_code" size="16" value="'.dol_escape_htmltag($tmpcode).'" maxlength="15">'; |
1712 | - } |
|
1713 | - else if ($object->codefournisseur_modifiable()) |
|
1794 | + } else if ($object->codefournisseur_modifiable()) |
|
1714 | 1795 | { |
1715 | 1796 | print '<input type="text" name="code_fournisseur" id="supplier_code" size="16" value="'.$object->code_fournisseur.'" maxlength="15">'; |
1716 | - } |
|
1717 | - else |
|
1797 | + } else |
|
1718 | 1798 | { |
1719 | 1799 | print $object->code_fournisseur; |
1720 | 1800 | print '<input type="hidden" name="code_fournisseur" value="'.$object->code_fournisseur.'">'; |
@@ -1756,7 +1836,9 @@ discard block |
||
1756 | 1836 | // Country |
1757 | 1837 | print '<tr><td>'.fieldLabel('Country','selectcounty_id').'</td><td colspan="3">'; |
1758 | 1838 | print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id),'country_id'); |
1759 | - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
1839 | + if ($user->admin) { |
|
1840 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
1841 | + } |
|
1760 | 1842 | print '</td></tr>'; |
1761 | 1843 | |
1762 | 1844 | // State |
@@ -1765,8 +1847,7 @@ discard block |
||
1765 | 1847 | if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) |
1766 | 1848 | { |
1767 | 1849 | print '<tr><td>'.fieldLabel('Region-State','state_id').'</td><td colspan="3">'; |
1768 | - } |
|
1769 | - else |
|
1850 | + } else |
|
1770 | 1851 | { |
1771 | 1852 | print '<tr><td>'.fieldLabel('State','state_id').'</td><td colspan="3">'; |
1772 | 1853 | } |
@@ -1803,22 +1884,29 @@ discard block |
||
1803 | 1884 | { |
1804 | 1885 | $key='idprof'.$i; |
1805 | 1886 | |
1806 | - if (($j % 2) == 0) print '<tr>'; |
|
1887 | + if (($j % 2) == 0) { |
|
1888 | + print '<tr>'; |
|
1889 | + } |
|
1807 | 1890 | |
1808 | 1891 | $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; |
1809 | - if (empty($conf->global->$idprof_mandatory) || ! $object->isACompany()) |
|
1810 | - print '<td>'.fieldLabel($idprof,$key).'</td><td>'; |
|
1811 | - else |
|
1812 | - print '<td><span class="fieldrequired">'.fieldLabel($idprof,$key).'</td><td>'; |
|
1892 | + if (empty($conf->global->$idprof_mandatory) || ! $object->isACompany()) { |
|
1893 | + print '<td>'.fieldLabel($idprof,$key).'</td><td>'; |
|
1894 | + } else { |
|
1895 | + print '<td><span class="fieldrequired">'.fieldLabel($idprof,$key).'</td><td>'; |
|
1896 | + } |
|
1813 | 1897 | |
1814 | 1898 | print $formcompany->get_input_id_prof($i,$key,$object->$key,$object->country_code); |
1815 | 1899 | print '</td>'; |
1816 | - if (($j % 2) == 1) print '</tr>'; |
|
1900 | + if (($j % 2) == 1) { |
|
1901 | + print '</tr>'; |
|
1902 | + } |
|
1817 | 1903 | $j++; |
1818 | 1904 | } |
1819 | 1905 | $i++; |
1820 | 1906 | } |
1821 | - if ($j % 2 == 1) print '<td colspan="2"></td></tr>'; |
|
1907 | + if ($j % 2 == 1) { |
|
1908 | + print '<td colspan="2"></td></tr>'; |
|
1909 | + } |
|
1822 | 1910 | |
1823 | 1911 | // VAT is used |
1824 | 1912 | print '<tr><td>'.fieldLabel('VATIsUsed','assujtva_value').'</td><td colspan="3">'; |
@@ -1849,8 +1937,7 @@ discard block |
||
1849 | 1937 | } |
1850 | 1938 | print '</td></tr>'; |
1851 | 1939 | |
1852 | - } |
|
1853 | - elseif($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj!="1") |
|
1940 | + } elseif($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj!="1") |
|
1854 | 1941 | { |
1855 | 1942 | print '<tr><td>'.fieldLabel($langs->transcountry("LocalTax1IsUsed",$mysoc->country_code),'localtax1assuj_value').'</td><td colspan="3">'; |
1856 | 1943 | print $form->selectyesno('localtax1assuj_value',$object->localtax1_assuj,1); |
@@ -1862,8 +1949,7 @@ discard block |
||
1862 | 1949 | } |
1863 | 1950 | print '</td></tr>'; |
1864 | 1951 | |
1865 | - } |
|
1866 | - elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1") |
|
1952 | + } elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1") |
|
1867 | 1953 | { |
1868 | 1954 | print '<tr><td>'.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').'</td><td colspan="3">'; |
1869 | 1955 | print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1); |
@@ -1896,8 +1982,7 @@ discard block |
||
1896 | 1982 | print "\n"; |
1897 | 1983 | $s.='<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>'; |
1898 | 1984 | $s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); |
1899 | - } |
|
1900 | - else |
|
1985 | + } else |
|
1901 | 1986 | { |
1902 | 1987 | $s.='<a href="'.$langs->transcountry("VATIntraCheckURL",$object->country_id).'" class="hideonsmartphone" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>'; |
1903 | 1988 | } |
@@ -1909,11 +1994,15 @@ discard block |
||
1909 | 1994 | // Type - Size |
1910 | 1995 | print '<tr><td>'.fieldLabel('ThirdPartyType','typent_id').'</td><td class="maxwidthonsmartphone">'; |
1911 | 1996 | print $form->selectarray("typent_id",$formcompany->typent_array(0), $object->typent_id, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); |
1912 | - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
1997 | + if ($user->admin) { |
|
1998 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
1999 | + } |
|
1913 | 2000 | print '</td>'; |
1914 | 2001 | print '<td>'.fieldLabel('Staff','effectif_id').'</td><td class="maxwidthonsmartphone">'; |
1915 | 2002 | print $form->selectarray("effectif_id",$formcompany->effectif_array(0), $object->effectif_id); |
1916 | - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
2003 | + if ($user->admin) { |
|
2004 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
2005 | + } |
|
1917 | 2006 | print '</td></tr>'; |
1918 | 2007 | |
1919 | 2008 | // Juridical type |
@@ -2009,13 +2098,19 @@ discard block |
||
2009 | 2098 | print '<tr class="hideonsmartphone">'; |
2010 | 2099 | print '<td>'.fieldLabel('Logo','photoinput').'</td>'; |
2011 | 2100 | print '<td colspan="3">'; |
2012 | - if ($object->logo) print $form->showphoto('societe',$object); |
|
2101 | + if ($object->logo) { |
|
2102 | + print $form->showphoto('societe',$object); |
|
2103 | + } |
|
2013 | 2104 | $caneditfield=1; |
2014 | 2105 | if ($caneditfield) |
2015 | 2106 | { |
2016 | - if ($object->logo) print "<br>\n"; |
|
2107 | + if ($object->logo) { |
|
2108 | + print "<br>\n"; |
|
2109 | + } |
|
2017 | 2110 | print '<table class="nobordernopadding">'; |
2018 | - if ($object->logo) print '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>'; |
|
2111 | + if ($object->logo) { |
|
2112 | + print '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>'; |
|
2113 | + } |
|
2019 | 2114 | //print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>'; |
2020 | 2115 | print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>'; |
2021 | 2116 | print '</table>'; |
@@ -2036,14 +2131,15 @@ discard block |
||
2036 | 2131 | |
2037 | 2132 | print '</form>'; |
2038 | 2133 | } |
2039 | - } |
|
2040 | - else |
|
2134 | + } else |
|
2041 | 2135 | { |
2042 | 2136 | /* |
2043 | 2137 | * View |
2044 | 2138 | */ |
2045 | 2139 | |
2046 | - if (!empty($object->id)) $res=$object->fetch_optionals(); |
|
2140 | + if (!empty($object->id)) { |
|
2141 | + $res=$object->fetch_optionals(); |
|
2142 | + } |
|
2047 | 2143 | //if ($res < 0) { dol_print_error($db); exit; } |
2048 | 2144 | |
2049 | 2145 | |
@@ -2098,9 +2194,11 @@ discard block |
||
2098 | 2194 | } |
2099 | 2195 | |
2100 | 2196 | // Prefix |
2101 | - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
2197 | + if (! empty($conf->global->SOCIETE_USEPREFIX)) { |
|
2198 | + // Old not used prefix field |
|
2102 | 2199 | { |
2103 | 2200 | print '<tr><td>'.$langs->trans('Prefix').'</td><td>'.$object->prefix_comm.'</td>'; |
2201 | + } |
|
2104 | 2202 | print $htmllogobar; $htmllogobar=''; |
2105 | 2203 | print '</tr>'; |
2106 | 2204 | } |
@@ -2111,7 +2209,9 @@ discard block |
||
2111 | 2209 | print '<tr><td>'; |
2112 | 2210 | print $langs->trans('CustomerCode').'</td><td>'; |
2113 | 2211 | print $object->code_client; |
2114 | - if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; |
|
2212 | + if ($object->check_codeclient() <> 0) { |
|
2213 | + print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; |
|
2214 | + } |
|
2115 | 2215 | print '</td>'; |
2116 | 2216 | print $htmllogobar; $htmllogobar=''; |
2117 | 2217 | print '</tr>'; |
@@ -2123,7 +2223,9 @@ discard block |
||
2123 | 2223 | print '<tr><td>'; |
2124 | 2224 | print $langs->trans('SupplierCode').'</td><td>'; |
2125 | 2225 | print $object->code_fournisseur; |
2126 | - if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; |
|
2226 | + if ($object->check_codefournisseur() <> 0) { |
|
2227 | + print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; |
|
2228 | + } |
|
2127 | 2229 | print '</td>'; |
2128 | 2230 | print $htmllogobar; $htmllogobar=''; |
2129 | 2231 | print '</tr>'; |
@@ -2135,7 +2237,9 @@ discard block |
||
2135 | 2237 | print '<tr><td>'; |
2136 | 2238 | print $langs->trans('Gencod').'</td><td>'.$object->barcode; |
2137 | 2239 | print '</td>'; |
2138 | - if ($htmllogobar) $htmllogobar.=$form->showbarcode($object); |
|
2240 | + if ($htmllogobar) { |
|
2241 | + $htmllogobar.=$form->showbarcode($object); |
|
2242 | + } |
|
2139 | 2243 | print $htmllogobar; |
2140 | 2244 | $htmllogobar=''; |
2141 | 2245 | print '</tr>'; |
@@ -2155,8 +2259,11 @@ discard block |
||
2155 | 2259 | print $object->$key; |
2156 | 2260 | if ($object->$key) |
2157 | 2261 | { |
2158 | - if ($object->id_prof_check($i,$object) > 0) print ' '.$object->id_prof_url($i,$object); |
|
2159 | - else print ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>'; |
|
2262 | + if ($object->id_prof_check($i,$object) > 0) { |
|
2263 | + print ' '.$object->id_prof_url($i,$object); |
|
2264 | + } else { |
|
2265 | + print ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>'; |
|
2266 | + } |
|
2160 | 2267 | } |
2161 | 2268 | print '</td>'; |
2162 | 2269 | //if (($j % 2) == 1) print '</tr>'; |
@@ -2196,8 +2303,7 @@ discard block |
||
2196 | 2303 | print '<td align="left">'; |
2197 | 2304 | $formcompany->select_localtax(1,$object->localtax1_value, "lt1"); |
2198 | 2305 | print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; |
2199 | - } |
|
2200 | - else |
|
2306 | + } else |
|
2201 | 2307 | { |
2202 | 2308 | print '<td>'.$object->localtax1_value.'</td>'; |
2203 | 2309 | } |
@@ -2213,13 +2319,12 @@ discard block |
||
2213 | 2319 | print '<td align="left">'; |
2214 | 2320 | $formcompany->select_localtax(2,$object->localtax2_value, "lt2"); |
2215 | 2321 | print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; |
2216 | - }else{ |
|
2322 | + } else{ |
|
2217 | 2323 | print '<td>'.$object->localtax2_value.'</td>'; |
2218 | 2324 | } |
2219 | 2325 | print '</tr></form>'; |
2220 | 2326 | } |
2221 | - } |
|
2222 | - elseif($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj!="1") |
|
2327 | + } elseif($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj!="1") |
|
2223 | 2328 | { |
2224 | 2329 | print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code).'</td><td>'; |
2225 | 2330 | print yn($object->localtax1_assuj); |
@@ -2234,14 +2339,13 @@ discard block |
||
2234 | 2339 | print '<td align="left">'; |
2235 | 2340 | $formcompany->select_localtax(1,$object->localtax1_value, "lt1"); |
2236 | 2341 | print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; |
2237 | - }else{ |
|
2342 | + } else{ |
|
2238 | 2343 | print '<td>'.$object->localtax1_value.'</td>'; |
2239 | 2344 | } |
2240 | 2345 | print '</tr></form>'; |
2241 | 2346 | |
2242 | 2347 | } |
2243 | - } |
|
2244 | - elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1") |
|
2348 | + } elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1") |
|
2245 | 2349 | { |
2246 | 2350 | print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td>'; |
2247 | 2351 | print yn($object->localtax2_assuj); |
@@ -2257,7 +2361,7 @@ discard block |
||
2257 | 2361 | print '<td align="left">'; |
2258 | 2362 | $formcompany->select_localtax(2,$object->localtax2_value, "lt2"); |
2259 | 2363 | print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; |
2260 | - }else{ |
|
2364 | + } else{ |
|
2261 | 2365 | print '<td>'.$object->localtax2_value.'</td>'; |
2262 | 2366 | } |
2263 | 2367 | print '</tr></form>'; |
@@ -2297,15 +2401,13 @@ discard block |
||
2297 | 2401 | print "\n"; |
2298 | 2402 | $s.='<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT( $(\'#tva_intra\').val() );">'.$langs->trans("VATIntraCheck").'</a>'; |
2299 | 2403 | $s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); |
2300 | - } |
|
2301 | - else |
|
2404 | + } else |
|
2302 | 2405 | { |
2303 | 2406 | $s.='<a href="'.$langs->transcountry("VATIntraCheckURL",$object->country_id).'" class="hideonsmartphone" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>'; |
2304 | 2407 | } |
2305 | 2408 | } |
2306 | 2409 | print $s; |
2307 | - } |
|
2308 | - else |
|
2410 | + } else |
|
2309 | 2411 | { |
2310 | 2412 | print ' '; |
2311 | 2413 | } |
@@ -2351,8 +2453,11 @@ discard block |
||
2351 | 2453 | |
2352 | 2454 | // Capital |
2353 | 2455 | print '<tr><td>'.$langs->trans('Capital').'</td><td>'; |
2354 | - if ($object->capital) print price($object->capital,'',$langs,0,-1,-1, $conf->currency); |
|
2355 | - else print ' '; |
|
2456 | + if ($object->capital) { |
|
2457 | + print price($object->capital,'',$langs,0,-1,-1, $conf->currency); |
|
2458 | + } else { |
|
2459 | + print ' '; |
|
2460 | + } |
|
2356 | 2461 | print '</td></tr>'; |
2357 | 2462 | |
2358 | 2463 | // Default language |
@@ -2375,16 +2480,18 @@ discard block |
||
2375 | 2480 | print '<table width="100%" class="nobordernopadding"><tr><td>'; |
2376 | 2481 | print $langs->trans('IncotermLabel'); |
2377 | 2482 | print '<td><td align="right">'; |
2378 | - if ($user->rights->societe->creer) print '<a href="'.DOL_URL_ROOT.'/societe/card.php?socid='.$object->id.'&action=editincoterm">'.img_edit('',1).'</a>'; |
|
2379 | - else print ' '; |
|
2483 | + if ($user->rights->societe->creer) { |
|
2484 | + print '<a href="'.DOL_URL_ROOT.'/societe/card.php?socid='.$object->id.'&action=editincoterm">'.img_edit('',1).'</a>'; |
|
2485 | + } else { |
|
2486 | + print ' '; |
|
2487 | + } |
|
2380 | 2488 | print '</td></tr></table>'; |
2381 | 2489 | print '</td>'; |
2382 | 2490 | print '<td colspan="3">'; |
2383 | 2491 | if ($action != 'editincoterm') |
2384 | 2492 | { |
2385 | 2493 | print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1); |
2386 | - } |
|
2387 | - else |
|
2494 | + } else |
|
2388 | 2495 | { |
2389 | 2496 | print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?socid='.$object->id); |
2390 | 2497 | } |
@@ -2413,14 +2520,15 @@ discard block |
||
2413 | 2520 | print '<table class="nobordernopadding" width="100%"><tr><td>'; |
2414 | 2521 | print $langs->trans('ParentCompany'); |
2415 | 2522 | print '</td>'; |
2416 | - if ($action != 'editparentcompany') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editparentcompany&socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</a></td>'; |
|
2523 | + if ($action != 'editparentcompany') { |
|
2524 | + print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editparentcompany&socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</a></td>'; |
|
2525 | + } |
|
2417 | 2526 | print '</tr></table>'; |
2418 | 2527 | print '</td><td colspan="3">'; |
2419 | 2528 | if ($action == 'editparentcompany') |
2420 | 2529 | { |
2421 | 2530 | $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->parent,'editparentcompany','s.rowid <> '.$object->id,1); |
2422 | - } |
|
2423 | - else |
|
2531 | + } else |
|
2424 | 2532 | { |
2425 | 2533 | $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->parent,'none','s.rowid <> '.$object->id,1); |
2426 | 2534 | } |
@@ -2443,8 +2551,7 @@ discard block |
||
2443 | 2551 | { |
2444 | 2552 | $adh->ref=$adh->getFullName($langs); |
2445 | 2553 | print $adh->getNomUrl(1); |
2446 | - } |
|
2447 | - else |
|
2554 | + } else |
|
2448 | 2555 | { |
2449 | 2556 | print '<span class="opacitymedium">'.$langs->trans("ThirdpartyNotLinkedToMember").'</span>'; |
2450 | 2557 | } |
@@ -2493,8 +2600,7 @@ discard block |
||
2493 | 2600 | { |
2494 | 2601 | $langs->load("mails"); |
2495 | 2602 | print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>'; |
2496 | - } |
|
2497 | - else |
|
2603 | + } else |
|
2498 | 2604 | { |
2499 | 2605 | $langs->load("mails"); |
2500 | 2606 | print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans('SendMail').'</a></div>'; |
@@ -2512,11 +2618,12 @@ discard block |
||
2512 | 2618 | |
2513 | 2619 | if ($user->rights->societe->supprimer) |
2514 | 2620 | { |
2515 | - if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) // We can't use preloaded confirm form with jmobile |
|
2621 | + if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) { |
|
2622 | + // We can't use preloaded confirm form with jmobile |
|
2516 | 2623 | { |
2517 | 2624 | print '<div class="inline-block divButAction"><span id="action-delete" class="butActionDelete">'.$langs->trans('Delete').'</span></div>'."\n"; |
2518 | 2625 | } |
2519 | - else |
|
2626 | + } else |
|
2520 | 2627 | { |
2521 | 2628 | print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete">'.$langs->trans('Delete').'</a></div>'."\n"; |
2522 | 2629 | } |