@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | $selected='EUA4'; |
128 | 128 | if (!$outputlangs) { |
129 | - $outputlangs=$langs; |
|
129 | + $outputlangs=$langs; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | if ($outputlangs->defaultlang == 'ca_CA') $selected='CAP4'; // Canada |
@@ -230,15 +230,15 @@ discard block |
||
230 | 230 | else print ': '; |
231 | 231 | if (is_object($object->user_creation)) |
232 | 232 | { |
233 | - if ($object->user_creation->id) print $object->user_creation->getNomUrl(1, '', 0, 0, 0); |
|
234 | - else print $langs->trans("Unknown"); |
|
233 | + if ($object->user_creation->id) print $object->user_creation->getNomUrl(1, '', 0, 0, 0); |
|
234 | + else print $langs->trans("Unknown"); |
|
235 | 235 | } |
236 | 236 | else |
237 | 237 | { |
238 | 238 | $userstatic=new User($db); |
239 | 239 | $userstatic->fetch($object->user_creation_id ? $object->user_creation_id : $object->user_creation); |
240 | 240 | if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
241 | - else print $langs->trans("Unknown"); |
|
241 | + else print $langs->trans("Unknown"); |
|
242 | 242 | } |
243 | 243 | if ($usetable) print '</td></tr>'; |
244 | 244 | else print '<br>'; |
@@ -266,15 +266,15 @@ discard block |
||
266 | 266 | else print ': '; |
267 | 267 | if (is_object($object->user_modification)) |
268 | 268 | { |
269 | - if ($object->user_modification->id) print $object->user_modification->getNomUrl(1, '', 0, 0, 0); |
|
270 | - else print $langs->trans("Unknown"); |
|
269 | + if ($object->user_modification->id) print $object->user_modification->getNomUrl(1, '', 0, 0, 0); |
|
270 | + else print $langs->trans("Unknown"); |
|
271 | 271 | } |
272 | 272 | else |
273 | 273 | { |
274 | 274 | $userstatic=new User($db); |
275 | 275 | $userstatic->fetch($object->user_modification_id ? $object->user_modification_id : $object->user_modification); |
276 | 276 | if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
277 | - else print $langs->trans("Unknown"); |
|
277 | + else print $langs->trans("Unknown"); |
|
278 | 278 | } |
279 | 279 | if ($usetable) print '</td></tr>'; |
280 | 280 | else print '<br>'; |
@@ -303,14 +303,14 @@ discard block |
||
303 | 303 | if (is_object($object->user_validation)) |
304 | 304 | { |
305 | 305 | if ($object->user_validation->id) print $object->user_validation->getNomUrl(1, '', 0, 0, 0); |
306 | - else print $langs->trans("Unknown"); |
|
306 | + else print $langs->trans("Unknown"); |
|
307 | 307 | } |
308 | 308 | else |
309 | 309 | { |
310 | 310 | $userstatic=new User($db); |
311 | 311 | $userstatic->fetch($object->user_validation_id ? $object->user_validation_id : $object->user_validation); |
312 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
313 | - else print $langs->trans("Unknown"); |
|
312 | + if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
313 | + else print $langs->trans("Unknown"); |
|
314 | 314 | } |
315 | 315 | if ($usetable) print '</td></tr>'; |
316 | 316 | else print '<br>'; |
@@ -339,14 +339,14 @@ discard block |
||
339 | 339 | if (is_object($object->user_approve)) |
340 | 340 | { |
341 | 341 | if ($object->user_approve->id) print $object->user_approve->getNomUrl(1, '', 0, 0, 0); |
342 | - else print $langs->trans("Unknown"); |
|
342 | + else print $langs->trans("Unknown"); |
|
343 | 343 | } |
344 | 344 | else |
345 | 345 | { |
346 | 346 | $userstatic=new User($db); |
347 | 347 | $userstatic->fetch($object->user_approve_id ? $object->user_approve_id : $object->user_approve); |
348 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
349 | - else print $langs->trans("Unknown"); |
|
348 | + if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
349 | + else print $langs->trans("Unknown"); |
|
350 | 350 | } |
351 | 351 | if ($usetable) print '</td></tr>'; |
352 | 352 | else print '<br>'; |
@@ -402,15 +402,15 @@ discard block |
||
402 | 402 | else print ': '; |
403 | 403 | if (is_object($object->user_cloture)) |
404 | 404 | { |
405 | - if ($object->user_cloture->id) print $object->user_cloture->getNomUrl(1, '', 0, 0, 0); |
|
406 | - else print $langs->trans("Unknown"); |
|
405 | + if ($object->user_cloture->id) print $object->user_cloture->getNomUrl(1, '', 0, 0, 0); |
|
406 | + else print $langs->trans("Unknown"); |
|
407 | 407 | } |
408 | 408 | else |
409 | 409 | { |
410 | 410 | $userstatic=new User($db); |
411 | 411 | $userstatic->fetch($object->user_cloture); |
412 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
413 | - else print $langs->trans("Unknown"); |
|
412 | + if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
413 | + else print $langs->trans("Unknown"); |
|
414 | 414 | } |
415 | 415 | if ($usetable) print '</td></tr>'; |
416 | 416 | else print '<br>'; |
@@ -438,15 +438,15 @@ discard block |
||
438 | 438 | else print ': '; |
439 | 439 | if (is_object($object->user_rappro)) |
440 | 440 | { |
441 | - if ($object->user_rappro->id) print $object->user_rappro->getNomUrl(1, '', 0, 0, 0); |
|
442 | - else print $langs->trans("Unknown"); |
|
441 | + if ($object->user_rappro->id) print $object->user_rappro->getNomUrl(1, '', 0, 0, 0); |
|
442 | + else print $langs->trans("Unknown"); |
|
443 | 443 | } |
444 | 444 | else |
445 | 445 | { |
446 | 446 | $userstatic=new User($db); |
447 | 447 | $userstatic->fetch($object->user_rappro); |
448 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
449 | - else print $langs->trans("Unknown"); |
|
448 | + if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
449 | + else print $langs->trans("Unknown"); |
|
450 | 450 | } |
451 | 451 | if ($usetable) print '</td></tr>'; |
452 | 452 | else print '<br>'; |
@@ -492,8 +492,8 @@ discard block |
||
492 | 492 | */ |
493 | 493 | function dolAddEmailTrackId($email, $trackingid) |
494 | 494 | { |
495 | - $tmp=explode('@',$email); |
|
496 | - return $tmp[0].'+'.$trackingid.'@'.(isset($tmp[1])?$tmp[1]:''); |
|
495 | + $tmp=explode('@',$email); |
|
496 | + return $tmp[0].'+'.$trackingid.'@'.(isset($tmp[1])?$tmp[1]:''); |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | /** |
@@ -619,33 +619,33 @@ discard block |
||
619 | 619 | */ |
620 | 620 | function dolObfuscateEmail($mail, $replace="*", $nbreplace=8, $nbdisplaymail=4, $nbdisplaydomain=3, $displaytld=true) |
621 | 621 | { |
622 | - if(!isValidEmail($mail))return ''; |
|
623 | - $tab = explode('@', $mail); |
|
624 | - $tab2 = explode('.',$tab[1]); |
|
625 | - $string_replace = ''; |
|
626 | - $mail_name = $tab[0]; |
|
627 | - $mail_domaine = $tab2[0]; |
|
628 | - $mail_tld = ''; |
|
629 | - |
|
630 | - $nbofelem = count($tab2); |
|
631 | - for($i=1; $i < $nbofelem && $displaytld; $i++) |
|
632 | - { |
|
633 | - $mail_tld .= '.'.$tab2[$i]; |
|
634 | - } |
|
635 | - |
|
636 | - for($i=0; $i < $nbreplace; $i++){ |
|
637 | - $string_replace .= $replace; |
|
638 | - } |
|
639 | - |
|
640 | - if(strlen($mail_name) > $nbdisplaymail){ |
|
641 | - $mail_name = substr($mail_name, 0, $nbdisplaymail); |
|
642 | - } |
|
643 | - |
|
644 | - if(strlen($mail_domaine) > $nbdisplaydomain){ |
|
645 | - $mail_domaine = substr($mail_domaine, strlen($mail_domaine)-$nbdisplaydomain); |
|
646 | - } |
|
647 | - |
|
648 | - return $mail_name . $string_replace . $mail_domaine . $mail_tld; |
|
622 | + if(!isValidEmail($mail))return ''; |
|
623 | + $tab = explode('@', $mail); |
|
624 | + $tab2 = explode('.',$tab[1]); |
|
625 | + $string_replace = ''; |
|
626 | + $mail_name = $tab[0]; |
|
627 | + $mail_domaine = $tab2[0]; |
|
628 | + $mail_tld = ''; |
|
629 | + |
|
630 | + $nbofelem = count($tab2); |
|
631 | + for($i=1; $i < $nbofelem && $displaytld; $i++) |
|
632 | + { |
|
633 | + $mail_tld .= '.'.$tab2[$i]; |
|
634 | + } |
|
635 | + |
|
636 | + for($i=0; $i < $nbreplace; $i++){ |
|
637 | + $string_replace .= $replace; |
|
638 | + } |
|
639 | + |
|
640 | + if(strlen($mail_name) > $nbdisplaymail){ |
|
641 | + $mail_name = substr($mail_name, 0, $nbdisplaymail); |
|
642 | + } |
|
643 | + |
|
644 | + if(strlen($mail_domaine) > $nbdisplaydomain){ |
|
645 | + $mail_domaine = substr($mail_domaine, strlen($mail_domaine)-$nbdisplaydomain); |
|
646 | + } |
|
647 | + |
|
648 | + return $mail_name . $string_replace . $mail_domaine . $mail_tld; |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | |
@@ -783,24 +783,24 @@ discard block |
||
783 | 783 | } |
784 | 784 | else |
785 | 785 | { |
786 | - $masktype=''; |
|
787 | - $masktype_value=''; |
|
786 | + $masktype=''; |
|
787 | + $masktype_value=''; |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | // Extract value for user |
791 | 791 | if (preg_match('/\{(u+)\}/i',$mask,$regType)) |
792 | 792 | { |
793 | - $lastname = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; |
|
794 | - if (is_object($objuser)) $lastname = $objuser->lastname; |
|
793 | + $lastname = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; |
|
794 | + if (is_object($objuser)) $lastname = $objuser->lastname; |
|
795 | 795 | |
796 | - $maskuser=$regType[1]; |
|
797 | - $maskuser_value=substr($lastname,0,dol_strlen($regType[1]));// get n first characters of user firstname (where n is length in mask) |
|
798 | - $maskuser_value=str_pad($maskuser_value,dol_strlen($regType[1]),"#",STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask |
|
796 | + $maskuser=$regType[1]; |
|
797 | + $maskuser_value=substr($lastname,0,dol_strlen($regType[1]));// get n first characters of user firstname (where n is length in mask) |
|
798 | + $maskuser_value=str_pad($maskuser_value,dol_strlen($regType[1]),"#",STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask |
|
799 | 799 | } |
800 | 800 | else |
801 | 801 | { |
802 | - $maskuser=''; |
|
803 | - $maskuser_value=''; |
|
802 | + $maskuser=''; |
|
803 | + $maskuser_value=''; |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | // Personalized field {XXX-1} à {XXX-9} |
@@ -816,12 +816,12 @@ discard block |
||
816 | 816 | |
817 | 817 | if (strstr($mask,'user_extra_')) |
818 | 818 | { |
819 | - $start = "{user_extra_"; |
|
820 | - $end = "\}"; |
|
821 | - $extra= get_string_between($mask, "user_extra_", "}"); |
|
822 | - if(!empty($user->array_options['options_'.$extra])){ |
|
823 | - $mask = preg_replace('#('.$start.')(.*?)('.$end.')#si', $user->array_options['options_'.$extra], $mask); |
|
824 | - } |
|
819 | + $start = "{user_extra_"; |
|
820 | + $end = "\}"; |
|
821 | + $extra= get_string_between($mask, "user_extra_", "}"); |
|
822 | + if(!empty($user->array_options['options_'.$extra])){ |
|
823 | + $mask = preg_replace('#('.$start.')(.*?)('.$end.')#si', $user->array_options['options_'.$extra], $mask); |
|
824 | + } |
|
825 | 825 | } |
826 | 826 | $maskwithonlyymcode=$mask; |
827 | 827 | $maskwithonlyymcode=preg_replace('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i',$maskcounter,$maskwithonlyymcode); |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | else // if reset is for a specific month in year, we need year |
883 | 883 | { |
884 | 884 | if (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; } |
885 | - else if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; } |
|
885 | + else if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; } |
|
886 | 886 | else if (preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=0; } |
887 | 887 | else return 'ErrorCantUseRazIfNoYearInMask'; |
888 | 888 | } |
@@ -890,11 +890,11 @@ discard block |
||
890 | 890 | $yearlen = $posy?dol_strlen($reg[$posy]):0; |
891 | 891 | $monthlen = $posm?dol_strlen($reg[$posm]):0; |
892 | 892 | // Define pos |
893 | - $yearpos = (dol_strlen($reg[1])+1); |
|
893 | + $yearpos = (dol_strlen($reg[1])+1); |
|
894 | 894 | $monthpos = ($yearpos+$yearlen); |
895 | 895 | if ($posy == 3 && $posm == 2) { // if month is before year |
896 | - $monthpos = (dol_strlen($reg[1])+1); |
|
897 | - $yearpos = ($monthpos+$monthlen); |
|
896 | + $monthpos = (dol_strlen($reg[1])+1); |
|
897 | + $yearpos = ($monthpos+$monthlen); |
|
898 | 898 | } |
899 | 899 | //print "xxx ".$maskwithonlyymcode." maskraz=".$maskraz." posy=".$posy." yearlen=".$yearlen." yearpos=".$yearpos." posm=".$posm." monthlen=".$monthlen." monthpos=".$monthpos." yearoffsettype=".$yearoffsettype." resetEveryMonth=".$resetEveryMonth."\n"; |
900 | 900 | |
@@ -904,20 +904,20 @@ discard block |
||
904 | 904 | |
905 | 905 | if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') // $yearoffsettype is - or + |
906 | 906 | { |
907 | - $currentyear=date("Y", $date); |
|
908 | - $fiscaldate=dol_mktime('0','0','0',$maskraz,'1',$currentyear); |
|
909 | - $newyeardate=dol_mktime('0','0','0','1','1',$currentyear); |
|
910 | - $nextnewyeardate=dol_mktime('0','0','0','1','1',$currentyear+1); |
|
911 | - //echo 'currentyear='.$currentyear.' date='.dol_print_date($date, 'day').' fiscaldate='.dol_print_date($fiscaldate, 'day').'<br>'; |
|
912 | - |
|
913 | - // If after or equal of current fiscal date |
|
914 | - if ($date >= $fiscaldate) |
|
915 | - { |
|
916 | - // If before of next new year date |
|
917 | - if ($date < $nextnewyeardate && $yearoffsettype == '+') $yearoffset=1; |
|
918 | - } |
|
919 | - // If after or equal of current new year date |
|
920 | - else if ($date >= $newyeardate && $yearoffsettype == '-') $yearoffset=-1; |
|
907 | + $currentyear=date("Y", $date); |
|
908 | + $fiscaldate=dol_mktime('0','0','0',$maskraz,'1',$currentyear); |
|
909 | + $newyeardate=dol_mktime('0','0','0','1','1',$currentyear); |
|
910 | + $nextnewyeardate=dol_mktime('0','0','0','1','1',$currentyear+1); |
|
911 | + //echo 'currentyear='.$currentyear.' date='.dol_print_date($date, 'day').' fiscaldate='.dol_print_date($fiscaldate, 'day').'<br>'; |
|
912 | + |
|
913 | + // If after or equal of current fiscal date |
|
914 | + if ($date >= $fiscaldate) |
|
915 | + { |
|
916 | + // If before of next new year date |
|
917 | + if ($date < $nextnewyeardate && $yearoffsettype == '+') $yearoffset=1; |
|
918 | + } |
|
919 | + // If after or equal of current new year date |
|
920 | + else if ($date >= $newyeardate && $yearoffsettype == '-') $yearoffset=-1; |
|
921 | 921 | } |
922 | 922 | // For backward compatibility |
923 | 923 | else if (date("m",$date) < $maskraz && empty($resetEveryMonth)) { $yearoffset=-1; } // If current month lower that month of return to zero, year is previous year |
@@ -938,11 +938,11 @@ discard block |
||
938 | 938 | $sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") < '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."') "; |
939 | 939 | $sqlwhere.=')'; |
940 | 940 | } |
941 | - else if ($resetEveryMonth) |
|
942 | - { |
|
943 | - $sqlwhere.="(SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'"; |
|
941 | + else if ($resetEveryMonth) |
|
942 | + { |
|
943 | + $sqlwhere.="(SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'"; |
|
944 | 944 | $sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") = '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."')"; |
945 | - } |
|
945 | + } |
|
946 | 946 | else // reset is done on january |
947 | 947 | { |
948 | 948 | $sqlwhere.='(SUBSTRING('.$field.', '.$yearpos.', '.$yearlen.") = '".$yearcomp."')"; |
@@ -953,13 +953,13 @@ discard block |
||
953 | 953 | |
954 | 954 | // Define $sqlstring |
955 | 955 | if (function_exists('mb_strrpos')) |
956 | - { |
|
957 | - $posnumstart=mb_strrpos($maskwithnocode,$maskcounter, 'UTF-8'); |
|
958 | - } |
|
959 | - else |
|
960 | - { |
|
961 | - $posnumstart=strrpos($maskwithnocode,$maskcounter); |
|
962 | - } // Pos of counter in final string (from 0 to ...) |
|
956 | + { |
|
957 | + $posnumstart=mb_strrpos($maskwithnocode,$maskcounter, 'UTF-8'); |
|
958 | + } |
|
959 | + else |
|
960 | + { |
|
961 | + $posnumstart=strrpos($maskwithnocode,$maskcounter); |
|
962 | + } // Pos of counter in final string (from 0 to ...) |
|
963 | 963 | if ($posnumstart < 0) return 'ErrorBadMaskFailedToLocatePosOfSequence'; |
964 | 964 | $sqlstring='SUBSTRING('.$field.', '.($posnumstart+1).', '.dol_strlen($maskcounter).')'; |
965 | 965 | |
@@ -978,7 +978,7 @@ discard block |
||
978 | 978 | if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'),$maskuser_value,$maskLike); |
979 | 979 | foreach($maskperso as $key => $val) |
980 | 980 | { |
981 | - $maskLike = str_replace(dol_string_nospecial($maskperso[$key]),$maskpersonew[$key],$maskLike); |
|
981 | + $maskLike = str_replace(dol_string_nospecial($maskperso[$key]),$maskpersonew[$key],$maskLike); |
|
982 | 982 | } |
983 | 983 | |
984 | 984 | // Get counter in database |
@@ -986,11 +986,11 @@ discard block |
||
986 | 986 | $sql = "SELECT MAX(".$sqlstring.") as val"; |
987 | 987 | $sql.= " FROM ".MAIN_DB_PREFIX.$table; |
988 | 988 | $sql.= " WHERE ".$field." LIKE '".$maskLike."'"; |
989 | - $sql.= " AND ".$field." NOT LIKE '(PROV%)'"; |
|
989 | + $sql.= " AND ".$field." NOT LIKE '(PROV%)'"; |
|
990 | 990 | if ($bentityon) // only if entity enable |
991 | - $sql.= " AND entity IN (".getEntity($sharetable).")"; |
|
991 | + $sql.= " AND entity IN (".getEntity($sharetable).")"; |
|
992 | 992 | else if (! empty($forceentity)) |
993 | - $sql.= " AND entity IN (".$forceentity.")"; |
|
993 | + $sql.= " AND entity IN (".$forceentity.")"; |
|
994 | 994 | if ($where) $sql.=$where; |
995 | 995 | if ($sqlwhere) $sql.=' AND '.$sqlwhere; |
996 | 996 | |
@@ -1008,8 +1008,8 @@ discard block |
||
1008 | 1008 | if (empty($counter)) $counter=$maskoffset; |
1009 | 1009 | else if (preg_match('/[^0-9]/i',$counter)) |
1010 | 1010 | { |
1011 | - $counter=0; |
|
1012 | - dol_syslog("Error, the last counter found is '".$counter."' so is not a numeric value. We will restart to 1.", LOG_ERR); |
|
1011 | + $counter=0; |
|
1012 | + dol_syslog("Error, the last counter found is '".$counter."' so is not a numeric value. We will restart to 1.", LOG_ERR); |
|
1013 | 1013 | } |
1014 | 1014 | else if ($counter < $maskoffset && empty($conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) $counter=$maskoffset; |
1015 | 1015 | |
@@ -1035,11 +1035,11 @@ discard block |
||
1035 | 1035 | $sql = "SELECT ".$field." as ref"; |
1036 | 1036 | $sql.= " FROM ".MAIN_DB_PREFIX.$table; |
1037 | 1037 | $sql.= " WHERE ".$field." LIKE '".$maskLike."'"; |
1038 | - $sql.= " AND ".$field." NOT LIKE '%PROV%'"; |
|
1039 | - if ($bentityon) // only if entity enable |
|
1040 | - $sql.= " AND entity IN (".getEntity($sharetable).")"; |
|
1038 | + $sql.= " AND ".$field." NOT LIKE '%PROV%'"; |
|
1039 | + if ($bentityon) // only if entity enable |
|
1040 | + $sql.= " AND entity IN (".getEntity($sharetable).")"; |
|
1041 | 1041 | else if (! empty($forceentity)) |
1042 | - $sql.= " AND entity IN (".$forceentity.")"; |
|
1042 | + $sql.= " AND entity IN (".$forceentity.")"; |
|
1043 | 1043 | if ($where) $sql.=$where; |
1044 | 1044 | if ($sqlwhere) $sql.=' AND '.$sqlwhere; |
1045 | 1045 | |
@@ -1061,7 +1061,7 @@ discard block |
||
1061 | 1061 | // If value for $counter has a length higher than $maskcounter chars |
1062 | 1062 | if ($counter >= pow(10, dol_strlen($maskcounter))) |
1063 | 1063 | { |
1064 | - $counter='ErrorMaxNumberReachForThisMask'; |
|
1064 | + $counter='ErrorMaxNumberReachForThisMask'; |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | if (! empty($maskrefclient_maskcounter)) |
@@ -1093,9 +1093,9 @@ discard block |
||
1093 | 1093 | //$sql.= " WHERE ".$field." not like '(%'"; |
1094 | 1094 | $maskrefclient_sql.= " WHERE ".$field." LIKE '".$maskrefclient_maskLike."'"; |
1095 | 1095 | if ($bentityon) // only if entity enable |
1096 | - $maskrefclient_sql.= " AND entity IN (".getEntity($sharetable).")"; |
|
1096 | + $maskrefclient_sql.= " AND entity IN (".getEntity($sharetable).")"; |
|
1097 | 1097 | else if (! empty($forceentity)) |
1098 | - $sql.= " AND entity IN (".$forceentity.")"; |
|
1098 | + $sql.= " AND entity IN (".$forceentity.")"; |
|
1099 | 1099 | if ($where) $maskrefclient_sql.=$where; //use the same optional where as general mask |
1100 | 1100 | if ($sqlwhere) $maskrefclient_sql.=' AND '.$sqlwhere; //use the same sqlwhere as general mask |
1101 | 1101 | $maskrefclient_sql.=' AND (SUBSTRING('.$field.', '.(strpos($maskwithnocode,$maskrefclient)+1).', '.dol_strlen($maskrefclient_maskclientcode).")='".$maskrefclient_clientcode."')"; |
@@ -1110,25 +1110,25 @@ discard block |
||
1110 | 1110 | else dol_print_error($db); |
1111 | 1111 | |
1112 | 1112 | if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i',$maskrefclient_counter)) $maskrefclient_counter=$maskrefclient_maskoffset; |
1113 | - $maskrefclient_counter++; |
|
1113 | + $maskrefclient_counter++; |
|
1114 | 1114 | } |
1115 | 1115 | |
1116 | 1116 | // Build numFinal |
1117 | 1117 | $numFinal = $mask; |
1118 | 1118 | |
1119 | 1119 | // We replace special codes except refclient |
1120 | - if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') // yearoffsettype is - or +, so we don't want current year |
|
1121 | - { |
|
1122 | - $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date)+$yearoffset, $numFinal); |
|
1123 | - $numFinal = preg_replace('/\{yy\}/i', date("y",$date)+$yearoffset, $numFinal); |
|
1124 | - $numFinal = preg_replace('/\{y\}/i', substr(date("y",$date),1,1)+$yearoffset, $numFinal); |
|
1125 | - } |
|
1126 | - else // we want yyyy to be current year |
|
1127 | - { |
|
1128 | - $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date), $numFinal); |
|
1129 | - $numFinal = preg_replace('/\{yy\}/i', date("y",$date), $numFinal); |
|
1130 | - $numFinal = preg_replace('/\{y\}/i', substr(date("y",$date),1,1), $numFinal); |
|
1131 | - } |
|
1120 | + if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') // yearoffsettype is - or +, so we don't want current year |
|
1121 | + { |
|
1122 | + $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date)+$yearoffset, $numFinal); |
|
1123 | + $numFinal = preg_replace('/\{yy\}/i', date("y",$date)+$yearoffset, $numFinal); |
|
1124 | + $numFinal = preg_replace('/\{y\}/i', substr(date("y",$date),1,1)+$yearoffset, $numFinal); |
|
1125 | + } |
|
1126 | + else // we want yyyy to be current year |
|
1127 | + { |
|
1128 | + $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date), $numFinal); |
|
1129 | + $numFinal = preg_replace('/\{yy\}/i', date("y",$date), $numFinal); |
|
1130 | + $numFinal = preg_replace('/\{y\}/i', substr(date("y",$date),1,1), $numFinal); |
|
1131 | + } |
|
1132 | 1132 | $numFinal = preg_replace('/\{mm\}/i', date("m",$date), $numFinal); |
1133 | 1133 | $numFinal = preg_replace('/\{dd\}/i', date("d",$date), $numFinal); |
1134 | 1134 | |
@@ -1158,9 +1158,9 @@ discard block |
||
1158 | 1158 | // Now we replace the user |
1159 | 1159 | if ($maskuser) |
1160 | 1160 | { |
1161 | - $maskuser_maskbefore='{'.$maskuser.'}'; |
|
1162 | - $maskuser_maskafter=$maskuser_value; |
|
1163 | - $numFinal = str_replace($maskuser_maskbefore,$maskuser_maskafter,$numFinal); |
|
1161 | + $maskuser_maskbefore='{'.$maskuser.'}'; |
|
1162 | + $maskuser_maskafter=$maskuser_value; |
|
1163 | + $numFinal = str_replace($maskuser_maskbefore,$maskuser_maskafter,$numFinal); |
|
1164 | 1164 | } |
1165 | 1165 | } |
1166 | 1166 | |
@@ -1179,11 +1179,11 @@ discard block |
||
1179 | 1179 | function get_string_between($string, $start, $end) |
1180 | 1180 | { |
1181 | 1181 | $string = " ".$string; |
1182 | - $ini = strpos($string,$start); |
|
1183 | - if ($ini == 0) return ""; |
|
1184 | - $ini += strlen($start); |
|
1185 | - $len = strpos($string,$end,$ini) - $ini; |
|
1186 | - return substr($string,$ini,$len); |
|
1182 | + $ini = strpos($string,$start); |
|
1183 | + if ($ini == 0) return ""; |
|
1184 | + $ini += strlen($start); |
|
1185 | + $len = strpos($string,$end,$ini) - $ini; |
|
1186 | + return substr($string,$ini,$len); |
|
1187 | 1187 | } |
1188 | 1188 | |
1189 | 1189 | /** |
@@ -1531,7 +1531,7 @@ discard block |
||
1531 | 1531 | } |
1532 | 1532 | else |
1533 | 1533 | { |
1534 | - $string = vatrate($reduction,true); |
|
1534 | + $string = vatrate($reduction,true); |
|
1535 | 1535 | } |
1536 | 1536 | |
1537 | 1537 | return $string; |
@@ -1624,7 +1624,7 @@ discard block |
||
1624 | 1624 | //irtoscan.=($dirtoscan?',':'').preg_replace('/[\r\n]+/',',',trim($conf->global->$const)); |
1625 | 1625 | $dirtoscan= preg_replace('/[\r\n]+/',',',trim($conf->global->$const)); |
1626 | 1626 | |
1627 | - $listoffiles=array(); |
|
1627 | + $listoffiles=array(); |
|
1628 | 1628 | |
1629 | 1629 | // Now we add models found in directories scanned |
1630 | 1630 | $listofdir=explode(',',$dirtoscan); |
@@ -1635,8 +1635,8 @@ discard block |
||
1635 | 1635 | if (! $tmpdir) { unset($listofdir[$key]); continue; } |
1636 | 1636 | if (is_dir($tmpdir)) |
1637 | 1637 | { |
1638 | - // all type of template is allowed |
|
1639 | - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0); |
|
1638 | + // all type of template is allowed |
|
1639 | + $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0); |
|
1640 | 1640 | if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
1641 | 1641 | } |
1642 | 1642 | } |
@@ -1692,19 +1692,19 @@ discard block |
||
1692 | 1692 | */ |
1693 | 1693 | function is_ip($ip) |
1694 | 1694 | { |
1695 | - // First we test if it is a valid IPv4 |
|
1696 | - if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
|
1695 | + // First we test if it is a valid IPv4 |
|
1696 | + if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
|
1697 | 1697 | |
1698 | - // Then we test if it is a private range |
|
1699 | - if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) return 2; |
|
1698 | + // Then we test if it is a private range |
|
1699 | + if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) return 2; |
|
1700 | 1700 | |
1701 | - // Then we test if it is a reserved range |
|
1702 | - if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) return 0; |
|
1701 | + // Then we test if it is a reserved range |
|
1702 | + if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) return 0; |
|
1703 | 1703 | |
1704 | - return 1; |
|
1705 | - } |
|
1704 | + return 1; |
|
1705 | + } |
|
1706 | 1706 | |
1707 | - return 0; |
|
1707 | + return 0; |
|
1708 | 1708 | } |
1709 | 1709 | |
1710 | 1710 | /** |
@@ -1744,25 +1744,25 @@ discard block |
||
1744 | 1744 | if ($proxyuse) |
1745 | 1745 | { |
1746 | 1746 | $params=array('connection_timeout'=>$timeout, |
1747 | - 'response_timeout'=>$response_timeout, |
|
1748 | - 'proxy_use' => 1, |
|
1749 | - 'proxy_host' => $proxyhost, |
|
1750 | - 'proxy_port' => $proxyport, |
|
1751 | - 'proxy_login' => $proxyuser, |
|
1752 | - 'proxy_password' => $proxypass, |
|
1753 | - 'trace' => 1 |
|
1747 | + 'response_timeout'=>$response_timeout, |
|
1748 | + 'proxy_use' => 1, |
|
1749 | + 'proxy_host' => $proxyhost, |
|
1750 | + 'proxy_port' => $proxyport, |
|
1751 | + 'proxy_login' => $proxyuser, |
|
1752 | + 'proxy_password' => $proxypass, |
|
1753 | + 'trace' => 1 |
|
1754 | 1754 | ); |
1755 | 1755 | } |
1756 | 1756 | else |
1757 | 1757 | { |
1758 | 1758 | $params=array('connection_timeout'=>$timeout, |
1759 | - 'response_timeout'=>$response_timeout, |
|
1760 | - 'proxy_use' => 0, |
|
1761 | - 'proxy_host' => false, |
|
1762 | - 'proxy_port' => false, |
|
1763 | - 'proxy_login' => false, |
|
1764 | - 'proxy_password' => false, |
|
1765 | - 'trace' => 1 |
|
1759 | + 'response_timeout'=>$response_timeout, |
|
1760 | + 'proxy_use' => 0, |
|
1761 | + 'proxy_host' => false, |
|
1762 | + 'proxy_port' => false, |
|
1763 | + 'proxy_login' => false, |
|
1764 | + 'proxy_password' => false, |
|
1765 | + 'trace' => 1 |
|
1766 | 1766 | ); |
1767 | 1767 | } |
1768 | 1768 | return $params; |
@@ -1780,118 +1780,118 @@ discard block |
||
1780 | 1780 | */ |
1781 | 1781 | function dolGetElementUrl($objectid,$objecttype,$withpicto=0,$option='') |
1782 | 1782 | { |
1783 | - global $db, $conf, $langs; |
|
1784 | - |
|
1785 | - $ret=''; |
|
1786 | - |
|
1787 | - // Parse element/subelement (ex: project_task) |
|
1788 | - $module = $element = $subelement = $objecttype; |
|
1789 | - if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs)) |
|
1790 | - { |
|
1791 | - $module = $element = $regs[1]; |
|
1792 | - $subelement = $regs[2]; |
|
1793 | - } |
|
1794 | - |
|
1795 | - $classpath = $element.'/class'; |
|
1796 | - |
|
1797 | - // To work with non standard path |
|
1798 | - if ($objecttype == 'facture' || $objecttype == 'invoice') { |
|
1799 | - $classpath = 'compta/facture/class'; |
|
1800 | - $module='facture'; |
|
1801 | - $subelement='facture'; |
|
1802 | - } |
|
1803 | - if ($objecttype == 'commande' || $objecttype == 'order') { |
|
1804 | - $classpath = 'commande/class'; |
|
1805 | - $module='commande'; |
|
1806 | - $subelement='commande'; |
|
1807 | - } |
|
1808 | - if ($objecttype == 'propal') { |
|
1809 | - $classpath = 'comm/propal/class'; |
|
1810 | - } |
|
1811 | - if ($objecttype == 'supplier_proposal') { |
|
1812 | - $classpath = 'supplier_proposal/class'; |
|
1813 | - } |
|
1814 | - if ($objecttype == 'shipping') { |
|
1815 | - $classpath = 'expedition/class'; |
|
1816 | - $subelement = 'expedition'; |
|
1817 | - $module = 'expedition_bon'; |
|
1818 | - } |
|
1819 | - if ($objecttype == 'delivery') { |
|
1820 | - $classpath = 'livraison/class'; |
|
1821 | - $subelement = 'livraison'; |
|
1822 | - $module = 'livraison_bon'; |
|
1823 | - } |
|
1824 | - if ($objecttype == 'contract') { |
|
1825 | - $classpath = 'contrat/class'; |
|
1826 | - $module='contrat'; |
|
1827 | - $subelement='contrat'; |
|
1828 | - } |
|
1829 | - if ($objecttype == 'member') { |
|
1830 | - $classpath = 'adherents/class'; |
|
1831 | - $module='adherent'; |
|
1832 | - $subelement='adherent'; |
|
1833 | - } |
|
1834 | - if ($objecttype == 'cabinetmed_cons') { |
|
1835 | - $classpath = 'cabinetmed/class'; |
|
1836 | - $module='cabinetmed'; |
|
1837 | - $subelement='cabinetmedcons'; |
|
1838 | - } |
|
1839 | - if ($objecttype == 'fichinter') { |
|
1840 | - $classpath = 'fichinter/class'; |
|
1841 | - $module='ficheinter'; |
|
1842 | - $subelement='fichinter'; |
|
1843 | - } |
|
1844 | - if ($objecttype == 'task') { |
|
1845 | - $classpath = 'projet/class'; |
|
1846 | - $module='projet'; |
|
1847 | - $subelement='task'; |
|
1848 | - } |
|
1849 | - if ($objecttype == 'stock') { |
|
1850 | - $classpath = 'product/stock/class'; |
|
1851 | - $module='stock'; |
|
1852 | - $subelement='stock'; |
|
1853 | - } |
|
1854 | - |
|
1855 | - //print "objecttype=".$objecttype." module=".$module." subelement=".$subelement; |
|
1856 | - |
|
1857 | - $classfile = strtolower($subelement); $classname = ucfirst($subelement); |
|
1858 | - if ($objecttype == 'invoice_supplier') { |
|
1859 | - $classfile = 'fournisseur.facture'; |
|
1860 | - $classname='FactureFournisseur'; |
|
1861 | - $classpath = 'fourn/class'; |
|
1862 | - $module='fournisseur'; |
|
1863 | - } |
|
1864 | - elseif ($objecttype == 'order_supplier') { |
|
1865 | - $classfile = 'fournisseur.commande'; |
|
1866 | - $classname='CommandeFournisseur'; |
|
1867 | - $classpath = 'fourn/class'; |
|
1868 | - $module='fournisseur'; |
|
1869 | - } |
|
1870 | - elseif ($objecttype == 'stock') { |
|
1871 | - $classpath = 'product/stock/class'; |
|
1872 | - $classfile='entrepot'; |
|
1873 | - $classname='Entrepot'; |
|
1874 | - } |
|
1875 | - if (! empty($conf->$module->enabled)) |
|
1876 | - { |
|
1877 | - $res=dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); |
|
1878 | - if ($res) |
|
1879 | - { |
|
1880 | - if (class_exists($classname)) |
|
1881 | - { |
|
1882 | - $object = new $classname($db); |
|
1883 | - $res=$object->fetch($objectid); |
|
1884 | - if ($res > 0) { |
|
1885 | - $ret=$object->getNomUrl($withpicto,$option); |
|
1886 | - } elseif($res==0) { |
|
1887 | - $ret=$langs->trans('Deleted'); |
|
1888 | - } |
|
1889 | - unset($object); |
|
1890 | - } |
|
1891 | - else dol_syslog("Class with classname ".$classname." is unknown even after the include", LOG_ERR); |
|
1892 | - } |
|
1893 | - } |
|
1894 | - return $ret; |
|
1783 | + global $db, $conf, $langs; |
|
1784 | + |
|
1785 | + $ret=''; |
|
1786 | + |
|
1787 | + // Parse element/subelement (ex: project_task) |
|
1788 | + $module = $element = $subelement = $objecttype; |
|
1789 | + if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs)) |
|
1790 | + { |
|
1791 | + $module = $element = $regs[1]; |
|
1792 | + $subelement = $regs[2]; |
|
1793 | + } |
|
1794 | + |
|
1795 | + $classpath = $element.'/class'; |
|
1796 | + |
|
1797 | + // To work with non standard path |
|
1798 | + if ($objecttype == 'facture' || $objecttype == 'invoice') { |
|
1799 | + $classpath = 'compta/facture/class'; |
|
1800 | + $module='facture'; |
|
1801 | + $subelement='facture'; |
|
1802 | + } |
|
1803 | + if ($objecttype == 'commande' || $objecttype == 'order') { |
|
1804 | + $classpath = 'commande/class'; |
|
1805 | + $module='commande'; |
|
1806 | + $subelement='commande'; |
|
1807 | + } |
|
1808 | + if ($objecttype == 'propal') { |
|
1809 | + $classpath = 'comm/propal/class'; |
|
1810 | + } |
|
1811 | + if ($objecttype == 'supplier_proposal') { |
|
1812 | + $classpath = 'supplier_proposal/class'; |
|
1813 | + } |
|
1814 | + if ($objecttype == 'shipping') { |
|
1815 | + $classpath = 'expedition/class'; |
|
1816 | + $subelement = 'expedition'; |
|
1817 | + $module = 'expedition_bon'; |
|
1818 | + } |
|
1819 | + if ($objecttype == 'delivery') { |
|
1820 | + $classpath = 'livraison/class'; |
|
1821 | + $subelement = 'livraison'; |
|
1822 | + $module = 'livraison_bon'; |
|
1823 | + } |
|
1824 | + if ($objecttype == 'contract') { |
|
1825 | + $classpath = 'contrat/class'; |
|
1826 | + $module='contrat'; |
|
1827 | + $subelement='contrat'; |
|
1828 | + } |
|
1829 | + if ($objecttype == 'member') { |
|
1830 | + $classpath = 'adherents/class'; |
|
1831 | + $module='adherent'; |
|
1832 | + $subelement='adherent'; |
|
1833 | + } |
|
1834 | + if ($objecttype == 'cabinetmed_cons') { |
|
1835 | + $classpath = 'cabinetmed/class'; |
|
1836 | + $module='cabinetmed'; |
|
1837 | + $subelement='cabinetmedcons'; |
|
1838 | + } |
|
1839 | + if ($objecttype == 'fichinter') { |
|
1840 | + $classpath = 'fichinter/class'; |
|
1841 | + $module='ficheinter'; |
|
1842 | + $subelement='fichinter'; |
|
1843 | + } |
|
1844 | + if ($objecttype == 'task') { |
|
1845 | + $classpath = 'projet/class'; |
|
1846 | + $module='projet'; |
|
1847 | + $subelement='task'; |
|
1848 | + } |
|
1849 | + if ($objecttype == 'stock') { |
|
1850 | + $classpath = 'product/stock/class'; |
|
1851 | + $module='stock'; |
|
1852 | + $subelement='stock'; |
|
1853 | + } |
|
1854 | + |
|
1855 | + //print "objecttype=".$objecttype." module=".$module." subelement=".$subelement; |
|
1856 | + |
|
1857 | + $classfile = strtolower($subelement); $classname = ucfirst($subelement); |
|
1858 | + if ($objecttype == 'invoice_supplier') { |
|
1859 | + $classfile = 'fournisseur.facture'; |
|
1860 | + $classname='FactureFournisseur'; |
|
1861 | + $classpath = 'fourn/class'; |
|
1862 | + $module='fournisseur'; |
|
1863 | + } |
|
1864 | + elseif ($objecttype == 'order_supplier') { |
|
1865 | + $classfile = 'fournisseur.commande'; |
|
1866 | + $classname='CommandeFournisseur'; |
|
1867 | + $classpath = 'fourn/class'; |
|
1868 | + $module='fournisseur'; |
|
1869 | + } |
|
1870 | + elseif ($objecttype == 'stock') { |
|
1871 | + $classpath = 'product/stock/class'; |
|
1872 | + $classfile='entrepot'; |
|
1873 | + $classname='Entrepot'; |
|
1874 | + } |
|
1875 | + if (! empty($conf->$module->enabled)) |
|
1876 | + { |
|
1877 | + $res=dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); |
|
1878 | + if ($res) |
|
1879 | + { |
|
1880 | + if (class_exists($classname)) |
|
1881 | + { |
|
1882 | + $object = new $classname($db); |
|
1883 | + $res=$object->fetch($objectid); |
|
1884 | + if ($res > 0) { |
|
1885 | + $ret=$object->getNomUrl($withpicto,$option); |
|
1886 | + } elseif($res==0) { |
|
1887 | + $ret=$langs->trans('Deleted'); |
|
1888 | + } |
|
1889 | + unset($object); |
|
1890 | + } |
|
1891 | + else dol_syslog("Class with classname ".$classname." is unknown even after the include", LOG_ERR); |
|
1892 | + } |
|
1893 | + } |
|
1894 | + return $ret; |
|
1895 | 1895 | } |
1896 | 1896 | |
1897 | 1897 | |
@@ -1905,113 +1905,113 @@ discard block |
||
1905 | 1905 | */ |
1906 | 1906 | function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) |
1907 | 1907 | { |
1908 | - $totalnb=0; |
|
1909 | - $listofid=array(); |
|
1910 | - $listofparentid=array(); |
|
1911 | - |
|
1912 | - // Get list of all id in array listofid and all parents in array listofparentid |
|
1913 | - $sql='SELECT rowid, '.$fieldfkparent.' as parent_id FROM '.MAIN_DB_PREFIX.$tabletocleantree; |
|
1914 | - $resql = $db->query($sql); |
|
1915 | - if ($resql) |
|
1916 | - { |
|
1917 | - $num = $db->num_rows($resql); |
|
1918 | - $i = 0; |
|
1919 | - while ($i < $num) |
|
1920 | - { |
|
1921 | - $obj = $db->fetch_object($resql); |
|
1922 | - $listofid[]=$obj->rowid; |
|
1923 | - if ($obj->parent_id > 0) $listofparentid[$obj->rowid]=$obj->parent_id; |
|
1924 | - $i++; |
|
1925 | - } |
|
1926 | - } |
|
1927 | - else |
|
1928 | - { |
|
1929 | - dol_print_error($db); |
|
1930 | - } |
|
1931 | - |
|
1932 | - if (count($listofid)) |
|
1933 | - { |
|
1934 | - print 'Code requested to clean tree (may be to solve data corruption), so we check/clean orphelins and loops.'."<br>\n"; |
|
1935 | - |
|
1936 | - // Check loops on each other |
|
1937 | - $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree." SET ".$fieldfkparent." = 0 WHERE ".$fieldfkparent." = rowid"; // So we update only records linked to themself |
|
1938 | - $resql = $db->query($sql); |
|
1939 | - if ($resql) |
|
1940 | - { |
|
1941 | - $nb=$db->affected_rows($sql); |
|
1942 | - if ($nb > 0) |
|
1943 | - { |
|
1944 | - print '<br>Some record that were parent of themself were cleaned.'; |
|
1945 | - } |
|
1946 | - |
|
1947 | - $totalnb+=$nb; |
|
1948 | - } |
|
1949 | - //else dol_print_error($db); |
|
1950 | - |
|
1951 | - // Check other loops |
|
1952 | - $listofidtoclean=array(); |
|
1953 | - foreach($listofparentid as $id => $pid) |
|
1954 | - { |
|
1955 | - // Check depth |
|
1956 | - //print 'Analyse record id='.$id.' with parent '.$pid.'<br>'; |
|
1957 | - |
|
1958 | - $cursor=$id; $arrayidparsed=array(); // We start from child $id |
|
1959 | - while ($cursor > 0) |
|
1960 | - { |
|
1961 | - $arrayidparsed[$cursor]=1; |
|
1962 | - if ($arrayidparsed[$listofparentid[$cursor]]) // We detect a loop. A record with a parent that was already into child |
|
1963 | - { |
|
1964 | - print 'Found a loop between id '.$id.' - '.$cursor.'<br>'; |
|
1965 | - unset($arrayidparsed); |
|
1966 | - $listofidtoclean[$cursor]=$id; |
|
1967 | - break; |
|
1968 | - } |
|
1969 | - $cursor=$listofparentid[$cursor]; |
|
1970 | - } |
|
1971 | - |
|
1972 | - if (count($listofidtoclean)) break; |
|
1973 | - } |
|
1974 | - |
|
1975 | - $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree; |
|
1976 | - $sql.= " SET ".$fieldfkparent." = 0"; |
|
1977 | - $sql.= " WHERE rowid IN (".join(',',$listofidtoclean).")"; // So we update only records detected wrong |
|
1978 | - $resql = $db->query($sql); |
|
1979 | - if ($resql) |
|
1980 | - { |
|
1981 | - $nb=$db->affected_rows($sql); |
|
1982 | - if ($nb > 0) |
|
1983 | - { |
|
1984 | - // Removed orphelins records |
|
1985 | - print '<br>Some records were detected to have parent that is a child, we set them as root record for id: '; |
|
1986 | - print join(',',$listofidtoclean); |
|
1987 | - } |
|
1988 | - |
|
1989 | - $totalnb+=$nb; |
|
1990 | - } |
|
1991 | - //else dol_print_error($db); |
|
1992 | - |
|
1993 | - // Check and clean orphelins |
|
1994 | - $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree; |
|
1995 | - $sql.= " SET ".$fieldfkparent." = 0"; |
|
1996 | - $sql.= " WHERE ".$fieldfkparent." NOT IN (".join(',',$listofid).")"; // So we update only records linked to a non existing parent |
|
1997 | - $resql = $db->query($sql); |
|
1998 | - if ($resql) |
|
1999 | - { |
|
2000 | - $nb=$db->affected_rows($sql); |
|
2001 | - if ($nb > 0) |
|
2002 | - { |
|
2003 | - // Removed orphelins records |
|
2004 | - print '<br>Some orphelins were found and modified to be parent so records are visible again for id: '; |
|
2005 | - print join(',',$listofid); |
|
2006 | - } |
|
2007 | - |
|
2008 | - $totalnb+=$nb; |
|
2009 | - } |
|
2010 | - //else dol_print_error($db); |
|
2011 | - |
|
2012 | - print '<br>We fixed '.$totalnb.' record(s). Some records may still be corrupted. New check may be required.'; |
|
2013 | - return $totalnb; |
|
2014 | - } |
|
1908 | + $totalnb=0; |
|
1909 | + $listofid=array(); |
|
1910 | + $listofparentid=array(); |
|
1911 | + |
|
1912 | + // Get list of all id in array listofid and all parents in array listofparentid |
|
1913 | + $sql='SELECT rowid, '.$fieldfkparent.' as parent_id FROM '.MAIN_DB_PREFIX.$tabletocleantree; |
|
1914 | + $resql = $db->query($sql); |
|
1915 | + if ($resql) |
|
1916 | + { |
|
1917 | + $num = $db->num_rows($resql); |
|
1918 | + $i = 0; |
|
1919 | + while ($i < $num) |
|
1920 | + { |
|
1921 | + $obj = $db->fetch_object($resql); |
|
1922 | + $listofid[]=$obj->rowid; |
|
1923 | + if ($obj->parent_id > 0) $listofparentid[$obj->rowid]=$obj->parent_id; |
|
1924 | + $i++; |
|
1925 | + } |
|
1926 | + } |
|
1927 | + else |
|
1928 | + { |
|
1929 | + dol_print_error($db); |
|
1930 | + } |
|
1931 | + |
|
1932 | + if (count($listofid)) |
|
1933 | + { |
|
1934 | + print 'Code requested to clean tree (may be to solve data corruption), so we check/clean orphelins and loops.'."<br>\n"; |
|
1935 | + |
|
1936 | + // Check loops on each other |
|
1937 | + $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree." SET ".$fieldfkparent." = 0 WHERE ".$fieldfkparent." = rowid"; // So we update only records linked to themself |
|
1938 | + $resql = $db->query($sql); |
|
1939 | + if ($resql) |
|
1940 | + { |
|
1941 | + $nb=$db->affected_rows($sql); |
|
1942 | + if ($nb > 0) |
|
1943 | + { |
|
1944 | + print '<br>Some record that were parent of themself were cleaned.'; |
|
1945 | + } |
|
1946 | + |
|
1947 | + $totalnb+=$nb; |
|
1948 | + } |
|
1949 | + //else dol_print_error($db); |
|
1950 | + |
|
1951 | + // Check other loops |
|
1952 | + $listofidtoclean=array(); |
|
1953 | + foreach($listofparentid as $id => $pid) |
|
1954 | + { |
|
1955 | + // Check depth |
|
1956 | + //print 'Analyse record id='.$id.' with parent '.$pid.'<br>'; |
|
1957 | + |
|
1958 | + $cursor=$id; $arrayidparsed=array(); // We start from child $id |
|
1959 | + while ($cursor > 0) |
|
1960 | + { |
|
1961 | + $arrayidparsed[$cursor]=1; |
|
1962 | + if ($arrayidparsed[$listofparentid[$cursor]]) // We detect a loop. A record with a parent that was already into child |
|
1963 | + { |
|
1964 | + print 'Found a loop between id '.$id.' - '.$cursor.'<br>'; |
|
1965 | + unset($arrayidparsed); |
|
1966 | + $listofidtoclean[$cursor]=$id; |
|
1967 | + break; |
|
1968 | + } |
|
1969 | + $cursor=$listofparentid[$cursor]; |
|
1970 | + } |
|
1971 | + |
|
1972 | + if (count($listofidtoclean)) break; |
|
1973 | + } |
|
1974 | + |
|
1975 | + $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree; |
|
1976 | + $sql.= " SET ".$fieldfkparent." = 0"; |
|
1977 | + $sql.= " WHERE rowid IN (".join(',',$listofidtoclean).")"; // So we update only records detected wrong |
|
1978 | + $resql = $db->query($sql); |
|
1979 | + if ($resql) |
|
1980 | + { |
|
1981 | + $nb=$db->affected_rows($sql); |
|
1982 | + if ($nb > 0) |
|
1983 | + { |
|
1984 | + // Removed orphelins records |
|
1985 | + print '<br>Some records were detected to have parent that is a child, we set them as root record for id: '; |
|
1986 | + print join(',',$listofidtoclean); |
|
1987 | + } |
|
1988 | + |
|
1989 | + $totalnb+=$nb; |
|
1990 | + } |
|
1991 | + //else dol_print_error($db); |
|
1992 | + |
|
1993 | + // Check and clean orphelins |
|
1994 | + $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree; |
|
1995 | + $sql.= " SET ".$fieldfkparent." = 0"; |
|
1996 | + $sql.= " WHERE ".$fieldfkparent." NOT IN (".join(',',$listofid).")"; // So we update only records linked to a non existing parent |
|
1997 | + $resql = $db->query($sql); |
|
1998 | + if ($resql) |
|
1999 | + { |
|
2000 | + $nb=$db->affected_rows($sql); |
|
2001 | + if ($nb > 0) |
|
2002 | + { |
|
2003 | + // Removed orphelins records |
|
2004 | + print '<br>Some orphelins were found and modified to be parent so records are visible again for id: '; |
|
2005 | + print join(',',$listofid); |
|
2006 | + } |
|
2007 | + |
|
2008 | + $totalnb+=$nb; |
|
2009 | + } |
|
2010 | + //else dol_print_error($db); |
|
2011 | + |
|
2012 | + print '<br>We fixed '.$totalnb.' record(s). Some records may still be corrupted. New check may be required.'; |
|
2013 | + return $totalnb; |
|
2014 | + } |
|
2015 | 2015 | } |
2016 | 2016 | |
2017 | 2017 | /** |
@@ -2143,21 +2143,21 @@ discard block |
||
2143 | 2143 | function fetchObjectByElement($element_id, $element_type, $element_ref='') |
2144 | 2144 | { |
2145 | 2145 | global $conf; |
2146 | - global $db,$conf; |
|
2146 | + global $db,$conf; |
|
2147 | 2147 | |
2148 | 2148 | $element_prop = getElementProperties($element_type); |
2149 | 2149 | if (is_array($element_prop) && $conf->{$element_prop['module']}->enabled) |
2150 | 2150 | { |
2151 | 2151 | dol_include_once('/'.$element_prop['classpath'].'/'.$element_prop['classfile'].'.class.php'); |
2152 | 2152 | |
2153 | - $objecttmp = new $element_prop['classname']($db); |
|
2154 | - $ret = $objecttmp->fetch($element_id, $element_ref); |
|
2155 | - if ($ret >= 0) |
|
2156 | - { |
|
2157 | - return $objecttmp; |
|
2158 | - } |
|
2159 | - } |
|
2160 | - return 0; |
|
2153 | + $objecttmp = new $element_prop['classname']($db); |
|
2154 | + $ret = $objecttmp->fetch($element_id, $element_ref); |
|
2155 | + if ($ret >= 0) |
|
2156 | + { |
|
2157 | + return $objecttmp; |
|
2158 | + } |
|
2159 | + } |
|
2160 | + return 0; |
|
2161 | 2161 | } |
2162 | 2162 | |
2163 | 2163 | |
@@ -2172,9 +2172,9 @@ discard block |
||
2172 | 2172 | */ |
2173 | 2173 | function colorArrayToHex($arraycolor,$colorifnotfound='888888') |
2174 | 2174 | { |
2175 | - if (! is_array($arraycolor)) return $colorifnotfound; |
|
2176 | - if (empty($arraycolor)) return $colorifnotfound; |
|
2177 | - return sprintf("%02s",dechex($arraycolor[0])).sprintf("%02s",dechex($arraycolor[1])).sprintf("%02s",dechex($arraycolor[2])); |
|
2175 | + if (! is_array($arraycolor)) return $colorifnotfound; |
|
2176 | + if (empty($arraycolor)) return $colorifnotfound; |
|
2177 | + return sprintf("%02s",dechex($arraycolor[0])).sprintf("%02s",dechex($arraycolor[1])).sprintf("%02s",dechex($arraycolor[2])); |
|
2178 | 2178 | } |
2179 | 2179 | |
2180 | 2180 | /** |
@@ -2189,15 +2189,15 @@ discard block |
||
2189 | 2189 | */ |
2190 | 2190 | function colorStringToArray($stringcolor,$colorifnotfound=array(88,88,88)) |
2191 | 2191 | { |
2192 | - if (is_array($stringcolor)) return $stringcolor; // If already into correct output format, we return as is |
|
2193 | - $tmp=preg_match('/^#?([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])$/',$stringcolor,$reg); |
|
2194 | - if (! $tmp) |
|
2195 | - { |
|
2196 | - $tmp=explode(',',$stringcolor); |
|
2197 | - if (count($tmp) < 3) return $colorifnotfound; |
|
2198 | - return $tmp; |
|
2199 | - } |
|
2200 | - return array(hexdec($reg[1]),hexdec($reg[2]),hexdec($reg[3])); |
|
2192 | + if (is_array($stringcolor)) return $stringcolor; // If already into correct output format, we return as is |
|
2193 | + $tmp=preg_match('/^#?([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])$/',$stringcolor,$reg); |
|
2194 | + if (! $tmp) |
|
2195 | + { |
|
2196 | + $tmp=explode(',',$stringcolor); |
|
2197 | + if (count($tmp) < 3) return $colorifnotfound; |
|
2198 | + return $tmp; |
|
2199 | + } |
|
2200 | + return array(hexdec($reg[1]),hexdec($reg[2]),hexdec($reg[3])); |
|
2201 | 2201 | } |
2202 | 2202 | |
2203 | 2203 | /** |
@@ -2243,7 +2243,7 @@ discard block |
||
2243 | 2243 | if ($moduledirforclass != 'api') $moduledirforclass = preg_replace('/api$/i','',$moduledirforclass); |
2244 | 2244 | |
2245 | 2245 | if ($module == 'contracts') { |
2246 | - $moduledirforclass = 'contrat'; |
|
2246 | + $moduledirforclass = 'contrat'; |
|
2247 | 2247 | } |
2248 | 2248 | elseif (in_array($module, array('admin', 'login', 'setup', 'access', 'status', 'tools', 'documents'))) { |
2249 | 2249 | $moduledirforclass = 'api'; |
@@ -2270,7 +2270,7 @@ discard block |
||
2270 | 2270 | $moduledirforclass = 'commande'; |
2271 | 2271 | } |
2272 | 2272 | elseif ($module == 'shipments') { |
2273 | - $moduledirforclass = 'expedition'; |
|
2273 | + $moduledirforclass = 'expedition'; |
|
2274 | 2274 | } |
2275 | 2275 | elseif ($module == 'facture' || $module == 'invoice' || $module == 'invoices') { |
2276 | 2276 | $moduledirforclass = 'compta/facture'; |
@@ -2288,7 +2288,7 @@ discard block |
||
2288 | 2288 | $moduledirforclass = 'product/stock'; |
2289 | 2289 | } |
2290 | 2290 | elseif ($module == 'supplierproposals' || $module == 'supplierproposal' || $module == 'supplier_proposal') { |
2291 | - $moduledirforclass = 'supplier_proposal'; |
|
2291 | + $moduledirforclass = 'supplier_proposal'; |
|
2292 | 2292 | } |
2293 | 2293 | elseif ($module == 'fournisseur' || $module == 'supplierinvoices' || $module == 'supplierorders') { |
2294 | 2294 | $moduledirforclass = 'fourn'; |
@@ -2300,10 +2300,10 @@ discard block |
||
2300 | 2300 | $moduledirforclass = 'user'; |
2301 | 2301 | } |
2302 | 2302 | elseif ($module == 'ficheinter' || $module == 'interventions') { |
2303 | - $moduledirforclass = 'fichinter'; |
|
2303 | + $moduledirforclass = 'fichinter'; |
|
2304 | 2304 | } |
2305 | 2305 | elseif ($module == 'tickets') { |
2306 | - $moduledirforclass = 'ticket'; |
|
2306 | + $moduledirforclass = 'ticket'; |
|
2307 | 2307 | } |
2308 | 2308 | |
2309 | 2309 | return $moduledirforclass; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $pos++; |
53 | 53 | $unicodeHexVal = substr($source, $pos, 4); |
54 | 54 | $unicode = hexdec($unicodeHexVal); |
55 | - $entity = "&#". $unicode . ';'; |
|
55 | + $entity = "&#".$unicode.';'; |
|
56 | 56 | $decodedStr .= utf8_encode($entity); |
57 | 57 | $pos += 4; |
58 | 58 | } |
@@ -78,32 +78,32 @@ discard block |
||
78 | 78 | * @param string $subdir Sub directory (Example: '/mailings') |
79 | 79 | * @return array Array of directories that can contains module descriptors |
80 | 80 | */ |
81 | -function dolGetModulesDirs($subdir='') |
|
81 | +function dolGetModulesDirs($subdir = '') |
|
82 | 82 | { |
83 | 83 | global $conf; |
84 | 84 | |
85 | - $modulesdir=array(); |
|
85 | + $modulesdir = array(); |
|
86 | 86 | |
87 | 87 | foreach ($conf->file->dol_document_root as $type => $dirroot) |
88 | 88 | { |
89 | 89 | // Default core/modules dir |
90 | 90 | if ($type === 'main') { |
91 | - $modulesdir[$dirroot . '/core/modules' . $subdir . '/'] = $dirroot . '/core/modules' . $subdir . '/'; |
|
91 | + $modulesdir[$dirroot.'/core/modules'.$subdir.'/'] = $dirroot.'/core/modules'.$subdir.'/'; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | // Scan dir from external modules |
95 | - $handle=@opendir($dirroot); |
|
95 | + $handle = @opendir($dirroot); |
|
96 | 96 | if (is_resource($handle)) |
97 | 97 | { |
98 | - while (($file = readdir($handle))!==false) |
|
98 | + while (($file = readdir($handle)) !== false) |
|
99 | 99 | { |
100 | - if (preg_match('/disabled/',$file)) continue; // We discard module if it contains disabled into name. |
|
100 | + if (preg_match('/disabled/', $file)) continue; // We discard module if it contains disabled into name. |
|
101 | 101 | |
102 | 102 | if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes') |
103 | 103 | { |
104 | - if (is_dir($dirroot . '/' . $file . '/core/modules'.$subdir.'/')) |
|
104 | + if (is_dir($dirroot.'/'.$file.'/core/modules'.$subdir.'/')) |
|
105 | 105 | { |
106 | - $modulesdir[$dirroot . '/' . $file . '/core/modules'.$subdir.'/'] = $dirroot . '/' . $file . '/core/modules'.$subdir.'/'; |
|
106 | + $modulesdir[$dirroot.'/'.$file.'/core/modules'.$subdir.'/'] = $dirroot.'/'.$file.'/core/modules'.$subdir.'/'; |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | } |
@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | { |
125 | 125 | global $langs; |
126 | 126 | |
127 | - $selected='EUA4'; |
|
127 | + $selected = 'EUA4'; |
|
128 | 128 | if (!$outputlangs) { |
129 | - $outputlangs=$langs; |
|
129 | + $outputlangs = $langs; |
|
130 | 130 | } |
131 | 131 | |
132 | - if ($outputlangs->defaultlang == 'ca_CA') $selected='CAP4'; // Canada |
|
133 | - if ($outputlangs->defaultlang == 'en_US') $selected='USLetter'; // US |
|
132 | + if ($outputlangs->defaultlang == 'ca_CA') $selected = 'CAP4'; // Canada |
|
133 | + if ($outputlangs->defaultlang == 'en_US') $selected = 'USLetter'; // US |
|
134 | 134 | return $selected; |
135 | 135 | } |
136 | 136 | |
@@ -142,20 +142,20 @@ discard block |
||
142 | 142 | * @param int $searchalt 1=Search also in alternative languages |
143 | 143 | * @return boolean true if OK, false if KO |
144 | 144 | */ |
145 | -function dol_print_file($langs,$filename,$searchalt=0) |
|
145 | +function dol_print_file($langs, $filename, $searchalt = 0) |
|
146 | 146 | { |
147 | 147 | global $conf; |
148 | 148 | |
149 | 149 | // Test if file is in lang directory |
150 | - foreach($langs->dir as $searchdir) |
|
150 | + foreach ($langs->dir as $searchdir) |
|
151 | 151 | { |
152 | - $formfile=($searchdir."/langs/".$langs->defaultlang."/".$filename); |
|
152 | + $formfile = ($searchdir."/langs/".$langs->defaultlang."/".$filename); |
|
153 | 153 | dol_syslog('functions2::dol_print_file search file '.$formfile, LOG_DEBUG); |
154 | 154 | if (is_readable($formfile)) |
155 | 155 | { |
156 | - $content=file_get_contents($formfile); |
|
157 | - $isutf8=utf8_check($content); |
|
158 | - if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') print utf8_encode($content); |
|
156 | + $content = file_get_contents($formfile); |
|
157 | + $isutf8 = utf8_check($content); |
|
158 | + if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') print utf8_encode($content); |
|
159 | 159 | elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') print utf8_decode($content); |
160 | 160 | else print $content; |
161 | 161 | return true; |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | //print 'getcwd='.getcwd().' htmlfilealt='.$formfilealt.' X '.file_exists(getcwd().'/'.$formfilealt); |
171 | 171 | if (is_readable($formfilealt)) |
172 | 172 | { |
173 | - $content=file_get_contents($formfilealt); |
|
174 | - $isutf8=utf8_check($content); |
|
175 | - if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') print utf8_encode($content); |
|
173 | + $content = file_get_contents($formfilealt); |
|
174 | + $isutf8 = utf8_check($content); |
|
175 | + if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') print utf8_encode($content); |
|
176 | 176 | elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') print utf8_decode($content); |
177 | 177 | else print $content; |
178 | 178 | return true; |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @param int $usetable Output into a table |
193 | 193 | * @return void |
194 | 194 | */ |
195 | -function dol_print_object_info($object, $usetable=0) |
|
195 | +function dol_print_object_info($object, $usetable = 0) |
|
196 | 196 | { |
197 | 197 | global $langs, $db; |
198 | 198 | |
@@ -201,16 +201,16 @@ discard block |
||
201 | 201 | |
202 | 202 | include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
203 | 203 | |
204 | - $deltadateforserver=getServerTimeZoneInt('now'); |
|
205 | - $deltadateforclient=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']); |
|
204 | + $deltadateforserver = getServerTimeZoneInt('now'); |
|
205 | + $deltadateforclient = ((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']); |
|
206 | 206 | //$deltadateforcompany=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']); |
207 | - $deltadateforuser=round($deltadateforclient-$deltadateforserver); |
|
207 | + $deltadateforuser = round($deltadateforclient - $deltadateforserver); |
|
208 | 208 | //print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser; |
209 | 209 | |
210 | 210 | if ($usetable) print '<table class="border centpercent">'; |
211 | 211 | |
212 | 212 | // Import key |
213 | - if (! empty($object->import_key)) |
|
213 | + if (!empty($object->import_key)) |
|
214 | 214 | { |
215 | 215 | if ($usetable) print '<tr><td class="titlefield">'; |
216 | 216 | print $langs->trans("ImportedWithSet"); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | } |
223 | 223 | |
224 | 224 | // User creation (old method using already loaded object and not id is kept for backward compatibility) |
225 | - if (! empty($object->user_creation) || ! empty($object->user_creation_id)) |
|
225 | + if (!empty($object->user_creation) || !empty($object->user_creation_id)) |
|
226 | 226 | { |
227 | 227 | if ($usetable) print '<tr><td class="titlefield">'; |
228 | 228 | print $langs->trans("CreatedBy"); |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | } |
236 | 236 | else |
237 | 237 | { |
238 | - $userstatic=new User($db); |
|
238 | + $userstatic = new User($db); |
|
239 | 239 | $userstatic->fetch($object->user_creation_id ? $object->user_creation_id : $object->user_creation); |
240 | 240 | if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
241 | 241 | else print $langs->trans("Unknown"); |
@@ -245,20 +245,20 @@ discard block |
||
245 | 245 | } |
246 | 246 | |
247 | 247 | // Date creation |
248 | - if (! empty($object->date_creation)) |
|
248 | + if (!empty($object->date_creation)) |
|
249 | 249 | { |
250 | 250 | if ($usetable) print '<tr><td class="titlefield">'; |
251 | 251 | print $langs->trans("DateCreation"); |
252 | 252 | if ($usetable) print '</td><td>'; |
253 | 253 | else print ': '; |
254 | 254 | print dol_print_date($object->date_creation, 'dayhour'); |
255 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_creation+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
255 | + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_creation + ($deltadateforuser * 3600), "dayhour").' '.$langs->trans("ClientHour"); |
|
256 | 256 | if ($usetable) print '</td></tr>'; |
257 | 257 | else print '<br>'; |
258 | 258 | } |
259 | 259 | |
260 | 260 | // User change (old method using already loaded object and not id is kept for backward compatibility) |
261 | - if (! empty($object->user_modification) || ! empty($object->user_modification_id)) |
|
261 | + if (!empty($object->user_modification) || !empty($object->user_modification_id)) |
|
262 | 262 | { |
263 | 263 | if ($usetable) print '<tr><td class="titlefield">'; |
264 | 264 | print $langs->trans("ModifiedBy"); |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | } |
272 | 272 | else |
273 | 273 | { |
274 | - $userstatic=new User($db); |
|
274 | + $userstatic = new User($db); |
|
275 | 275 | $userstatic->fetch($object->user_modification_id ? $object->user_modification_id : $object->user_modification); |
276 | 276 | if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
277 | 277 | else print $langs->trans("Unknown"); |
@@ -281,20 +281,20 @@ discard block |
||
281 | 281 | } |
282 | 282 | |
283 | 283 | // Date change |
284 | - if (! empty($object->date_modification)) |
|
284 | + if (!empty($object->date_modification)) |
|
285 | 285 | { |
286 | 286 | if ($usetable) print '<tr><td class="titlefield">'; |
287 | 287 | print $langs->trans("DateLastModification"); |
288 | 288 | if ($usetable) print '</td><td>'; |
289 | 289 | else print ': '; |
290 | 290 | print dol_print_date($object->date_modification, 'dayhour'); |
291 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_modification+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
291 | + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_modification + ($deltadateforuser * 3600), "dayhour").' '.$langs->trans("ClientHour"); |
|
292 | 292 | if ($usetable) print '</td></tr>'; |
293 | 293 | else print '<br>'; |
294 | 294 | } |
295 | 295 | |
296 | 296 | // User validation (old method using already loaded object and not id is kept for backward compatibility) |
297 | - if (! empty($object->user_validation) || ! empty($object->user_validation_id)) |
|
297 | + if (!empty($object->user_validation) || !empty($object->user_validation_id)) |
|
298 | 298 | { |
299 | 299 | if ($usetable) print '<tr><td class="titlefield">'; |
300 | 300 | print $langs->trans("ValidatedBy"); |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | } |
308 | 308 | else |
309 | 309 | { |
310 | - $userstatic=new User($db); |
|
310 | + $userstatic = new User($db); |
|
311 | 311 | $userstatic->fetch($object->user_validation_id ? $object->user_validation_id : $object->user_validation); |
312 | 312 | if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
313 | 313 | else print $langs->trans("Unknown"); |
@@ -317,20 +317,20 @@ discard block |
||
317 | 317 | } |
318 | 318 | |
319 | 319 | // Date validation |
320 | - if (! empty($object->date_validation)) |
|
320 | + if (!empty($object->date_validation)) |
|
321 | 321 | { |
322 | 322 | if ($usetable) print '<tr><td class="titlefield">'; |
323 | 323 | print $langs->trans("DateValidation"); |
324 | 324 | if ($usetable) print '</td><td>'; |
325 | 325 | else print ': '; |
326 | 326 | print dol_print_date($object->date_validation, 'dayhour'); |
327 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_validation+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
327 | + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_validation + ($deltadateforuser * 3600), "dayhour").' '.$langs->trans("ClientHour"); |
|
328 | 328 | if ($usetable) print '</td></tr>'; |
329 | 329 | else print '<br>'; |
330 | 330 | } |
331 | 331 | |
332 | 332 | // User approve (old method using already loaded object and not id is kept for backward compatibility) |
333 | - if (! empty($object->user_approve) || ! empty($object->user_approve_id)) |
|
333 | + if (!empty($object->user_approve) || !empty($object->user_approve_id)) |
|
334 | 334 | { |
335 | 335 | if ($usetable) print '<tr><td class="titlefield">'; |
336 | 336 | print $langs->trans("ApprovedBy"); |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | } |
344 | 344 | else |
345 | 345 | { |
346 | - $userstatic=new User($db); |
|
346 | + $userstatic = new User($db); |
|
347 | 347 | $userstatic->fetch($object->user_approve_id ? $object->user_approve_id : $object->user_approve); |
348 | 348 | if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
349 | 349 | else print $langs->trans("Unknown"); |
@@ -353,26 +353,26 @@ discard block |
||
353 | 353 | } |
354 | 354 | |
355 | 355 | // Date approve |
356 | - if (! empty($object->date_approve)) |
|
356 | + if (!empty($object->date_approve)) |
|
357 | 357 | { |
358 | 358 | if ($usetable) print '<tr><td class="titlefield">'; |
359 | 359 | print $langs->trans("DateApprove"); |
360 | 360 | if ($usetable) print '</td><td>'; |
361 | 361 | else print ': '; |
362 | 362 | print dol_print_date($object->date_approve, 'dayhour'); |
363 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_approve+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
363 | + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_approve + ($deltadateforuser * 3600), "dayhour").' '.$langs->trans("ClientHour"); |
|
364 | 364 | if ($usetable) print '</td></tr>'; |
365 | 365 | else print '<br>'; |
366 | 366 | } |
367 | 367 | |
368 | 368 | // User approve |
369 | - if (! empty($object->user_approve_id2)) |
|
369 | + if (!empty($object->user_approve_id2)) |
|
370 | 370 | { |
371 | 371 | if ($usetable) print '<tr><td class="titlefield">'; |
372 | 372 | print $langs->trans("ApprovedBy"); |
373 | 373 | if ($usetable) print '</td><td>'; |
374 | 374 | else print ': '; |
375 | - $userstatic=new User($db); |
|
375 | + $userstatic = new User($db); |
|
376 | 376 | $userstatic->fetch($object->user_approve_id2); |
377 | 377 | if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
378 | 378 | else print $langs->trans("Unknown"); |
@@ -381,20 +381,20 @@ discard block |
||
381 | 381 | } |
382 | 382 | |
383 | 383 | // Date approve |
384 | - if (! empty($object->date_approve2)) |
|
384 | + if (!empty($object->date_approve2)) |
|
385 | 385 | { |
386 | 386 | if ($usetable) print '<tr><td class="titlefield">'; |
387 | 387 | print $langs->trans("DateApprove2"); |
388 | 388 | if ($usetable) print '</td><td>'; |
389 | 389 | else print ': '; |
390 | 390 | print dol_print_date($object->date_approve2, 'dayhour'); |
391 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_approve2+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
391 | + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_approve2 + ($deltadateforuser * 3600), "dayhour").' '.$langs->trans("ClientHour"); |
|
392 | 392 | if ($usetable) print '</td></tr>'; |
393 | 393 | else print '<br>'; |
394 | 394 | } |
395 | 395 | |
396 | 396 | // User close |
397 | - if (! empty($object->user_cloture)) |
|
397 | + if (!empty($object->user_cloture)) |
|
398 | 398 | { |
399 | 399 | if ($usetable) print '<tr><td class="titlefield">'; |
400 | 400 | print $langs->trans("ClosedBy"); |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | } |
408 | 408 | else |
409 | 409 | { |
410 | - $userstatic=new User($db); |
|
410 | + $userstatic = new User($db); |
|
411 | 411 | $userstatic->fetch($object->user_cloture); |
412 | 412 | if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
413 | 413 | else print $langs->trans("Unknown"); |
@@ -417,20 +417,20 @@ discard block |
||
417 | 417 | } |
418 | 418 | |
419 | 419 | // Date close |
420 | - if (! empty($object->date_cloture)) |
|
420 | + if (!empty($object->date_cloture)) |
|
421 | 421 | { |
422 | 422 | if ($usetable) print '<tr><td class="titlefield">'; |
423 | 423 | print $langs->trans("DateClosing"); |
424 | 424 | if ($usetable) print '</td><td>'; |
425 | 425 | else print ': '; |
426 | 426 | print dol_print_date($object->date_cloture, 'dayhour'); |
427 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_cloture+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
427 | + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_cloture + ($deltadateforuser * 3600), "dayhour").' '.$langs->trans("ClientHour"); |
|
428 | 428 | if ($usetable) print '</td></tr>'; |
429 | 429 | else print '<br>'; |
430 | 430 | } |
431 | 431 | |
432 | 432 | // User conciliate |
433 | - if (! empty($object->user_rappro)) |
|
433 | + if (!empty($object->user_rappro)) |
|
434 | 434 | { |
435 | 435 | if ($usetable) print '<tr><td class="titlefield">'; |
436 | 436 | print $langs->trans("ConciliatedBy"); |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | } |
444 | 444 | else |
445 | 445 | { |
446 | - $userstatic=new User($db); |
|
446 | + $userstatic = new User($db); |
|
447 | 447 | $userstatic->fetch($object->user_rappro); |
448 | 448 | if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
449 | 449 | else print $langs->trans("Unknown"); |
@@ -453,27 +453,27 @@ discard block |
||
453 | 453 | } |
454 | 454 | |
455 | 455 | // Date conciliate |
456 | - if (! empty($object->date_rappro)) |
|
456 | + if (!empty($object->date_rappro)) |
|
457 | 457 | { |
458 | 458 | if ($usetable) print '<tr><td class="titlefield">'; |
459 | 459 | print $langs->trans("DateConciliating"); |
460 | 460 | if ($usetable) print '</td><td>'; |
461 | 461 | else print ': '; |
462 | 462 | print dol_print_date($object->date_rappro, 'dayhour'); |
463 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_rappro+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
463 | + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_rappro + ($deltadateforuser * 3600), "dayhour").' '.$langs->trans("ClientHour"); |
|
464 | 464 | if ($usetable) print '</td></tr>'; |
465 | 465 | else print '<br>'; |
466 | 466 | } |
467 | 467 | |
468 | 468 | // Date send |
469 | - if (! empty($object->date_envoi)) |
|
469 | + if (!empty($object->date_envoi)) |
|
470 | 470 | { |
471 | 471 | if ($usetable) print '<tr><td class="titlefield">'; |
472 | 472 | print $langs->trans("DateLastSend"); |
473 | 473 | if ($usetable) print '</td><td>'; |
474 | 474 | else print ': '; |
475 | 475 | print dol_print_date($object->date_envoi, 'dayhour'); |
476 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_envoi+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
476 | + if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_envoi + ($deltadateforuser * 3600), "dayhour").' '.$langs->trans("ClientHour"); |
|
477 | 477 | if ($usetable) print '</td></tr>'; |
478 | 478 | else print '<br>'; |
479 | 479 | } |
@@ -492,8 +492,8 @@ discard block |
||
492 | 492 | */ |
493 | 493 | function dolAddEmailTrackId($email, $trackingid) |
494 | 494 | { |
495 | - $tmp=explode('@',$email); |
|
496 | - return $tmp[0].'+'.$trackingid.'@'.(isset($tmp[1])?$tmp[1]:''); |
|
495 | + $tmp = explode('@', $email); |
|
496 | + return $tmp[0].'+'.$trackingid.'@'.(isset($tmp[1]) ? $tmp[1] : ''); |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | /** |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | * @param int $anchor 1: verify anchor is provided, 0: not verify anchor |
529 | 529 | * @return int 1=Check is OK, 0=Check is KO |
530 | 530 | */ |
531 | -function isValidUrl($url,$http=0,$pass=0,$port=0,$path=0,$query=0,$anchor=0) |
|
531 | +function isValidUrl($url, $http = 0, $pass = 0, $port = 0, $path = 0, $query = 0, $anchor = 0) |
|
532 | 532 | { |
533 | 533 | $ValidUrl = 0; |
534 | 534 | $urlregex = ''; |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | // HOSTNAME OR IP |
543 | 543 | //$urlregex .= "[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*"; // x allowed (ex. http://localhost, http://routerlogin) |
544 | 544 | //$urlregex .= "[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)+"; // x.x |
545 | - $urlregex .= "([a-z0-9+\$_\\\:-])+(\.[a-z0-9+\$_-][a-z0-9+\$_-]+)*"; // x ou x.xx (2 x ou plus) |
|
545 | + $urlregex .= "([a-z0-9+\$_\\\:-])+(\.[a-z0-9+\$_-][a-z0-9+\$_-]+)*"; // x ou x.xx (2 x ou plus) |
|
546 | 546 | //use only one of the above |
547 | 547 | |
548 | 548 | // PORT |
@@ -571,33 +571,33 @@ discard block |
||
571 | 571 | * @param integer $http 1 = keep both http:// and https://, 0: remove http:// but not https:// |
572 | 572 | * @return string Cleaned url |
573 | 573 | */ |
574 | -function clean_url($url,$http=1) |
|
574 | +function clean_url($url, $http = 1) |
|
575 | 575 | { |
576 | 576 | // Fixed by Matelli (see http://matelli.fr/showcases/patchs-dolibarr/fix-cleaning-url.html) |
577 | 577 | // To include the minus sign in a char class, we must not escape it but put it at the end of the class |
578 | 578 | // Also, there's no need of escape a dot sign in a class |
579 | - if (preg_match('/^(https?:[\\/]+)?([0-9A-Z.-]+\.[A-Z]{2,4})(:[0-9]+)?/i',$url,$regs)) |
|
579 | + if (preg_match('/^(https?:[\\/]+)?([0-9A-Z.-]+\.[A-Z]{2,4})(:[0-9]+)?/i', $url, $regs)) |
|
580 | 580 | { |
581 | - $proto=$regs[1]; |
|
582 | - $domain=$regs[2]; |
|
583 | - $port=isset($regs[3])?$regs[3]:''; |
|
581 | + $proto = $regs[1]; |
|
582 | + $domain = $regs[2]; |
|
583 | + $port = isset($regs[3]) ? $regs[3] : ''; |
|
584 | 584 | //print $url." -> ".$proto." - ".$domain." - ".$port; |
585 | 585 | //$url = dol_string_nospecial(trim($url)); |
586 | 586 | $url = trim($url); |
587 | 587 | |
588 | 588 | // Si http: defini on supprime le http (Si https on ne supprime pas) |
589 | - $newproto=$proto; |
|
590 | - if ($http==0) |
|
589 | + $newproto = $proto; |
|
590 | + if ($http == 0) |
|
591 | 591 | { |
592 | - if (preg_match('/^http:[\\/]+/i',$url)) |
|
592 | + if (preg_match('/^http:[\\/]+/i', $url)) |
|
593 | 593 | { |
594 | - $url = preg_replace('/^http:[\\/]+/i','',$url); |
|
594 | + $url = preg_replace('/^http:[\\/]+/i', '', $url); |
|
595 | 595 | $newproto = ''; |
596 | 596 | } |
597 | 597 | } |
598 | 598 | |
599 | 599 | // On passe le nom de domaine en minuscule |
600 | - $CleanUrl = preg_replace('/^'.preg_quote($proto.$domain,'/').'/i', $newproto.strtolower($domain), $url); |
|
600 | + $CleanUrl = preg_replace('/^'.preg_quote($proto.$domain, '/').'/i', $newproto.strtolower($domain), $url); |
|
601 | 601 | |
602 | 602 | return $CleanUrl; |
603 | 603 | } |
@@ -617,35 +617,35 @@ discard block |
||
617 | 617 | * @param bool $displaytld Display tld (default: true) |
618 | 618 | * @return string Return email with hidden parts or ''; |
619 | 619 | */ |
620 | -function dolObfuscateEmail($mail, $replace="*", $nbreplace=8, $nbdisplaymail=4, $nbdisplaydomain=3, $displaytld=true) |
|
620 | +function dolObfuscateEmail($mail, $replace = "*", $nbreplace = 8, $nbdisplaymail = 4, $nbdisplaydomain = 3, $displaytld = true) |
|
621 | 621 | { |
622 | - if(!isValidEmail($mail))return ''; |
|
622 | + if (!isValidEmail($mail))return ''; |
|
623 | 623 | $tab = explode('@', $mail); |
624 | - $tab2 = explode('.',$tab[1]); |
|
624 | + $tab2 = explode('.', $tab[1]); |
|
625 | 625 | $string_replace = ''; |
626 | 626 | $mail_name = $tab[0]; |
627 | 627 | $mail_domaine = $tab2[0]; |
628 | 628 | $mail_tld = ''; |
629 | 629 | |
630 | 630 | $nbofelem = count($tab2); |
631 | - for($i=1; $i < $nbofelem && $displaytld; $i++) |
|
631 | + for ($i = 1; $i < $nbofelem && $displaytld; $i++) |
|
632 | 632 | { |
633 | 633 | $mail_tld .= '.'.$tab2[$i]; |
634 | 634 | } |
635 | 635 | |
636 | - for($i=0; $i < $nbreplace; $i++){ |
|
636 | + for ($i = 0; $i < $nbreplace; $i++) { |
|
637 | 637 | $string_replace .= $replace; |
638 | 638 | } |
639 | 639 | |
640 | - if(strlen($mail_name) > $nbdisplaymail){ |
|
640 | + if (strlen($mail_name) > $nbdisplaymail) { |
|
641 | 641 | $mail_name = substr($mail_name, 0, $nbdisplaymail); |
642 | 642 | } |
643 | 643 | |
644 | - if(strlen($mail_domaine) > $nbdisplaydomain){ |
|
645 | - $mail_domaine = substr($mail_domaine, strlen($mail_domaine)-$nbdisplaydomain); |
|
644 | + if (strlen($mail_domaine) > $nbdisplaydomain) { |
|
645 | + $mail_domaine = substr($mail_domaine, strlen($mail_domaine) - $nbdisplaydomain); |
|
646 | 646 | } |
647 | 647 | |
648 | - return $mail_name . $string_replace . $mail_domaine . $mail_tld; |
|
648 | + return $mail_name.$string_replace.$mail_domaine.$mail_tld; |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | |
@@ -658,14 +658,14 @@ discard block |
||
658 | 658 | * @param string $tdoptions Options for td |
659 | 659 | * @return string |
660 | 660 | */ |
661 | -function array2tr($data,$troptions='',$tdoptions='') |
|
661 | +function array2tr($data, $troptions = '', $tdoptions = '') |
|
662 | 662 | { |
663 | - $text = '<tr '.$troptions.'>' ; |
|
664 | - foreach($data as $key => $item){ |
|
665 | - $text.= '<td '.$tdoptions.'>'.$item.'</td>' ; |
|
663 | + $text = '<tr '.$troptions.'>'; |
|
664 | + foreach ($data as $key => $item) { |
|
665 | + $text .= '<td '.$tdoptions.'>'.$item.'</td>'; |
|
666 | 666 | } |
667 | - $text.= '</tr>' ; |
|
668 | - return $text ; |
|
667 | + $text .= '</tr>'; |
|
668 | + return $text; |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | /** |
@@ -678,22 +678,22 @@ discard block |
||
678 | 678 | * @param string $tdoptions Options for td |
679 | 679 | * @return string |
680 | 680 | */ |
681 | -function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdoptions='') |
|
681 | +function array2table($data, $tableMarkup = 1, $tableoptions = '', $troptions = '', $tdoptions = '') |
|
682 | 682 | { |
683 | - $text='' ; |
|
684 | - if($tableMarkup) $text = '<table '.$tableoptions.'>' ; |
|
685 | - foreach($data as $key => $item){ |
|
686 | - if(is_array($item)){ |
|
687 | - $text.=array2tr($item,$troptions,$tdoptions); |
|
683 | + $text = ''; |
|
684 | + if ($tableMarkup) $text = '<table '.$tableoptions.'>'; |
|
685 | + foreach ($data as $key => $item) { |
|
686 | + if (is_array($item)) { |
|
687 | + $text .= array2tr($item, $troptions, $tdoptions); |
|
688 | 688 | } else { |
689 | - $text.= '<tr '.$troptions.'>' ; |
|
690 | - $text.= '<td '.$tdoptions.'>'.$key.'</td>' ; |
|
691 | - $text.= '<td '.$tdoptions.'>'.$item.'</td>' ; |
|
692 | - $text.= '</tr>' ; |
|
689 | + $text .= '<tr '.$troptions.'>'; |
|
690 | + $text .= '<td '.$tdoptions.'>'.$key.'</td>'; |
|
691 | + $text .= '<td '.$tdoptions.'>'.$item.'</td>'; |
|
692 | + $text .= '</tr>'; |
|
693 | 693 | } |
694 | 694 | } |
695 | - if($tableMarkup) $text.= '</table>' ; |
|
696 | - return $text ; |
|
695 | + if ($tableMarkup) $text .= '</table>'; |
|
696 | + return $text; |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | /** |
@@ -712,19 +712,19 @@ discard block |
||
712 | 712 | * @param int $forceentity Entity id to force |
713 | 713 | * @return string New value (numeric) or error message |
714 | 714 | */ |
715 | -function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next', $bentityon=true, $objuser=null, $forceentity=null) |
|
715 | +function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $date = '', $mode = 'next', $bentityon = true, $objuser = null, $forceentity = null) |
|
716 | 716 | { |
717 | - global $conf,$user; |
|
717 | + global $conf, $user; |
|
718 | 718 | |
719 | - if (! is_object($objsoc)) $valueforccc=$objsoc; |
|
720 | - else if ($table == "commande_fournisseur" || $table == "facture_fourn" ) $valueforccc=$objsoc->code_fournisseur; |
|
721 | - else $valueforccc=$objsoc->code_client; |
|
719 | + if (!is_object($objsoc)) $valueforccc = $objsoc; |
|
720 | + else if ($table == "commande_fournisseur" || $table == "facture_fourn") $valueforccc = $objsoc->code_fournisseur; |
|
721 | + else $valueforccc = $objsoc->code_client; |
|
722 | 722 | |
723 | 723 | $sharetable = $table; |
724 | 724 | if ($table == 'facture' || $table == 'invoice') $sharetable = 'invoicenumber'; // for getEntity function |
725 | 725 | |
726 | 726 | // Clean parameters |
727 | - if ($date == '') $date=dol_now(); // We use local year and month of PHP server to search numbers |
|
727 | + if ($date == '') $date = dol_now(); // We use local year and month of PHP server to search numbers |
|
728 | 728 | // but we should use local year and month of user |
729 | 729 | |
730 | 730 | // For debugging |
@@ -734,132 +734,132 @@ discard block |
||
734 | 734 | //$date=dol_mktime(12, 0, 0, 1, 1, 1900); |
735 | 735 | //$date=dol_stringtotime('20130101'); |
736 | 736 | |
737 | - $hasglobalcounter=false; |
|
737 | + $hasglobalcounter = false; |
|
738 | 738 | // Extract value for mask counter, mask raz and mask offset |
739 | - if (preg_match('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i',$mask,$reg)) |
|
739 | + if (preg_match('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i', $mask, $reg)) |
|
740 | 740 | { |
741 | - $masktri=$reg[1].(! empty($reg[2])?$reg[2]:'').(! empty($reg[3])?$reg[3]:''); |
|
742 | - $maskcounter=$reg[1]; |
|
743 | - $hasglobalcounter=true; |
|
741 | + $masktri = $reg[1].(!empty($reg[2]) ? $reg[2] : '').(!empty($reg[3]) ? $reg[3] : ''); |
|
742 | + $maskcounter = $reg[1]; |
|
743 | + $hasglobalcounter = true; |
|
744 | 744 | } |
745 | 745 | else |
746 | 746 | { |
747 | 747 | // setting some defaults so the rest of the code won't fail if there is a third party counter |
748 | - $masktri='00000'; |
|
749 | - $maskcounter='00000'; |
|
748 | + $masktri = '00000'; |
|
749 | + $maskcounter = '00000'; |
|
750 | 750 | } |
751 | 751 | |
752 | - $maskraz=-1; |
|
753 | - $maskoffset=0; |
|
754 | - $resetEveryMonth=false; |
|
752 | + $maskraz = -1; |
|
753 | + $maskoffset = 0; |
|
754 | + $resetEveryMonth = false; |
|
755 | 755 | if (dol_strlen($maskcounter) < 3 && empty($conf->global->MAIN_COUNTER_WITH_LESS_3_DIGITS)) return 'ErrorCounterMustHaveMoreThan3Digits'; |
756 | 756 | |
757 | 757 | // Extract value for third party mask counter |
758 | - if (preg_match('/\{(c+)(0*)\}/i',$mask,$regClientRef)) |
|
758 | + if (preg_match('/\{(c+)(0*)\}/i', $mask, $regClientRef)) |
|
759 | 759 | { |
760 | - $maskrefclient=$regClientRef[1].$regClientRef[2]; |
|
761 | - $maskrefclient_maskclientcode=$regClientRef[1]; |
|
762 | - $maskrefclient_maskcounter=$regClientRef[2]; |
|
763 | - $maskrefclient_maskoffset=0; //default value of maskrefclient_counter offset |
|
764 | - $maskrefclient_clientcode=substr($valueforccc,0,dol_strlen($maskrefclient_maskclientcode));//get n first characters of client code where n is length in mask |
|
765 | - $maskrefclient_clientcode=str_pad($maskrefclient_clientcode,dol_strlen($maskrefclient_maskclientcode),"#",STR_PAD_RIGHT);//padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode |
|
766 | - $maskrefclient_clientcode=dol_string_nospecial($maskrefclient_clientcode);//sanitize maskrefclient_clientcode for sql insert and sql select like |
|
760 | + $maskrefclient = $regClientRef[1].$regClientRef[2]; |
|
761 | + $maskrefclient_maskclientcode = $regClientRef[1]; |
|
762 | + $maskrefclient_maskcounter = $regClientRef[2]; |
|
763 | + $maskrefclient_maskoffset = 0; //default value of maskrefclient_counter offset |
|
764 | + $maskrefclient_clientcode = substr($valueforccc, 0, dol_strlen($maskrefclient_maskclientcode)); //get n first characters of client code where n is length in mask |
|
765 | + $maskrefclient_clientcode = str_pad($maskrefclient_clientcode, dol_strlen($maskrefclient_maskclientcode), "#", STR_PAD_RIGHT); //padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode |
|
766 | + $maskrefclient_clientcode = dol_string_nospecial($maskrefclient_clientcode); //sanitize maskrefclient_clientcode for sql insert and sql select like |
|
767 | 767 | if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; |
768 | 768 | } |
769 | - else $maskrefclient=''; |
|
769 | + else $maskrefclient = ''; |
|
770 | 770 | |
771 | 771 | // fail if there is neither a global nor a third party counter |
772 | - if (! $hasglobalcounter && ($maskrefclient_maskcounter == '')) |
|
772 | + if (!$hasglobalcounter && ($maskrefclient_maskcounter == '')) |
|
773 | 773 | { |
774 | 774 | return 'ErrorBadMask'; |
775 | 775 | } |
776 | 776 | |
777 | 777 | // Extract value for third party type |
778 | - if (preg_match('/\{(t+)\}/i',$mask,$regType)) |
|
778 | + if (preg_match('/\{(t+)\}/i', $mask, $regType)) |
|
779 | 779 | { |
780 | - $masktype=$regType[1]; |
|
781 | - $masktype_value=substr(preg_replace('/^TE_/','',$objsoc->typent_code),0,dol_strlen($regType[1]));// get n first characters of thirdpaty typent_code (where n is length in mask) |
|
782 | - $masktype_value=str_pad($masktype_value,dol_strlen($regType[1]),"#",STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask |
|
780 | + $masktype = $regType[1]; |
|
781 | + $masktype_value = substr(preg_replace('/^TE_/', '', $objsoc->typent_code), 0, dol_strlen($regType[1])); // get n first characters of thirdpaty typent_code (where n is length in mask) |
|
782 | + $masktype_value = str_pad($masktype_value, dol_strlen($regType[1]), "#", STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask |
|
783 | 783 | } |
784 | 784 | else |
785 | 785 | { |
786 | - $masktype=''; |
|
787 | - $masktype_value=''; |
|
786 | + $masktype = ''; |
|
787 | + $masktype_value = ''; |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | // Extract value for user |
791 | - if (preg_match('/\{(u+)\}/i',$mask,$regType)) |
|
791 | + if (preg_match('/\{(u+)\}/i', $mask, $regType)) |
|
792 | 792 | { |
793 | 793 | $lastname = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; |
794 | 794 | if (is_object($objuser)) $lastname = $objuser->lastname; |
795 | 795 | |
796 | - $maskuser=$regType[1]; |
|
797 | - $maskuser_value=substr($lastname,0,dol_strlen($regType[1]));// get n first characters of user firstname (where n is length in mask) |
|
798 | - $maskuser_value=str_pad($maskuser_value,dol_strlen($regType[1]),"#",STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask |
|
796 | + $maskuser = $regType[1]; |
|
797 | + $maskuser_value = substr($lastname, 0, dol_strlen($regType[1])); // get n first characters of user firstname (where n is length in mask) |
|
798 | + $maskuser_value = str_pad($maskuser_value, dol_strlen($regType[1]), "#", STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask |
|
799 | 799 | } |
800 | 800 | else |
801 | 801 | { |
802 | - $maskuser=''; |
|
803 | - $maskuser_value=''; |
|
802 | + $maskuser = ''; |
|
803 | + $maskuser_value = ''; |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | // Personalized field {XXX-1} à {XXX-9} |
807 | - $maskperso=array(); |
|
808 | - $maskpersonew=array(); |
|
809 | - $tmpmask=$mask; |
|
810 | - while (preg_match('/\{([A-Z]+)\-([1-9])\}/',$tmpmask,$regKey)) |
|
807 | + $maskperso = array(); |
|
808 | + $maskpersonew = array(); |
|
809 | + $tmpmask = $mask; |
|
810 | + while (preg_match('/\{([A-Z]+)\-([1-9])\}/', $tmpmask, $regKey)) |
|
811 | 811 | { |
812 | - $maskperso[$regKey[1]]='{'.$regKey[1].'-'.$regKey[2].'}'; |
|
813 | - $maskpersonew[$regKey[1]]=str_pad('', $regKey[2], '_', STR_PAD_RIGHT); |
|
814 | - $tmpmask=preg_replace('/\{'.$regKey[1].'\-'.$regKey[2].'\}/i', $maskpersonew[$regKey[1]], $tmpmask); |
|
812 | + $maskperso[$regKey[1]] = '{'.$regKey[1].'-'.$regKey[2].'}'; |
|
813 | + $maskpersonew[$regKey[1]] = str_pad('', $regKey[2], '_', STR_PAD_RIGHT); |
|
814 | + $tmpmask = preg_replace('/\{'.$regKey[1].'\-'.$regKey[2].'\}/i', $maskpersonew[$regKey[1]], $tmpmask); |
|
815 | 815 | } |
816 | 816 | |
817 | - if (strstr($mask,'user_extra_')) |
|
817 | + if (strstr($mask, 'user_extra_')) |
|
818 | 818 | { |
819 | 819 | $start = "{user_extra_"; |
820 | 820 | $end = "\}"; |
821 | - $extra= get_string_between($mask, "user_extra_", "}"); |
|
822 | - if(!empty($user->array_options['options_'.$extra])){ |
|
823 | - $mask = preg_replace('#('.$start.')(.*?)('.$end.')#si', $user->array_options['options_'.$extra], $mask); |
|
821 | + $extra = get_string_between($mask, "user_extra_", "}"); |
|
822 | + if (!empty($user->array_options['options_'.$extra])) { |
|
823 | + $mask = preg_replace('#('.$start.')(.*?)('.$end.')#si', $user->array_options['options_'.$extra], $mask); |
|
824 | 824 | } |
825 | 825 | } |
826 | - $maskwithonlyymcode=$mask; |
|
827 | - $maskwithonlyymcode=preg_replace('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i',$maskcounter,$maskwithonlyymcode); |
|
828 | - $maskwithonlyymcode=preg_replace('/\{dd\}/i','dd',$maskwithonlyymcode); |
|
829 | - $maskwithonlyymcode=preg_replace('/\{(c+)(0*)\}/i',$maskrefclient,$maskwithonlyymcode); |
|
830 | - $maskwithonlyymcode=preg_replace('/\{(t+)\}/i',$masktype_value,$maskwithonlyymcode); |
|
831 | - $maskwithonlyymcode=preg_replace('/\{(u+)\}/i',$maskuser_value,$maskwithonlyymcode); |
|
832 | - foreach($maskperso as $key => $val) |
|
826 | + $maskwithonlyymcode = $mask; |
|
827 | + $maskwithonlyymcode = preg_replace('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i', $maskcounter, $maskwithonlyymcode); |
|
828 | + $maskwithonlyymcode = preg_replace('/\{dd\}/i', 'dd', $maskwithonlyymcode); |
|
829 | + $maskwithonlyymcode = preg_replace('/\{(c+)(0*)\}/i', $maskrefclient, $maskwithonlyymcode); |
|
830 | + $maskwithonlyymcode = preg_replace('/\{(t+)\}/i', $masktype_value, $maskwithonlyymcode); |
|
831 | + $maskwithonlyymcode = preg_replace('/\{(u+)\}/i', $maskuser_value, $maskwithonlyymcode); |
|
832 | + foreach ($maskperso as $key => $val) |
|
833 | 833 | { |
834 | - $maskwithonlyymcode=preg_replace('/'.preg_quote($val,'/').'/i', $maskpersonew[$key], $maskwithonlyymcode); |
|
834 | + $maskwithonlyymcode = preg_replace('/'.preg_quote($val, '/').'/i', $maskpersonew[$key], $maskwithonlyymcode); |
|
835 | 835 | } |
836 | - $maskwithnocode=$maskwithonlyymcode; |
|
837 | - $maskwithnocode=preg_replace('/\{yyyy\}/i','yyyy',$maskwithnocode); |
|
838 | - $maskwithnocode=preg_replace('/\{yy\}/i','yy',$maskwithnocode); |
|
839 | - $maskwithnocode=preg_replace('/\{y\}/i','y',$maskwithnocode); |
|
840 | - $maskwithnocode=preg_replace('/\{mm\}/i','mm',$maskwithnocode); |
|
836 | + $maskwithnocode = $maskwithonlyymcode; |
|
837 | + $maskwithnocode = preg_replace('/\{yyyy\}/i', 'yyyy', $maskwithnocode); |
|
838 | + $maskwithnocode = preg_replace('/\{yy\}/i', 'yy', $maskwithnocode); |
|
839 | + $maskwithnocode = preg_replace('/\{y\}/i', 'y', $maskwithnocode); |
|
840 | + $maskwithnocode = preg_replace('/\{mm\}/i', 'mm', $maskwithnocode); |
|
841 | 841 | // Now maskwithnocode = 0000ddmmyyyyccc for example |
842 | 842 | // and maskcounter = 0000 for example |
843 | 843 | //print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n<br>"; |
844 | 844 | //var_dump($reg); |
845 | 845 | |
846 | 846 | // If an offset is asked |
847 | - if (! empty($reg[2]) && preg_match('/^\+/',$reg[2])) $maskoffset=preg_replace('/^\+/','',$reg[2]); |
|
848 | - if (! empty($reg[3]) && preg_match('/^\+/',$reg[3])) $maskoffset=preg_replace('/^\+/','',$reg[3]); |
|
847 | + if (!empty($reg[2]) && preg_match('/^\+/', $reg[2])) $maskoffset = preg_replace('/^\+/', '', $reg[2]); |
|
848 | + if (!empty($reg[3]) && preg_match('/^\+/', $reg[3])) $maskoffset = preg_replace('/^\+/', '', $reg[3]); |
|
849 | 849 | |
850 | 850 | // Define $sqlwhere |
851 | - $sqlwhere=''; |
|
852 | - $yearoffset=0; // Use year of current $date by default |
|
853 | - $yearoffsettype=false; // false: no reset, 0,-,=,+: reset at offset SOCIETE_FISCAL_MONTH_START, x=reset at offset x |
|
851 | + $sqlwhere = ''; |
|
852 | + $yearoffset = 0; // Use year of current $date by default |
|
853 | + $yearoffsettype = false; // false: no reset, 0,-,=,+: reset at offset SOCIETE_FISCAL_MONTH_START, x=reset at offset x |
|
854 | 854 | |
855 | 855 | // If a restore to zero after a month is asked we check if there is already a value for this year. |
856 | - if (! empty($reg[2]) && preg_match('/^@/',$reg[2])) $yearoffsettype = preg_replace('/^@/','',$reg[2]); |
|
857 | - if (! empty($reg[3]) && preg_match('/^@/',$reg[3])) $yearoffsettype = preg_replace('/^@/','',$reg[3]); |
|
856 | + if (!empty($reg[2]) && preg_match('/^@/', $reg[2])) $yearoffsettype = preg_replace('/^@/', '', $reg[2]); |
|
857 | + if (!empty($reg[3]) && preg_match('/^@/', $reg[3])) $yearoffsettype = preg_replace('/^@/', '', $reg[3]); |
|
858 | 858 | |
859 | 859 | //print "yearoffset=".$yearoffset." yearoffsettype=".$yearoffsettype; |
860 | 860 | if (is_numeric($yearoffsettype) && $yearoffsettype >= 1) |
861 | - $maskraz=$yearoffsettype; // For backward compatibility |
|
862 | - else if ($yearoffsettype === '0' || (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1)) |
|
861 | + $maskraz = $yearoffsettype; // For backward compatibility |
|
862 | + else if ($yearoffsettype === '0' || (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1)) |
|
863 | 863 | $maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START; |
864 | 864 | //print "maskraz=".$maskraz; // -1=no reset |
865 | 865 | |
@@ -873,79 +873,79 @@ discard block |
||
873 | 873 | // Define posy, posm and reg |
874 | 874 | if ($maskraz > 1) // if reset is not first month, we need month and year into mask |
875 | 875 | { |
876 | - if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; } |
|
877 | - elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; } |
|
876 | + if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 2; $posm = 3; } |
|
877 | + elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 3; $posm = 2; } |
|
878 | 878 | else return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; |
879 | 879 | |
880 | 880 | if (dol_strlen($reg[$posy]) < 2) return 'ErrorCantUseRazWithYearOnOneDigit'; |
881 | 881 | } |
882 | 882 | else // if reset is for a specific month in year, we need year |
883 | 883 | { |
884 | - if (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; } |
|
885 | - else if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; } |
|
886 | - else if (preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=0; } |
|
884 | + if (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 3; $posm = 2; } |
|
885 | + else if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 2; $posm = 3; } |
|
886 | + else if (preg_match('/^(.*)\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 2; $posm = 0; } |
|
887 | 887 | else return 'ErrorCantUseRazIfNoYearInMask'; |
888 | 888 | } |
889 | 889 | // Define length |
890 | - $yearlen = $posy?dol_strlen($reg[$posy]):0; |
|
891 | - $monthlen = $posm?dol_strlen($reg[$posm]):0; |
|
890 | + $yearlen = $posy ?dol_strlen($reg[$posy]) : 0; |
|
891 | + $monthlen = $posm ?dol_strlen($reg[$posm]) : 0; |
|
892 | 892 | // Define pos |
893 | - $yearpos = (dol_strlen($reg[1])+1); |
|
894 | - $monthpos = ($yearpos+$yearlen); |
|
893 | + $yearpos = (dol_strlen($reg[1]) + 1); |
|
894 | + $monthpos = ($yearpos + $yearlen); |
|
895 | 895 | if ($posy == 3 && $posm == 2) { // if month is before year |
896 | - $monthpos = (dol_strlen($reg[1])+1); |
|
897 | - $yearpos = ($monthpos+$monthlen); |
|
896 | + $monthpos = (dol_strlen($reg[1]) + 1); |
|
897 | + $yearpos = ($monthpos + $monthlen); |
|
898 | 898 | } |
899 | 899 | //print "xxx ".$maskwithonlyymcode." maskraz=".$maskraz." posy=".$posy." yearlen=".$yearlen." yearpos=".$yearpos." posm=".$posm." monthlen=".$monthlen." monthpos=".$monthpos." yearoffsettype=".$yearoffsettype." resetEveryMonth=".$resetEveryMonth."\n"; |
900 | 900 | |
901 | 901 | // Define $yearcomp and $monthcomp (that will be use in the select where to search max number) |
902 | - $monthcomp=$maskraz; |
|
903 | - $yearcomp=0; |
|
902 | + $monthcomp = $maskraz; |
|
903 | + $yearcomp = 0; |
|
904 | 904 | |
905 | - if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') // $yearoffsettype is - or + |
|
905 | + if (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $yearoffsettype != '=') // $yearoffsettype is - or + |
|
906 | 906 | { |
907 | - $currentyear=date("Y", $date); |
|
908 | - $fiscaldate=dol_mktime('0','0','0',$maskraz,'1',$currentyear); |
|
909 | - $newyeardate=dol_mktime('0','0','0','1','1',$currentyear); |
|
910 | - $nextnewyeardate=dol_mktime('0','0','0','1','1',$currentyear+1); |
|
907 | + $currentyear = date("Y", $date); |
|
908 | + $fiscaldate = dol_mktime('0', '0', '0', $maskraz, '1', $currentyear); |
|
909 | + $newyeardate = dol_mktime('0', '0', '0', '1', '1', $currentyear); |
|
910 | + $nextnewyeardate = dol_mktime('0', '0', '0', '1', '1', $currentyear + 1); |
|
911 | 911 | //echo 'currentyear='.$currentyear.' date='.dol_print_date($date, 'day').' fiscaldate='.dol_print_date($fiscaldate, 'day').'<br>'; |
912 | 912 | |
913 | 913 | // If after or equal of current fiscal date |
914 | 914 | if ($date >= $fiscaldate) |
915 | 915 | { |
916 | 916 | // If before of next new year date |
917 | - if ($date < $nextnewyeardate && $yearoffsettype == '+') $yearoffset=1; |
|
917 | + if ($date < $nextnewyeardate && $yearoffsettype == '+') $yearoffset = 1; |
|
918 | 918 | } |
919 | 919 | // If after or equal of current new year date |
920 | - else if ($date >= $newyeardate && $yearoffsettype == '-') $yearoffset=-1; |
|
920 | + else if ($date >= $newyeardate && $yearoffsettype == '-') $yearoffset = -1; |
|
921 | 921 | } |
922 | 922 | // For backward compatibility |
923 | - else if (date("m",$date) < $maskraz && empty($resetEveryMonth)) { $yearoffset=-1; } // If current month lower that month of return to zero, year is previous year |
|
923 | + else if (date("m", $date) < $maskraz && empty($resetEveryMonth)) { $yearoffset = -1; } // If current month lower that month of return to zero, year is previous year |
|
924 | 924 | |
925 | - if ($yearlen == 4) $yearcomp=sprintf("%04d",date("Y",$date)+$yearoffset); |
|
926 | - elseif ($yearlen == 2) $yearcomp=sprintf("%02d",date("y",$date)+$yearoffset); |
|
927 | - elseif ($yearlen == 1) $yearcomp=substr(date("y",$date),2,1)+$yearoffset; |
|
925 | + if ($yearlen == 4) $yearcomp = sprintf("%04d", date("Y", $date) + $yearoffset); |
|
926 | + elseif ($yearlen == 2) $yearcomp = sprintf("%02d", date("y", $date) + $yearoffset); |
|
927 | + elseif ($yearlen == 1) $yearcomp = substr(date("y", $date), 2, 1) + $yearoffset; |
|
928 | 928 | if ($monthcomp > 1 && empty($resetEveryMonth)) // Test with month is useless if monthcomp = 0 or 1 (0 is same as 1) (regis: $monthcomp can't equal 0) |
929 | 929 | { |
930 | - if ($yearlen == 4) $yearcomp1=sprintf("%04d",date("Y",$date)+$yearoffset+1); |
|
931 | - elseif ($yearlen == 2) $yearcomp1=sprintf("%02d",date("y",$date)+$yearoffset+1); |
|
932 | - |
|
933 | - $sqlwhere.="("; |
|
934 | - $sqlwhere.=" (SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'"; |
|
935 | - $sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") >= '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."')"; |
|
936 | - $sqlwhere.=" OR"; |
|
937 | - $sqlwhere.=" (SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp1."'"; |
|
938 | - $sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") < '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."') "; |
|
939 | - $sqlwhere.=')'; |
|
930 | + if ($yearlen == 4) $yearcomp1 = sprintf("%04d", date("Y", $date) + $yearoffset + 1); |
|
931 | + elseif ($yearlen == 2) $yearcomp1 = sprintf("%02d", date("y", $date) + $yearoffset + 1); |
|
932 | + |
|
933 | + $sqlwhere .= "("; |
|
934 | + $sqlwhere .= " (SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'"; |
|
935 | + $sqlwhere .= " AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") >= '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."')"; |
|
936 | + $sqlwhere .= " OR"; |
|
937 | + $sqlwhere .= " (SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp1."'"; |
|
938 | + $sqlwhere .= " AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") < '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."') "; |
|
939 | + $sqlwhere .= ')'; |
|
940 | 940 | } |
941 | 941 | else if ($resetEveryMonth) |
942 | 942 | { |
943 | - $sqlwhere.="(SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'"; |
|
944 | - $sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") = '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."')"; |
|
943 | + $sqlwhere .= "(SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'"; |
|
944 | + $sqlwhere .= " AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") = '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."')"; |
|
945 | 945 | } |
946 | 946 | else // reset is done on january |
947 | 947 | { |
948 | - $sqlwhere.='(SUBSTRING('.$field.', '.$yearpos.', '.$yearlen.") = '".$yearcomp."')"; |
|
948 | + $sqlwhere .= '(SUBSTRING('.$field.', '.$yearpos.', '.$yearlen.") = '".$yearcomp."')"; |
|
949 | 949 | } |
950 | 950 | } |
951 | 951 | //print "sqlwhere=".$sqlwhere." yearcomp=".$yearcomp."<br>\n"; // sqlwhere and yearcomp defined only if we ask a reset |
@@ -954,49 +954,49 @@ discard block |
||
954 | 954 | // Define $sqlstring |
955 | 955 | if (function_exists('mb_strrpos')) |
956 | 956 | { |
957 | - $posnumstart=mb_strrpos($maskwithnocode,$maskcounter, 'UTF-8'); |
|
957 | + $posnumstart = mb_strrpos($maskwithnocode, $maskcounter, 'UTF-8'); |
|
958 | 958 | } |
959 | 959 | else |
960 | 960 | { |
961 | - $posnumstart=strrpos($maskwithnocode,$maskcounter); |
|
961 | + $posnumstart = strrpos($maskwithnocode, $maskcounter); |
|
962 | 962 | } // Pos of counter in final string (from 0 to ...) |
963 | 963 | if ($posnumstart < 0) return 'ErrorBadMaskFailedToLocatePosOfSequence'; |
964 | - $sqlstring='SUBSTRING('.$field.', '.($posnumstart+1).', '.dol_strlen($maskcounter).')'; |
|
964 | + $sqlstring = 'SUBSTRING('.$field.', '.($posnumstart + 1).', '.dol_strlen($maskcounter).')'; |
|
965 | 965 | |
966 | 966 | // Define $maskLike |
967 | 967 | $maskLike = dol_string_nospecial($mask); |
968 | - $maskLike = str_replace("%","_",$maskLike); |
|
968 | + $maskLike = str_replace("%", "_", $maskLike); |
|
969 | 969 | // Replace protected special codes with matching number of _ as wild card caracter |
970 | - $maskLike = preg_replace('/\{yyyy\}/i','____',$maskLike); |
|
971 | - $maskLike = preg_replace('/\{yy\}/i','__',$maskLike); |
|
972 | - $maskLike = preg_replace('/\{y\}/i','_',$maskLike); |
|
973 | - $maskLike = preg_replace('/\{mm\}/i','__',$maskLike); |
|
974 | - $maskLike = preg_replace('/\{dd\}/i','__',$maskLike); |
|
975 | - $maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'),str_pad("",dol_strlen($maskcounter),"_"),$maskLike); |
|
976 | - if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",dol_strlen($maskrefclient),"_"),$maskLike); |
|
977 | - if ($masktype) $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'),$masktype_value,$maskLike); |
|
978 | - if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'),$maskuser_value,$maskLike); |
|
979 | - foreach($maskperso as $key => $val) |
|
970 | + $maskLike = preg_replace('/\{yyyy\}/i', '____', $maskLike); |
|
971 | + $maskLike = preg_replace('/\{yy\}/i', '__', $maskLike); |
|
972 | + $maskLike = preg_replace('/\{y\}/i', '_', $maskLike); |
|
973 | + $maskLike = preg_replace('/\{mm\}/i', '__', $maskLike); |
|
974 | + $maskLike = preg_replace('/\{dd\}/i', '__', $maskLike); |
|
975 | + $maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'), str_pad("", dol_strlen($maskcounter), "_"), $maskLike); |
|
976 | + if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'), str_pad("", dol_strlen($maskrefclient), "_"), $maskLike); |
|
977 | + if ($masktype) $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'), $masktype_value, $maskLike); |
|
978 | + if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'), $maskuser_value, $maskLike); |
|
979 | + foreach ($maskperso as $key => $val) |
|
980 | 980 | { |
981 | - $maskLike = str_replace(dol_string_nospecial($maskperso[$key]),$maskpersonew[$key],$maskLike); |
|
981 | + $maskLike = str_replace(dol_string_nospecial($maskperso[$key]), $maskpersonew[$key], $maskLike); |
|
982 | 982 | } |
983 | 983 | |
984 | 984 | // Get counter in database |
985 | - $counter=0; |
|
985 | + $counter = 0; |
|
986 | 986 | $sql = "SELECT MAX(".$sqlstring.") as val"; |
987 | - $sql.= " FROM ".MAIN_DB_PREFIX.$table; |
|
988 | - $sql.= " WHERE ".$field." LIKE '".$maskLike."'"; |
|
989 | - $sql.= " AND ".$field." NOT LIKE '(PROV%)'"; |
|
987 | + $sql .= " FROM ".MAIN_DB_PREFIX.$table; |
|
988 | + $sql .= " WHERE ".$field." LIKE '".$maskLike."'"; |
|
989 | + $sql .= " AND ".$field." NOT LIKE '(PROV%)'"; |
|
990 | 990 | if ($bentityon) // only if entity enable |
991 | - $sql.= " AND entity IN (".getEntity($sharetable).")"; |
|
992 | - else if (! empty($forceentity)) |
|
993 | - $sql.= " AND entity IN (".$forceentity.")"; |
|
994 | - if ($where) $sql.=$where; |
|
995 | - if ($sqlwhere) $sql.=' AND '.$sqlwhere; |
|
991 | + $sql .= " AND entity IN (".getEntity($sharetable).")"; |
|
992 | + else if (!empty($forceentity)) |
|
993 | + $sql .= " AND entity IN (".$forceentity.")"; |
|
994 | + if ($where) $sql .= $where; |
|
995 | + if ($sqlwhere) $sql .= ' AND '.$sqlwhere; |
|
996 | 996 | |
997 | 997 | //print $sql.'<br>'; |
998 | 998 | dol_syslog("functions2::get_next_value mode=".$mode."", LOG_DEBUG); |
999 | - $resql=$db->query($sql); |
|
999 | + $resql = $db->query($sql); |
|
1000 | 1000 | if ($resql) |
1001 | 1001 | { |
1002 | 1002 | $obj = $db->fetch_object($resql); |
@@ -1005,46 +1005,46 @@ discard block |
||
1005 | 1005 | else dol_print_error($db); |
1006 | 1006 | |
1007 | 1007 | // Check if we must force counter to maskoffset |
1008 | - if (empty($counter)) $counter=$maskoffset; |
|
1009 | - else if (preg_match('/[^0-9]/i',$counter)) |
|
1008 | + if (empty($counter)) $counter = $maskoffset; |
|
1009 | + else if (preg_match('/[^0-9]/i', $counter)) |
|
1010 | 1010 | { |
1011 | - $counter=0; |
|
1011 | + $counter = 0; |
|
1012 | 1012 | dol_syslog("Error, the last counter found is '".$counter."' so is not a numeric value. We will restart to 1.", LOG_ERR); |
1013 | 1013 | } |
1014 | - else if ($counter < $maskoffset && empty($conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) $counter=$maskoffset; |
|
1014 | + else if ($counter < $maskoffset && empty($conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) $counter = $maskoffset; |
|
1015 | 1015 | |
1016 | 1016 | if ($mode == 'last') // We found value for counter = last counter value. Now need to get corresponding ref of invoice. |
1017 | 1017 | { |
1018 | - $counterpadded=str_pad($counter,dol_strlen($maskcounter),"0",STR_PAD_LEFT); |
|
1018 | + $counterpadded = str_pad($counter, dol_strlen($maskcounter), "0", STR_PAD_LEFT); |
|
1019 | 1019 | |
1020 | 1020 | // Define $maskLike |
1021 | 1021 | $maskLike = dol_string_nospecial($mask); |
1022 | - $maskLike = str_replace("%","_",$maskLike); |
|
1022 | + $maskLike = str_replace("%", "_", $maskLike); |
|
1023 | 1023 | // Replace protected special codes with matching number of _ as wild card caracter |
1024 | - $maskLike = preg_replace('/\{yyyy\}/i','____',$maskLike); |
|
1025 | - $maskLike = preg_replace('/\{yy\}/i','__',$maskLike); |
|
1026 | - $maskLike = preg_replace('/\{y\}/i','_',$maskLike); |
|
1027 | - $maskLike = preg_replace('/\{mm\}/i','__',$maskLike); |
|
1028 | - $maskLike = preg_replace('/\{dd\}/i','__',$maskLike); |
|
1029 | - $maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'),$counterpadded,$maskLike); |
|
1030 | - if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",dol_strlen($maskrefclient),"_"),$maskLike); |
|
1031 | - if ($masktype) $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'),$masktype_value,$maskLike); |
|
1032 | - if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'),$maskuser_value,$maskLike); |
|
1033 | - |
|
1034 | - $ref=''; |
|
1024 | + $maskLike = preg_replace('/\{yyyy\}/i', '____', $maskLike); |
|
1025 | + $maskLike = preg_replace('/\{yy\}/i', '__', $maskLike); |
|
1026 | + $maskLike = preg_replace('/\{y\}/i', '_', $maskLike); |
|
1027 | + $maskLike = preg_replace('/\{mm\}/i', '__', $maskLike); |
|
1028 | + $maskLike = preg_replace('/\{dd\}/i', '__', $maskLike); |
|
1029 | + $maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'), $counterpadded, $maskLike); |
|
1030 | + if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'), str_pad("", dol_strlen($maskrefclient), "_"), $maskLike); |
|
1031 | + if ($masktype) $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'), $masktype_value, $maskLike); |
|
1032 | + if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'), $maskuser_value, $maskLike); |
|
1033 | + |
|
1034 | + $ref = ''; |
|
1035 | 1035 | $sql = "SELECT ".$field." as ref"; |
1036 | - $sql.= " FROM ".MAIN_DB_PREFIX.$table; |
|
1037 | - $sql.= " WHERE ".$field." LIKE '".$maskLike."'"; |
|
1038 | - $sql.= " AND ".$field." NOT LIKE '%PROV%'"; |
|
1036 | + $sql .= " FROM ".MAIN_DB_PREFIX.$table; |
|
1037 | + $sql .= " WHERE ".$field." LIKE '".$maskLike."'"; |
|
1038 | + $sql .= " AND ".$field." NOT LIKE '%PROV%'"; |
|
1039 | 1039 | if ($bentityon) // only if entity enable |
1040 | - $sql.= " AND entity IN (".getEntity($sharetable).")"; |
|
1041 | - else if (! empty($forceentity)) |
|
1042 | - $sql.= " AND entity IN (".$forceentity.")"; |
|
1043 | - if ($where) $sql.=$where; |
|
1044 | - if ($sqlwhere) $sql.=' AND '.$sqlwhere; |
|
1040 | + $sql .= " AND entity IN (".getEntity($sharetable).")"; |
|
1041 | + else if (!empty($forceentity)) |
|
1042 | + $sql .= " AND entity IN (".$forceentity.")"; |
|
1043 | + if ($where) $sql .= $where; |
|
1044 | + if ($sqlwhere) $sql .= ' AND '.$sqlwhere; |
|
1045 | 1045 | |
1046 | 1046 | dol_syslog("functions2::get_next_value mode=".$mode."", LOG_DEBUG); |
1047 | - $resql=$db->query($sql); |
|
1047 | + $resql = $db->query($sql); |
|
1048 | 1048 | if ($resql) |
1049 | 1049 | { |
1050 | 1050 | $obj = $db->fetch_object($resql); |
@@ -1052,7 +1052,7 @@ discard block |
||
1052 | 1052 | } |
1053 | 1053 | else dol_print_error($db); |
1054 | 1054 | |
1055 | - $numFinal=$ref; |
|
1055 | + $numFinal = $ref; |
|
1056 | 1056 | } |
1057 | 1057 | else if ($mode == 'next') |
1058 | 1058 | { |
@@ -1061,47 +1061,47 @@ discard block |
||
1061 | 1061 | // If value for $counter has a length higher than $maskcounter chars |
1062 | 1062 | if ($counter >= pow(10, dol_strlen($maskcounter))) |
1063 | 1063 | { |
1064 | - $counter='ErrorMaxNumberReachForThisMask'; |
|
1064 | + $counter = 'ErrorMaxNumberReachForThisMask'; |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | - if (! empty($maskrefclient_maskcounter)) |
|
1067 | + if (!empty($maskrefclient_maskcounter)) |
|
1068 | 1068 | { |
1069 | 1069 | //print "maskrefclient_maskcounter=".$maskrefclient_maskcounter." maskwithnocode=".$maskwithnocode." maskrefclient=".$maskrefclient."\n<br>"; |
1070 | 1070 | |
1071 | 1071 | // Define $sqlstring |
1072 | - $maskrefclient_posnumstart=strpos($maskwithnocode,$maskrefclient_maskcounter,strpos($maskwithnocode,$maskrefclient)); // Pos of counter in final string (from 0 to ...) |
|
1072 | + $maskrefclient_posnumstart = strpos($maskwithnocode, $maskrefclient_maskcounter, strpos($maskwithnocode, $maskrefclient)); // Pos of counter in final string (from 0 to ...) |
|
1073 | 1073 | if ($maskrefclient_posnumstart <= 0) return 'ErrorBadMask'; |
1074 | - $maskrefclient_sqlstring='SUBSTRING('.$field.', '.($maskrefclient_posnumstart+1).', '.dol_strlen($maskrefclient_maskcounter).')'; |
|
1074 | + $maskrefclient_sqlstring = 'SUBSTRING('.$field.', '.($maskrefclient_posnumstart + 1).', '.dol_strlen($maskrefclient_maskcounter).')'; |
|
1075 | 1075 | //print "x".$sqlstring; |
1076 | 1076 | |
1077 | 1077 | // Define $maskrefclient_maskLike |
1078 | 1078 | $maskrefclient_maskLike = dol_string_nospecial($mask); |
1079 | - $maskrefclient_maskLike = str_replace("%","_",$maskrefclient_maskLike); |
|
1079 | + $maskrefclient_maskLike = str_replace("%", "_", $maskrefclient_maskLike); |
|
1080 | 1080 | // Replace protected special codes with matching number of _ as wild card caracter |
1081 | - $maskrefclient_maskLike = str_replace(dol_string_nospecial('{yyyy}'),'____',$maskrefclient_maskLike); |
|
1082 | - $maskrefclient_maskLike = str_replace(dol_string_nospecial('{yy}'),'__',$maskrefclient_maskLike); |
|
1083 | - $maskrefclient_maskLike = str_replace(dol_string_nospecial('{y}'),'_',$maskrefclient_maskLike); |
|
1084 | - $maskrefclient_maskLike = str_replace(dol_string_nospecial('{mm}'),'__',$maskrefclient_maskLike); |
|
1085 | - $maskrefclient_maskLike = str_replace(dol_string_nospecial('{dd}'),'__',$maskrefclient_maskLike); |
|
1086 | - $maskrefclient_maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'),str_pad("",dol_strlen($maskcounter),"_"),$maskrefclient_maskLike); |
|
1087 | - $maskrefclient_maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),$maskrefclient_clientcode.str_pad("",dol_strlen($maskrefclient_maskcounter),"_"),$maskrefclient_maskLike); |
|
1081 | + $maskrefclient_maskLike = str_replace(dol_string_nospecial('{yyyy}'), '____', $maskrefclient_maskLike); |
|
1082 | + $maskrefclient_maskLike = str_replace(dol_string_nospecial('{yy}'), '__', $maskrefclient_maskLike); |
|
1083 | + $maskrefclient_maskLike = str_replace(dol_string_nospecial('{y}'), '_', $maskrefclient_maskLike); |
|
1084 | + $maskrefclient_maskLike = str_replace(dol_string_nospecial('{mm}'), '__', $maskrefclient_maskLike); |
|
1085 | + $maskrefclient_maskLike = str_replace(dol_string_nospecial('{dd}'), '__', $maskrefclient_maskLike); |
|
1086 | + $maskrefclient_maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'), str_pad("", dol_strlen($maskcounter), "_"), $maskrefclient_maskLike); |
|
1087 | + $maskrefclient_maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'), $maskrefclient_clientcode.str_pad("", dol_strlen($maskrefclient_maskcounter), "_"), $maskrefclient_maskLike); |
|
1088 | 1088 | |
1089 | 1089 | // Get counter in database |
1090 | - $maskrefclient_counter=0; |
|
1090 | + $maskrefclient_counter = 0; |
|
1091 | 1091 | $maskrefclient_sql = "SELECT MAX(".$maskrefclient_sqlstring.") as val"; |
1092 | - $maskrefclient_sql.= " FROM ".MAIN_DB_PREFIX.$table; |
|
1092 | + $maskrefclient_sql .= " FROM ".MAIN_DB_PREFIX.$table; |
|
1093 | 1093 | //$sql.= " WHERE ".$field." not like '(%'"; |
1094 | - $maskrefclient_sql.= " WHERE ".$field." LIKE '".$maskrefclient_maskLike."'"; |
|
1094 | + $maskrefclient_sql .= " WHERE ".$field." LIKE '".$maskrefclient_maskLike."'"; |
|
1095 | 1095 | if ($bentityon) // only if entity enable |
1096 | - $maskrefclient_sql.= " AND entity IN (".getEntity($sharetable).")"; |
|
1097 | - else if (! empty($forceentity)) |
|
1098 | - $sql.= " AND entity IN (".$forceentity.")"; |
|
1099 | - if ($where) $maskrefclient_sql.=$where; //use the same optional where as general mask |
|
1100 | - if ($sqlwhere) $maskrefclient_sql.=' AND '.$sqlwhere; //use the same sqlwhere as general mask |
|
1101 | - $maskrefclient_sql.=' AND (SUBSTRING('.$field.', '.(strpos($maskwithnocode,$maskrefclient)+1).', '.dol_strlen($maskrefclient_maskclientcode).")='".$maskrefclient_clientcode."')"; |
|
1096 | + $maskrefclient_sql .= " AND entity IN (".getEntity($sharetable).")"; |
|
1097 | + else if (!empty($forceentity)) |
|
1098 | + $sql .= " AND entity IN (".$forceentity.")"; |
|
1099 | + if ($where) $maskrefclient_sql .= $where; //use the same optional where as general mask |
|
1100 | + if ($sqlwhere) $maskrefclient_sql .= ' AND '.$sqlwhere; //use the same sqlwhere as general mask |
|
1101 | + $maskrefclient_sql .= ' AND (SUBSTRING('.$field.', '.(strpos($maskwithnocode, $maskrefclient) + 1).', '.dol_strlen($maskrefclient_maskclientcode).")='".$maskrefclient_clientcode."')"; |
|
1102 | 1102 | |
1103 | 1103 | dol_syslog("functions2::get_next_value maskrefclient", LOG_DEBUG); |
1104 | - $maskrefclient_resql=$db->query($maskrefclient_sql); |
|
1104 | + $maskrefclient_resql = $db->query($maskrefclient_sql); |
|
1105 | 1105 | if ($maskrefclient_resql) |
1106 | 1106 | { |
1107 | 1107 | $maskrefclient_obj = $db->fetch_object($maskrefclient_resql); |
@@ -1109,7 +1109,7 @@ discard block |
||
1109 | 1109 | } |
1110 | 1110 | else dol_print_error($db); |
1111 | 1111 | |
1112 | - if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i',$maskrefclient_counter)) $maskrefclient_counter=$maskrefclient_maskoffset; |
|
1112 | + if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i', $maskrefclient_counter)) $maskrefclient_counter = $maskrefclient_maskoffset; |
|
1113 | 1113 | $maskrefclient_counter++; |
1114 | 1114 | } |
1115 | 1115 | |
@@ -1117,54 +1117,54 @@ discard block |
||
1117 | 1117 | $numFinal = $mask; |
1118 | 1118 | |
1119 | 1119 | // We replace special codes except refclient |
1120 | - if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') // yearoffsettype is - or +, so we don't want current year |
|
1120 | + if (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $yearoffsettype != '=') // yearoffsettype is - or +, so we don't want current year |
|
1121 | 1121 | { |
1122 | - $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date)+$yearoffset, $numFinal); |
|
1123 | - $numFinal = preg_replace('/\{yy\}/i', date("y",$date)+$yearoffset, $numFinal); |
|
1124 | - $numFinal = preg_replace('/\{y\}/i', substr(date("y",$date),1,1)+$yearoffset, $numFinal); |
|
1122 | + $numFinal = preg_replace('/\{yyyy\}/i', date("Y", $date) + $yearoffset, $numFinal); |
|
1123 | + $numFinal = preg_replace('/\{yy\}/i', date("y", $date) + $yearoffset, $numFinal); |
|
1124 | + $numFinal = preg_replace('/\{y\}/i', substr(date("y", $date), 1, 1) + $yearoffset, $numFinal); |
|
1125 | 1125 | } |
1126 | 1126 | else // we want yyyy to be current year |
1127 | 1127 | { |
1128 | - $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date), $numFinal); |
|
1129 | - $numFinal = preg_replace('/\{yy\}/i', date("y",$date), $numFinal); |
|
1130 | - $numFinal = preg_replace('/\{y\}/i', substr(date("y",$date),1,1), $numFinal); |
|
1128 | + $numFinal = preg_replace('/\{yyyy\}/i', date("Y", $date), $numFinal); |
|
1129 | + $numFinal = preg_replace('/\{yy\}/i', date("y", $date), $numFinal); |
|
1130 | + $numFinal = preg_replace('/\{y\}/i', substr(date("y", $date), 1, 1), $numFinal); |
|
1131 | 1131 | } |
1132 | - $numFinal = preg_replace('/\{mm\}/i', date("m",$date), $numFinal); |
|
1133 | - $numFinal = preg_replace('/\{dd\}/i', date("d",$date), $numFinal); |
|
1132 | + $numFinal = preg_replace('/\{mm\}/i', date("m", $date), $numFinal); |
|
1133 | + $numFinal = preg_replace('/\{dd\}/i', date("d", $date), $numFinal); |
|
1134 | 1134 | |
1135 | 1135 | // Now we replace the counter |
1136 | - $maskbefore='{'.$masktri.'}'; |
|
1137 | - $maskafter=str_pad($counter,dol_strlen($maskcounter),"0",STR_PAD_LEFT); |
|
1136 | + $maskbefore = '{'.$masktri.'}'; |
|
1137 | + $maskafter = str_pad($counter, dol_strlen($maskcounter), "0", STR_PAD_LEFT); |
|
1138 | 1138 | //print 'x'.$maskbefore.'-'.$maskafter.'y'; |
1139 | - $numFinal = str_replace($maskbefore,$maskafter,$numFinal); |
|
1139 | + $numFinal = str_replace($maskbefore, $maskafter, $numFinal); |
|
1140 | 1140 | |
1141 | 1141 | // Now we replace the refclient |
1142 | 1142 | if ($maskrefclient) |
1143 | 1143 | { |
1144 | 1144 | //print "maskrefclient=".$maskrefclient." maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n<br>"; |
1145 | - $maskrefclient_maskbefore='{'.$maskrefclient.'}'; |
|
1146 | - $maskrefclient_maskafter=$maskrefclient_clientcode.str_pad($maskrefclient_counter,dol_strlen($maskrefclient_maskcounter),"0",STR_PAD_LEFT); |
|
1147 | - $numFinal = str_replace($maskrefclient_maskbefore,$maskrefclient_maskafter,$numFinal); |
|
1145 | + $maskrefclient_maskbefore = '{'.$maskrefclient.'}'; |
|
1146 | + $maskrefclient_maskafter = $maskrefclient_clientcode.str_pad($maskrefclient_counter, dol_strlen($maskrefclient_maskcounter), "0", STR_PAD_LEFT); |
|
1147 | + $numFinal = str_replace($maskrefclient_maskbefore, $maskrefclient_maskafter, $numFinal); |
|
1148 | 1148 | } |
1149 | 1149 | |
1150 | 1150 | // Now we replace the type |
1151 | 1151 | if ($masktype) |
1152 | 1152 | { |
1153 | - $masktype_maskbefore='{'.$masktype.'}'; |
|
1154 | - $masktype_maskafter=$masktype_value; |
|
1155 | - $numFinal = str_replace($masktype_maskbefore,$masktype_maskafter,$numFinal); |
|
1153 | + $masktype_maskbefore = '{'.$masktype.'}'; |
|
1154 | + $masktype_maskafter = $masktype_value; |
|
1155 | + $numFinal = str_replace($masktype_maskbefore, $masktype_maskafter, $numFinal); |
|
1156 | 1156 | } |
1157 | 1157 | |
1158 | 1158 | // Now we replace the user |
1159 | 1159 | if ($maskuser) |
1160 | 1160 | { |
1161 | - $maskuser_maskbefore='{'.$maskuser.'}'; |
|
1162 | - $maskuser_maskafter=$maskuser_value; |
|
1163 | - $numFinal = str_replace($maskuser_maskbefore,$maskuser_maskafter,$numFinal); |
|
1161 | + $maskuser_maskbefore = '{'.$maskuser.'}'; |
|
1162 | + $maskuser_maskafter = $maskuser_value; |
|
1163 | + $numFinal = str_replace($maskuser_maskbefore, $maskuser_maskafter, $numFinal); |
|
1164 | 1164 | } |
1165 | 1165 | } |
1166 | 1166 | |
1167 | - dol_syslog("functions2::get_next_value return ".$numFinal,LOG_DEBUG); |
|
1167 | + dol_syslog("functions2::get_next_value return ".$numFinal, LOG_DEBUG); |
|
1168 | 1168 | return $numFinal; |
1169 | 1169 | } |
1170 | 1170 | |
@@ -1179,11 +1179,11 @@ discard block |
||
1179 | 1179 | function get_string_between($string, $start, $end) |
1180 | 1180 | { |
1181 | 1181 | $string = " ".$string; |
1182 | - $ini = strpos($string,$start); |
|
1182 | + $ini = strpos($string, $start); |
|
1183 | 1183 | if ($ini == 0) return ""; |
1184 | 1184 | $ini += strlen($start); |
1185 | - $len = strpos($string,$end,$ini) - $ini; |
|
1186 | - return substr($string,$ini,$len); |
|
1185 | + $len = strpos($string, $end, $ini) - $ini; |
|
1186 | + return substr($string, $ini, $len); |
|
1187 | 1187 | } |
1188 | 1188 | |
1189 | 1189 | /** |
@@ -1193,78 +1193,78 @@ discard block |
||
1193 | 1193 | * @param string $value Value |
1194 | 1194 | * @return int|string <0 or error string if KO, 0 if OK |
1195 | 1195 | */ |
1196 | -function check_value($mask,$value) |
|
1196 | +function check_value($mask, $value) |
|
1197 | 1197 | { |
1198 | - $result=0; |
|
1198 | + $result = 0; |
|
1199 | 1199 | |
1200 | - $hasglobalcounter=false; |
|
1200 | + $hasglobalcounter = false; |
|
1201 | 1201 | // Extract value for mask counter, mask raz and mask offset |
1202 | - if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$mask,$reg)) |
|
1202 | + if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg)) |
|
1203 | 1203 | { |
1204 | - $masktri=$reg[1].(isset($reg[2])?$reg[2]:'').(isset($reg[3])?$reg[3]:''); |
|
1205 | - $maskcounter=$reg[1]; |
|
1206 | - $hasglobalcounter=true; |
|
1204 | + $masktri = $reg[1].(isset($reg[2]) ? $reg[2] : '').(isset($reg[3]) ? $reg[3] : ''); |
|
1205 | + $maskcounter = $reg[1]; |
|
1206 | + $hasglobalcounter = true; |
|
1207 | 1207 | } |
1208 | 1208 | else |
1209 | 1209 | { |
1210 | 1210 | // setting some defaults so the rest of the code won't fail if there is a third party counter |
1211 | - $masktri='00000'; |
|
1212 | - $maskcounter='00000'; |
|
1211 | + $masktri = '00000'; |
|
1212 | + $maskcounter = '00000'; |
|
1213 | 1213 | } |
1214 | 1214 | |
1215 | - $maskraz=-1; |
|
1216 | - $maskoffset=0; |
|
1215 | + $maskraz = -1; |
|
1216 | + $maskoffset = 0; |
|
1217 | 1217 | if (dol_strlen($maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; |
1218 | 1218 | |
1219 | 1219 | // Extract value for third party mask counter |
1220 | - if (preg_match('/\{(c+)(0*)\}/i',$mask,$regClientRef)) |
|
1220 | + if (preg_match('/\{(c+)(0*)\}/i', $mask, $regClientRef)) |
|
1221 | 1221 | { |
1222 | - $maskrefclient=$regClientRef[1].$regClientRef[2]; |
|
1223 | - $maskrefclient_maskclientcode=$regClientRef[1]; |
|
1224 | - $maskrefclient_maskcounter=$regClientRef[2]; |
|
1225 | - $maskrefclient_maskoffset=0; //default value of maskrefclient_counter offset |
|
1226 | - $maskrefclient_clientcode=substr('',0,dol_strlen($maskrefclient_maskclientcode));//get n first characters of client code to form maskrefclient_clientcode |
|
1227 | - $maskrefclient_clientcode=str_pad($maskrefclient_clientcode,dol_strlen($maskrefclient_maskclientcode),"#",STR_PAD_RIGHT);//padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode |
|
1228 | - $maskrefclient_clientcode=dol_string_nospecial($maskrefclient_clientcode);//sanitize maskrefclient_clientcode for sql insert and sql select like |
|
1222 | + $maskrefclient = $regClientRef[1].$regClientRef[2]; |
|
1223 | + $maskrefclient_maskclientcode = $regClientRef[1]; |
|
1224 | + $maskrefclient_maskcounter = $regClientRef[2]; |
|
1225 | + $maskrefclient_maskoffset = 0; //default value of maskrefclient_counter offset |
|
1226 | + $maskrefclient_clientcode = substr('', 0, dol_strlen($maskrefclient_maskclientcode)); //get n first characters of client code to form maskrefclient_clientcode |
|
1227 | + $maskrefclient_clientcode = str_pad($maskrefclient_clientcode, dol_strlen($maskrefclient_maskclientcode), "#", STR_PAD_RIGHT); //padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode |
|
1228 | + $maskrefclient_clientcode = dol_string_nospecial($maskrefclient_clientcode); //sanitize maskrefclient_clientcode for sql insert and sql select like |
|
1229 | 1229 | if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; |
1230 | 1230 | } |
1231 | - else $maskrefclient=''; |
|
1231 | + else $maskrefclient = ''; |
|
1232 | 1232 | |
1233 | 1233 | // fail if there is neither a global nor a third party counter |
1234 | - if (! $hasglobalcounter && ($maskrefclient_maskcounter == '')) |
|
1234 | + if (!$hasglobalcounter && ($maskrefclient_maskcounter == '')) |
|
1235 | 1235 | { |
1236 | 1236 | return 'ErrorBadMask'; |
1237 | 1237 | } |
1238 | 1238 | |
1239 | - $maskwithonlyymcode=$mask; |
|
1240 | - $maskwithonlyymcode=preg_replace('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$maskcounter,$maskwithonlyymcode); |
|
1241 | - $maskwithonlyymcode=preg_replace('/\{dd\}/i','dd',$maskwithonlyymcode); |
|
1242 | - $maskwithonlyymcode=preg_replace('/\{(c+)(0*)\}/i',$maskrefclient,$maskwithonlyymcode); |
|
1243 | - $maskwithnocode=$maskwithonlyymcode; |
|
1244 | - $maskwithnocode=preg_replace('/\{yyyy\}/i','yyyy',$maskwithnocode); |
|
1245 | - $maskwithnocode=preg_replace('/\{yy\}/i','yy',$maskwithnocode); |
|
1246 | - $maskwithnocode=preg_replace('/\{y\}/i','y',$maskwithnocode); |
|
1247 | - $maskwithnocode=preg_replace('/\{mm\}/i','mm',$maskwithnocode); |
|
1239 | + $maskwithonlyymcode = $mask; |
|
1240 | + $maskwithonlyymcode = preg_replace('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $maskcounter, $maskwithonlyymcode); |
|
1241 | + $maskwithonlyymcode = preg_replace('/\{dd\}/i', 'dd', $maskwithonlyymcode); |
|
1242 | + $maskwithonlyymcode = preg_replace('/\{(c+)(0*)\}/i', $maskrefclient, $maskwithonlyymcode); |
|
1243 | + $maskwithnocode = $maskwithonlyymcode; |
|
1244 | + $maskwithnocode = preg_replace('/\{yyyy\}/i', 'yyyy', $maskwithnocode); |
|
1245 | + $maskwithnocode = preg_replace('/\{yy\}/i', 'yy', $maskwithnocode); |
|
1246 | + $maskwithnocode = preg_replace('/\{y\}/i', 'y', $maskwithnocode); |
|
1247 | + $maskwithnocode = preg_replace('/\{mm\}/i', 'mm', $maskwithnocode); |
|
1248 | 1248 | // Now maskwithnocode = 0000ddmmyyyyccc for example |
1249 | 1249 | // and maskcounter = 0000 for example |
1250 | 1250 | //print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n<br>"; |
1251 | 1251 | |
1252 | 1252 | // If an offset is asked |
1253 | - if (! empty($reg[2]) && preg_match('/^\+/',$reg[2])) $maskoffset=preg_replace('/^\+/','',$reg[2]); |
|
1254 | - if (! empty($reg[3]) && preg_match('/^\+/',$reg[3])) $maskoffset=preg_replace('/^\+/','',$reg[3]); |
|
1253 | + if (!empty($reg[2]) && preg_match('/^\+/', $reg[2])) $maskoffset = preg_replace('/^\+/', '', $reg[2]); |
|
1254 | + if (!empty($reg[3]) && preg_match('/^\+/', $reg[3])) $maskoffset = preg_replace('/^\+/', '', $reg[3]); |
|
1255 | 1255 | |
1256 | 1256 | // Define $sqlwhere |
1257 | 1257 | |
1258 | 1258 | // If a restore to zero after a month is asked we check if there is already a value for this year. |
1259 | - if (! empty($reg[2]) && preg_match('/^@/',$reg[2])) $maskraz=preg_replace('/^@/','',$reg[2]); |
|
1260 | - if (! empty($reg[3]) && preg_match('/^@/',$reg[3])) $maskraz=preg_replace('/^@/','',$reg[3]); |
|
1259 | + if (!empty($reg[2]) && preg_match('/^@/', $reg[2])) $maskraz = preg_replace('/^@/', '', $reg[2]); |
|
1260 | + if (!empty($reg[3]) && preg_match('/^@/', $reg[3])) $maskraz = preg_replace('/^@/', '', $reg[3]); |
|
1261 | 1261 | if ($maskraz >= 0) |
1262 | 1262 | { |
1263 | 1263 | if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; |
1264 | 1264 | |
1265 | 1265 | // Define reg |
1266 | - if ($maskraz > 1 && ! preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; |
|
1267 | - if ($maskraz <= 1 && ! preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) return 'ErrorCantUseRazIfNoYearInMask'; |
|
1266 | + if ($maskraz > 1 && !preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; |
|
1267 | + if ($maskraz <= 1 && !preg_match('/^(.*)\{(y+)\}/i', $maskwithonlyymcode, $reg)) return 'ErrorCantUseRazIfNoYearInMask'; |
|
1268 | 1268 | //print "x".$maskwithonlyymcode." ".$maskraz; |
1269 | 1269 | } |
1270 | 1270 | //print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset."<br>\n"; |
@@ -1273,8 +1273,8 @@ discard block |
||
1273 | 1273 | // |
1274 | 1274 | |
1275 | 1275 | // Check length |
1276 | - $len=dol_strlen($maskwithnocode); |
|
1277 | - if (dol_strlen($value) != $len) $result=-1; |
|
1276 | + $len = dol_strlen($maskwithnocode); |
|
1277 | + if (dol_strlen($value) != $len) $result = -1; |
|
1278 | 1278 | |
1279 | 1279 | // Define $maskLike |
1280 | 1280 | /* seems not used |
@@ -1290,7 +1290,7 @@ discard block |
||
1290 | 1290 | if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",strlen($maskrefclient),"_"),$maskLike); |
1291 | 1291 | */ |
1292 | 1292 | |
1293 | - dol_syslog("functions2::check_value result=".$result,LOG_DEBUG); |
|
1293 | + dol_syslog("functions2::check_value result=".$result, LOG_DEBUG); |
|
1294 | 1294 | return $result; |
1295 | 1295 | } |
1296 | 1296 | |
@@ -1302,13 +1302,13 @@ discard block |
||
1302 | 1302 | * @param boolean $upper Convert to tupper |
1303 | 1303 | * @return string x |
1304 | 1304 | */ |
1305 | -function binhex($bin, $pad=false, $upper=false) |
|
1305 | +function binhex($bin, $pad = false, $upper = false) |
|
1306 | 1306 | { |
1307 | - $last = dol_strlen($bin)-1; |
|
1308 | - for($i=0; $i<=$last; $i++){ $x += $bin[$last-$i] * pow(2,$i); } |
|
1307 | + $last = dol_strlen($bin) - 1; |
|
1308 | + for ($i = 0; $i <= $last; $i++) { $x += $bin[$last - $i] * pow(2, $i); } |
|
1309 | 1309 | $x = dechex($x); |
1310 | - if($pad){ while(dol_strlen($x) < intval(dol_strlen($bin))/4){ $x = "0$x"; } } |
|
1311 | - if($upper){ $x = strtoupper($x); } |
|
1310 | + if ($pad) { while (dol_strlen($x) < intval(dol_strlen($bin)) / 4) { $x = "0$x"; } } |
|
1311 | + if ($upper) { $x = strtoupper($x); } |
|
1312 | 1312 | return $x; |
1313 | 1313 | } |
1314 | 1314 | |
@@ -1320,11 +1320,11 @@ discard block |
||
1320 | 1320 | */ |
1321 | 1321 | function hexbin($hexa) |
1322 | 1322 | { |
1323 | - $bin=''; |
|
1323 | + $bin = ''; |
|
1324 | 1324 | $strLength = dol_strlen($hexa); |
1325 | - for($i=0;$i<$strLength;$i++) |
|
1325 | + for ($i = 0; $i < $strLength; $i++) |
|
1326 | 1326 | { |
1327 | - $bin.=str_pad(decbin(hexdec($hexa{$i})),4,'0',STR_PAD_LEFT); |
|
1327 | + $bin .= str_pad(decbin(hexdec($hexa{$i})), 4, '0', STR_PAD_LEFT); |
|
1328 | 1328 | } |
1329 | 1329 | return $bin; |
1330 | 1330 | } |
@@ -1337,9 +1337,9 @@ discard block |
||
1337 | 1337 | */ |
1338 | 1338 | function numero_semaine($time) |
1339 | 1339 | { |
1340 | - $stime = strftime('%Y-%m-%d',$time); |
|
1340 | + $stime = strftime('%Y-%m-%d', $time); |
|
1341 | 1341 | |
1342 | - if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/i',$stime,$reg)) |
|
1342 | + if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/i', $stime, $reg)) |
|
1343 | 1343 | { |
1344 | 1344 | // Date est au format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS' |
1345 | 1345 | $annee = $reg[1]; |
@@ -1355,47 +1355,47 @@ discard block |
||
1355 | 1355 | */ |
1356 | 1356 | |
1357 | 1357 | // Definition du Jeudi de la semaine |
1358 | - if (date("w",mktime(12,0,0,$mois,$jour,$annee))==0) // Dimanche |
|
1359 | - $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-3*24*60*60; |
|
1360 | - else if (date("w",mktime(12,0,0,$mois,$jour,$annee))<4) // du Lundi au Mercredi |
|
1361 | - $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)+(4-date("w",mktime(12,0,0,$mois,$jour,$annee)))*24*60*60; |
|
1362 | - else if (date("w",mktime(12,0,0,$mois,$jour,$annee))>4) // du Vendredi au Samedi |
|
1363 | - $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-(date("w",mktime(12,0,0,$mois,$jour,$annee))-4)*24*60*60; |
|
1358 | + if (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) == 0) // Dimanche |
|
1359 | + $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) - 3 * 24 * 60 * 60; |
|
1360 | + else if (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) < 4) // du Lundi au Mercredi |
|
1361 | + $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) + (4 - date("w", mktime(12, 0, 0, $mois, $jour, $annee))) * 24 * 60 * 60; |
|
1362 | + else if (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) > 4) // du Vendredi au Samedi |
|
1363 | + $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) - (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) - 4) * 24 * 60 * 60; |
|
1364 | 1364 | else // Jeudi |
1365 | - $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee); |
|
1365 | + $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee); |
|
1366 | 1366 | |
1367 | 1367 | // Definition du premier Jeudi de l'annee |
1368 | - if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==0) // Dimanche |
|
1368 | + if (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) == 0) // Dimanche |
|
1369 | 1369 | { |
1370 | - $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+4*24*60*60; |
|
1370 | + $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)) + 4 * 24 * 60 * 60; |
|
1371 | 1371 | } |
1372 | - else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))<4) // du Lundi au Mercredi |
|
1372 | + else if (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) < 4) // du Lundi au Mercredi |
|
1373 | 1373 | { |
1374 | - $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+(4-date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine))))*24*60*60; |
|
1374 | + $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)) + (4 - date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)))) * 24 * 60 * 60; |
|
1375 | 1375 | } |
1376 | - else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))>4) // du Vendredi au Samedi |
|
1376 | + else if (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) > 4) // du Vendredi au Samedi |
|
1377 | 1377 | { |
1378 | - $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+(7-(date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))-4))*24*60*60; |
|
1378 | + $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)) + (7 - (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) - 4)) * 24 * 60 * 60; |
|
1379 | 1379 | } |
1380 | 1380 | else // Jeudi |
1381 | 1381 | { |
1382 | - $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine)); |
|
1382 | + $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)); |
|
1383 | 1383 | } |
1384 | 1384 | |
1385 | 1385 | // Definition du numero de semaine: nb de jours entre "premier Jeudi de l'annee" et "Jeudi de la semaine"; |
1386 | - $numeroSemaine = ( |
|
1386 | + $numeroSemaine = ( |
|
1387 | 1387 | ( |
1388 | - date("z",mktime(12,0,0,date("m",$jeudiSemaine),date("d",$jeudiSemaine),date("Y",$jeudiSemaine))) |
|
1388 | + date("z", mktime(12, 0, 0, date("m", $jeudiSemaine), date("d", $jeudiSemaine), date("Y", $jeudiSemaine))) |
|
1389 | 1389 | - |
1390 | - date("z",mktime(12,0,0,date("m",$premierJeudiAnnee),date("d",$premierJeudiAnnee),date("Y",$premierJeudiAnnee))) |
|
1390 | + date("z", mktime(12, 0, 0, date("m", $premierJeudiAnnee), date("d", $premierJeudiAnnee), date("Y", $premierJeudiAnnee))) |
|
1391 | 1391 | ) / 7 |
1392 | 1392 | ) + 1; |
1393 | 1393 | |
1394 | 1394 | // Cas particulier de la semaine 53 |
1395 | - if ($numeroSemaine==53) |
|
1395 | + if ($numeroSemaine == 53) |
|
1396 | 1396 | { |
1397 | 1397 | // Les annees qui commence un Jeudi et les annees bissextiles commencant un Mercredi en possede 53 |
1398 | - if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==4 || (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==3 && date("z",mktime(12,0,0,12,31,date("Y",$jeudiSemaine)))==365)) |
|
1398 | + if (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) == 4 || (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) == 3 && date("z", mktime(12, 0, 0, 12, 31, date("Y", $jeudiSemaine))) == 365)) |
|
1399 | 1399 | { |
1400 | 1400 | $numeroSemaine = 53; |
1401 | 1401 | } |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | |
1408 | 1408 | //echo $jour."-".$mois."-".$annee." (".date("d-m-Y",$premierJeudiAnnee)." - ".date("d-m-Y",$jeudiSemaine).") -> ".$numeroSemaine."<BR>"; |
1409 | 1409 | |
1410 | - return sprintf("%02d",$numeroSemaine); |
|
1410 | + return sprintf("%02d", $numeroSemaine); |
|
1411 | 1411 | } |
1412 | 1412 | |
1413 | 1413 | /** |
@@ -1418,26 +1418,26 @@ discard block |
||
1418 | 1418 | * @param int $to_unit Nouvelle unite en puissance de 10 |
1419 | 1419 | * @return float Masse convertie |
1420 | 1420 | */ |
1421 | -function weight_convert($weight,&$from_unit,$to_unit) |
|
1421 | +function weight_convert($weight, &$from_unit, $to_unit) |
|
1422 | 1422 | { |
1423 | 1423 | /* Pour convertire 320 gr en Kg appeler |
1424 | 1424 | * $f = -3 |
1425 | 1425 | * weigh_convert(320, $f, 0) retournera 0.32 |
1426 | 1426 | * |
1427 | 1427 | */ |
1428 | - while ($from_unit <> $to_unit) |
|
1428 | + while ($from_unit <> $to_unit) |
|
1429 | 1429 | { |
1430 | 1430 | if ($from_unit > $to_unit) |
1431 | 1431 | { |
1432 | 1432 | $weight = $weight * 10; |
1433 | 1433 | $from_unit = $from_unit - 1; |
1434 | - $weight = weight_convert($weight,$from_unit, $to_unit); |
|
1434 | + $weight = weight_convert($weight, $from_unit, $to_unit); |
|
1435 | 1435 | } |
1436 | 1436 | if ($from_unit < $to_unit) |
1437 | 1437 | { |
1438 | 1438 | $weight = $weight / 10; |
1439 | 1439 | $from_unit = $from_unit + 1; |
1440 | - $weight = weight_convert($weight,$from_unit, $to_unit); |
|
1440 | + $weight = weight_convert($weight, $from_unit, $to_unit); |
|
1441 | 1441 | } |
1442 | 1442 | } |
1443 | 1443 | |
@@ -1464,21 +1464,21 @@ discard block |
||
1464 | 1464 | |
1465 | 1465 | // We remove old parameters for all keys in $tab |
1466 | 1466 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param"; |
1467 | - $sql.= " WHERE fk_user = ".$user->id; |
|
1468 | - $sql.= " AND entity = ".$conf->entity; |
|
1469 | - $sql.= " AND param in ("; |
|
1470 | - $i=0; |
|
1467 | + $sql .= " WHERE fk_user = ".$user->id; |
|
1468 | + $sql .= " AND entity = ".$conf->entity; |
|
1469 | + $sql .= " AND param in ("; |
|
1470 | + $i = 0; |
|
1471 | 1471 | foreach ($tab as $key => $value) |
1472 | 1472 | { |
1473 | - if ($i > 0) $sql.=','; |
|
1474 | - $sql.="'".$db->escape($key)."'"; |
|
1473 | + if ($i > 0) $sql .= ','; |
|
1474 | + $sql .= "'".$db->escape($key)."'"; |
|
1475 | 1475 | $i++; |
1476 | 1476 | } |
1477 | - $sql.= ")"; |
|
1477 | + $sql .= ")"; |
|
1478 | 1478 | dol_syslog("functions2.lib::dol_set_user_param", LOG_DEBUG); |
1479 | 1479 | |
1480 | - $resql=$db->query($sql); |
|
1481 | - if (! $resql) |
|
1480 | + $resql = $db->query($sql); |
|
1481 | + if (!$resql) |
|
1482 | 1482 | { |
1483 | 1483 | dol_print_error($db); |
1484 | 1484 | $db->rollback(); |
@@ -1491,12 +1491,12 @@ discard block |
||
1491 | 1491 | if ($value) |
1492 | 1492 | { |
1493 | 1493 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_param(fk_user,entity,param,value)"; |
1494 | - $sql.= " VALUES (".$user->id.",".$conf->entity.","; |
|
1495 | - $sql.= " '".$db->escape($key)."','".$db->escape($value)."')"; |
|
1494 | + $sql .= " VALUES (".$user->id.",".$conf->entity.","; |
|
1495 | + $sql .= " '".$db->escape($key)."','".$db->escape($value)."')"; |
|
1496 | 1496 | |
1497 | 1497 | dol_syslog("functions2.lib::dol_set_user_param", LOG_DEBUG); |
1498 | - $result=$db->query($sql); |
|
1499 | - if (! $result) |
|
1498 | + $result = $db->query($sql); |
|
1499 | + if (!$result) |
|
1500 | 1500 | { |
1501 | 1501 | dol_print_error($db); |
1502 | 1502 | $db->rollback(); |
@@ -1522,7 +1522,7 @@ discard block |
||
1522 | 1522 | * @param Translate $langs Output language |
1523 | 1523 | * @return string Formated reduction |
1524 | 1524 | */ |
1525 | -function dol_print_reduction($reduction,$langs) |
|
1525 | +function dol_print_reduction($reduction, $langs) |
|
1526 | 1526 | { |
1527 | 1527 | $string = ''; |
1528 | 1528 | if ($reduction == 100) |
@@ -1531,7 +1531,7 @@ discard block |
||
1531 | 1531 | } |
1532 | 1532 | else |
1533 | 1533 | { |
1534 | - $string = vatrate($reduction,true); |
|
1534 | + $string = vatrate($reduction, true); |
|
1535 | 1535 | } |
1536 | 1536 | |
1537 | 1537 | return $string; |
@@ -1545,7 +1545,7 @@ discard block |
||
1545 | 1545 | */ |
1546 | 1546 | function version_os() |
1547 | 1547 | { |
1548 | - $osversion=php_uname(); |
|
1548 | + $osversion = php_uname(); |
|
1549 | 1549 | return $osversion; |
1550 | 1550 | } |
1551 | 1551 | |
@@ -1589,18 +1589,18 @@ discard block |
||
1589 | 1589 | * @param int $maxfilenamelength Max length of value to show |
1590 | 1590 | * @return mixed 0 if no module is activated, or array(key=>label). For modules that need directory scan, key is completed with ":filename". |
1591 | 1591 | */ |
1592 | -function getListOfModels($db,$type,$maxfilenamelength=0) |
|
1592 | +function getListOfModels($db, $type, $maxfilenamelength = 0) |
|
1593 | 1593 | { |
1594 | - global $conf,$langs; |
|
1595 | - $liste=array(); |
|
1596 | - $found=0; |
|
1597 | - $dirtoscan=''; |
|
1594 | + global $conf, $langs; |
|
1595 | + $liste = array(); |
|
1596 | + $found = 0; |
|
1597 | + $dirtoscan = ''; |
|
1598 | 1598 | |
1599 | 1599 | $sql = "SELECT nom as id, nom as lib, libelle as label, description as description"; |
1600 | - $sql.= " FROM ".MAIN_DB_PREFIX."document_model"; |
|
1601 | - $sql.= " WHERE type = '".$type."'"; |
|
1602 | - $sql.= " AND entity IN (0,".$conf->entity.")"; |
|
1603 | - $sql.= " ORDER BY description DESC"; |
|
1600 | + $sql .= " FROM ".MAIN_DB_PREFIX."document_model"; |
|
1601 | + $sql .= " WHERE type = '".$type."'"; |
|
1602 | + $sql .= " AND entity IN (0,".$conf->entity.")"; |
|
1603 | + $sql .= " ORDER BY description DESC"; |
|
1604 | 1604 | |
1605 | 1605 | dol_syslog('/core/lib/function2.lib.php::getListOfModels', LOG_DEBUG); |
1606 | 1606 | $resql = $db->query($sql); |
@@ -1610,48 +1610,48 @@ discard block |
||
1610 | 1610 | $i = 0; |
1611 | 1611 | while ($i < $num) |
1612 | 1612 | { |
1613 | - $found=1; |
|
1613 | + $found = 1; |
|
1614 | 1614 | |
1615 | 1615 | $obj = $db->fetch_object($resql); |
1616 | 1616 | |
1617 | 1617 | // If this generation module needs to scan a directory, then description field is filled |
1618 | 1618 | // with the constant that contains list of directories to scan (COMPANY_ADDON_PDF_ODT_PATH, ...). |
1619 | - if (! empty($obj->description)) // A list of directories to scan is defined |
|
1619 | + if (!empty($obj->description)) // A list of directories to scan is defined |
|
1620 | 1620 | { |
1621 | 1621 | include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
1622 | 1622 | |
1623 | - $const=$obj->description; |
|
1623 | + $const = $obj->description; |
|
1624 | 1624 | //irtoscan.=($dirtoscan?',':'').preg_replace('/[\r\n]+/',',',trim($conf->global->$const)); |
1625 | - $dirtoscan= preg_replace('/[\r\n]+/',',',trim($conf->global->$const)); |
|
1625 | + $dirtoscan = preg_replace('/[\r\n]+/', ',', trim($conf->global->$const)); |
|
1626 | 1626 | |
1627 | - $listoffiles=array(); |
|
1627 | + $listoffiles = array(); |
|
1628 | 1628 | |
1629 | 1629 | // Now we add models found in directories scanned |
1630 | - $listofdir=explode(',',$dirtoscan); |
|
1631 | - foreach($listofdir as $key=>$tmpdir) |
|
1630 | + $listofdir = explode(',', $dirtoscan); |
|
1631 | + foreach ($listofdir as $key=>$tmpdir) |
|
1632 | 1632 | { |
1633 | - $tmpdir=trim($tmpdir); |
|
1634 | - $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); |
|
1635 | - if (! $tmpdir) { unset($listofdir[$key]); continue; } |
|
1633 | + $tmpdir = trim($tmpdir); |
|
1634 | + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); |
|
1635 | + if (!$tmpdir) { unset($listofdir[$key]); continue; } |
|
1636 | 1636 | if (is_dir($tmpdir)) |
1637 | 1637 | { |
1638 | 1638 | // all type of template is allowed |
1639 | - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0); |
|
1640 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
1639 | + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0); |
|
1640 | + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); |
|
1641 | 1641 | } |
1642 | 1642 | } |
1643 | 1643 | |
1644 | 1644 | if (count($listoffiles)) |
1645 | 1645 | { |
1646 | - foreach($listoffiles as $record) |
|
1646 | + foreach ($listoffiles as $record) |
|
1647 | 1647 | { |
1648 | - $max=($maxfilenamelength?$maxfilenamelength:28); |
|
1649 | - $liste[$obj->id.':'.$record['fullname']]=dol_trunc($record['name'],$max,'middle'); |
|
1648 | + $max = ($maxfilenamelength ? $maxfilenamelength : 28); |
|
1649 | + $liste[$obj->id.':'.$record['fullname']] = dol_trunc($record['name'], $max, 'middle'); |
|
1650 | 1650 | } |
1651 | 1651 | } |
1652 | 1652 | else |
1653 | 1653 | { |
1654 | - $liste[0]=$obj->label.': '.$langs->trans("None"); |
|
1654 | + $liste[0] = $obj->label.': '.$langs->trans("None"); |
|
1655 | 1655 | } |
1656 | 1656 | } |
1657 | 1657 | else |
@@ -1660,14 +1660,14 @@ discard block |
||
1660 | 1660 | { |
1661 | 1661 | global $_Avery_Labels; |
1662 | 1662 | include_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; |
1663 | - foreach($_Avery_Labels as $key => $val) |
|
1663 | + foreach ($_Avery_Labels as $key => $val) |
|
1664 | 1664 | { |
1665 | - $liste[$obj->id.':'.$key]=($obj->label?$obj->label:$obj->lib).' '.$val['name']; |
|
1665 | + $liste[$obj->id.':'.$key] = ($obj->label ? $obj->label : $obj->lib).' '.$val['name']; |
|
1666 | 1666 | } |
1667 | 1667 | } |
1668 | 1668 | else // Common usage |
1669 | 1669 | { |
1670 | - $liste[$obj->id]=$obj->label?$obj->label:$obj->lib; |
|
1670 | + $liste[$obj->id] = $obj->label ? $obj->label : $obj->lib; |
|
1671 | 1671 | } |
1672 | 1672 | } |
1673 | 1673 | $i++; |
@@ -1696,10 +1696,10 @@ discard block |
||
1696 | 1696 | if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
1697 | 1697 | |
1698 | 1698 | // Then we test if it is a private range |
1699 | - if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) return 2; |
|
1699 | + if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) return 2; |
|
1700 | 1700 | |
1701 | 1701 | // Then we test if it is a reserved range |
1702 | - if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) return 0; |
|
1702 | + if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) return 0; |
|
1703 | 1703 | |
1704 | 1704 | return 1; |
1705 | 1705 | } |
@@ -1714,12 +1714,12 @@ discard block |
||
1714 | 1714 | * @param string $firstname Firstname |
1715 | 1715 | * @return string Login |
1716 | 1716 | */ |
1717 | -function dol_buildlogin($lastname,$firstname) |
|
1717 | +function dol_buildlogin($lastname, $firstname) |
|
1718 | 1718 | { |
1719 | - $login=strtolower(dol_string_unaccent($firstname)); |
|
1720 | - $login.=($login?'.':''); |
|
1721 | - $login.=strtolower(dol_string_unaccent($lastname)); |
|
1722 | - $login=dol_string_nospecial($login,''); // For special names |
|
1719 | + $login = strtolower(dol_string_unaccent($firstname)); |
|
1720 | + $login .= ($login ? '.' : ''); |
|
1721 | + $login .= strtolower(dol_string_unaccent($lastname)); |
|
1722 | + $login = dol_string_nospecial($login, ''); // For special names |
|
1723 | 1723 | return $login; |
1724 | 1724 | } |
1725 | 1725 | |
@@ -1732,18 +1732,18 @@ discard block |
||
1732 | 1732 | { |
1733 | 1733 | global $conf; |
1734 | 1734 | |
1735 | - $params=array(); |
|
1736 | - $proxyuse =(empty($conf->global->MAIN_PROXY_USE)?false:true); |
|
1737 | - $proxyhost=(empty($conf->global->MAIN_PROXY_USE)?false:$conf->global->MAIN_PROXY_HOST); |
|
1738 | - $proxyport=(empty($conf->global->MAIN_PROXY_USE)?false:$conf->global->MAIN_PROXY_PORT); |
|
1739 | - $proxyuser=(empty($conf->global->MAIN_PROXY_USE)?false:$conf->global->MAIN_PROXY_USER); |
|
1740 | - $proxypass=(empty($conf->global->MAIN_PROXY_USE)?false:$conf->global->MAIN_PROXY_PASS); |
|
1741 | - $timeout =(empty($conf->global->MAIN_USE_CONNECT_TIMEOUT)?10:$conf->global->MAIN_USE_CONNECT_TIMEOUT); // Connection timeout |
|
1742 | - $response_timeout=(empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT)?30:$conf->global->MAIN_USE_RESPONSE_TIMEOUT); // Response timeout |
|
1735 | + $params = array(); |
|
1736 | + $proxyuse = (empty($conf->global->MAIN_PROXY_USE) ?false:true); |
|
1737 | + $proxyhost = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_HOST); |
|
1738 | + $proxyport = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_PORT); |
|
1739 | + $proxyuser = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_USER); |
|
1740 | + $proxypass = (empty($conf->global->MAIN_PROXY_USE) ?false:$conf->global->MAIN_PROXY_PASS); |
|
1741 | + $timeout = (empty($conf->global->MAIN_USE_CONNECT_TIMEOUT) ? 10 : $conf->global->MAIN_USE_CONNECT_TIMEOUT); // Connection timeout |
|
1742 | + $response_timeout = (empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT) ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT); // Response timeout |
|
1743 | 1743 | //print extension_loaded('soap'); |
1744 | 1744 | if ($proxyuse) |
1745 | 1745 | { |
1746 | - $params=array('connection_timeout'=>$timeout, |
|
1746 | + $params = array('connection_timeout'=>$timeout, |
|
1747 | 1747 | 'response_timeout'=>$response_timeout, |
1748 | 1748 | 'proxy_use' => 1, |
1749 | 1749 | 'proxy_host' => $proxyhost, |
@@ -1755,7 +1755,7 @@ discard block |
||
1755 | 1755 | } |
1756 | 1756 | else |
1757 | 1757 | { |
1758 | - $params=array('connection_timeout'=>$timeout, |
|
1758 | + $params = array('connection_timeout'=>$timeout, |
|
1759 | 1759 | 'response_timeout'=>$response_timeout, |
1760 | 1760 | 'proxy_use' => 0, |
1761 | 1761 | 'proxy_host' => false, |
@@ -1778,15 +1778,15 @@ discard block |
||
1778 | 1778 | * @param string $option More options |
1779 | 1779 | * @return string URL of link to object id/type |
1780 | 1780 | */ |
1781 | -function dolGetElementUrl($objectid,$objecttype,$withpicto=0,$option='') |
|
1781 | +function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '') |
|
1782 | 1782 | { |
1783 | 1783 | global $db, $conf, $langs; |
1784 | 1784 | |
1785 | - $ret=''; |
|
1785 | + $ret = ''; |
|
1786 | 1786 | |
1787 | 1787 | // Parse element/subelement (ex: project_task) |
1788 | 1788 | $module = $element = $subelement = $objecttype; |
1789 | - if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs)) |
|
1789 | + if (preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs)) |
|
1790 | 1790 | { |
1791 | 1791 | $module = $element = $regs[1]; |
1792 | 1792 | $subelement = $regs[2]; |
@@ -1797,18 +1797,18 @@ discard block |
||
1797 | 1797 | // To work with non standard path |
1798 | 1798 | if ($objecttype == 'facture' || $objecttype == 'invoice') { |
1799 | 1799 | $classpath = 'compta/facture/class'; |
1800 | - $module='facture'; |
|
1801 | - $subelement='facture'; |
|
1800 | + $module = 'facture'; |
|
1801 | + $subelement = 'facture'; |
|
1802 | 1802 | } |
1803 | 1803 | if ($objecttype == 'commande' || $objecttype == 'order') { |
1804 | 1804 | $classpath = 'commande/class'; |
1805 | - $module='commande'; |
|
1806 | - $subelement='commande'; |
|
1805 | + $module = 'commande'; |
|
1806 | + $subelement = 'commande'; |
|
1807 | 1807 | } |
1808 | - if ($objecttype == 'propal') { |
|
1808 | + if ($objecttype == 'propal') { |
|
1809 | 1809 | $classpath = 'comm/propal/class'; |
1810 | 1810 | } |
1811 | - if ($objecttype == 'supplier_proposal') { |
|
1811 | + if ($objecttype == 'supplier_proposal') { |
|
1812 | 1812 | $classpath = 'supplier_proposal/class'; |
1813 | 1813 | } |
1814 | 1814 | if ($objecttype == 'shipping') { |
@@ -1823,33 +1823,33 @@ discard block |
||
1823 | 1823 | } |
1824 | 1824 | if ($objecttype == 'contract') { |
1825 | 1825 | $classpath = 'contrat/class'; |
1826 | - $module='contrat'; |
|
1827 | - $subelement='contrat'; |
|
1826 | + $module = 'contrat'; |
|
1827 | + $subelement = 'contrat'; |
|
1828 | 1828 | } |
1829 | 1829 | if ($objecttype == 'member') { |
1830 | 1830 | $classpath = 'adherents/class'; |
1831 | - $module='adherent'; |
|
1832 | - $subelement='adherent'; |
|
1831 | + $module = 'adherent'; |
|
1832 | + $subelement = 'adherent'; |
|
1833 | 1833 | } |
1834 | 1834 | if ($objecttype == 'cabinetmed_cons') { |
1835 | 1835 | $classpath = 'cabinetmed/class'; |
1836 | - $module='cabinetmed'; |
|
1837 | - $subelement='cabinetmedcons'; |
|
1836 | + $module = 'cabinetmed'; |
|
1837 | + $subelement = 'cabinetmedcons'; |
|
1838 | 1838 | } |
1839 | 1839 | if ($objecttype == 'fichinter') { |
1840 | 1840 | $classpath = 'fichinter/class'; |
1841 | - $module='ficheinter'; |
|
1842 | - $subelement='fichinter'; |
|
1841 | + $module = 'ficheinter'; |
|
1842 | + $subelement = 'fichinter'; |
|
1843 | 1843 | } |
1844 | 1844 | if ($objecttype == 'task') { |
1845 | 1845 | $classpath = 'projet/class'; |
1846 | - $module='projet'; |
|
1847 | - $subelement='task'; |
|
1846 | + $module = 'projet'; |
|
1847 | + $subelement = 'task'; |
|
1848 | 1848 | } |
1849 | 1849 | if ($objecttype == 'stock') { |
1850 | 1850 | $classpath = 'product/stock/class'; |
1851 | - $module='stock'; |
|
1852 | - $subelement='stock'; |
|
1851 | + $module = 'stock'; |
|
1852 | + $subelement = 'stock'; |
|
1853 | 1853 | } |
1854 | 1854 | |
1855 | 1855 | //print "objecttype=".$objecttype." module=".$module." subelement=".$subelement; |
@@ -1857,34 +1857,34 @@ discard block |
||
1857 | 1857 | $classfile = strtolower($subelement); $classname = ucfirst($subelement); |
1858 | 1858 | if ($objecttype == 'invoice_supplier') { |
1859 | 1859 | $classfile = 'fournisseur.facture'; |
1860 | - $classname='FactureFournisseur'; |
|
1860 | + $classname = 'FactureFournisseur'; |
|
1861 | 1861 | $classpath = 'fourn/class'; |
1862 | - $module='fournisseur'; |
|
1862 | + $module = 'fournisseur'; |
|
1863 | 1863 | } |
1864 | - elseif ($objecttype == 'order_supplier') { |
|
1864 | + elseif ($objecttype == 'order_supplier') { |
|
1865 | 1865 | $classfile = 'fournisseur.commande'; |
1866 | - $classname='CommandeFournisseur'; |
|
1866 | + $classname = 'CommandeFournisseur'; |
|
1867 | 1867 | $classpath = 'fourn/class'; |
1868 | - $module='fournisseur'; |
|
1868 | + $module = 'fournisseur'; |
|
1869 | 1869 | } |
1870 | - elseif ($objecttype == 'stock') { |
|
1870 | + elseif ($objecttype == 'stock') { |
|
1871 | 1871 | $classpath = 'product/stock/class'; |
1872 | - $classfile='entrepot'; |
|
1873 | - $classname='Entrepot'; |
|
1872 | + $classfile = 'entrepot'; |
|
1873 | + $classname = 'Entrepot'; |
|
1874 | 1874 | } |
1875 | - if (! empty($conf->$module->enabled)) |
|
1875 | + if (!empty($conf->$module->enabled)) |
|
1876 | 1876 | { |
1877 | - $res=dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); |
|
1877 | + $res = dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); |
|
1878 | 1878 | if ($res) |
1879 | 1879 | { |
1880 | 1880 | if (class_exists($classname)) |
1881 | 1881 | { |
1882 | 1882 | $object = new $classname($db); |
1883 | - $res=$object->fetch($objectid); |
|
1883 | + $res = $object->fetch($objectid); |
|
1884 | 1884 | if ($res > 0) { |
1885 | - $ret=$object->getNomUrl($withpicto,$option); |
|
1886 | - } elseif($res==0) { |
|
1887 | - $ret=$langs->trans('Deleted'); |
|
1885 | + $ret = $object->getNomUrl($withpicto, $option); |
|
1886 | + } elseif ($res == 0) { |
|
1887 | + $ret = $langs->trans('Deleted'); |
|
1888 | 1888 | } |
1889 | 1889 | unset($object); |
1890 | 1890 | } |
@@ -1905,12 +1905,12 @@ discard block |
||
1905 | 1905 | */ |
1906 | 1906 | function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) |
1907 | 1907 | { |
1908 | - $totalnb=0; |
|
1909 | - $listofid=array(); |
|
1910 | - $listofparentid=array(); |
|
1908 | + $totalnb = 0; |
|
1909 | + $listofid = array(); |
|
1910 | + $listofparentid = array(); |
|
1911 | 1911 | |
1912 | 1912 | // Get list of all id in array listofid and all parents in array listofparentid |
1913 | - $sql='SELECT rowid, '.$fieldfkparent.' as parent_id FROM '.MAIN_DB_PREFIX.$tabletocleantree; |
|
1913 | + $sql = 'SELECT rowid, '.$fieldfkparent.' as parent_id FROM '.MAIN_DB_PREFIX.$tabletocleantree; |
|
1914 | 1914 | $resql = $db->query($sql); |
1915 | 1915 | if ($resql) |
1916 | 1916 | { |
@@ -1919,8 +1919,8 @@ discard block |
||
1919 | 1919 | while ($i < $num) |
1920 | 1920 | { |
1921 | 1921 | $obj = $db->fetch_object($resql); |
1922 | - $listofid[]=$obj->rowid; |
|
1923 | - if ($obj->parent_id > 0) $listofparentid[$obj->rowid]=$obj->parent_id; |
|
1922 | + $listofid[] = $obj->rowid; |
|
1923 | + if ($obj->parent_id > 0) $listofparentid[$obj->rowid] = $obj->parent_id; |
|
1924 | 1924 | $i++; |
1925 | 1925 | } |
1926 | 1926 | } |
@@ -1934,78 +1934,78 @@ discard block |
||
1934 | 1934 | print 'Code requested to clean tree (may be to solve data corruption), so we check/clean orphelins and loops.'."<br>\n"; |
1935 | 1935 | |
1936 | 1936 | // Check loops on each other |
1937 | - $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree." SET ".$fieldfkparent." = 0 WHERE ".$fieldfkparent." = rowid"; // So we update only records linked to themself |
|
1937 | + $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree." SET ".$fieldfkparent." = 0 WHERE ".$fieldfkparent." = rowid"; // So we update only records linked to themself |
|
1938 | 1938 | $resql = $db->query($sql); |
1939 | 1939 | if ($resql) |
1940 | 1940 | { |
1941 | - $nb=$db->affected_rows($sql); |
|
1941 | + $nb = $db->affected_rows($sql); |
|
1942 | 1942 | if ($nb > 0) |
1943 | 1943 | { |
1944 | 1944 | print '<br>Some record that were parent of themself were cleaned.'; |
1945 | 1945 | } |
1946 | 1946 | |
1947 | - $totalnb+=$nb; |
|
1947 | + $totalnb += $nb; |
|
1948 | 1948 | } |
1949 | 1949 | //else dol_print_error($db); |
1950 | 1950 | |
1951 | 1951 | // Check other loops |
1952 | - $listofidtoclean=array(); |
|
1953 | - foreach($listofparentid as $id => $pid) |
|
1952 | + $listofidtoclean = array(); |
|
1953 | + foreach ($listofparentid as $id => $pid) |
|
1954 | 1954 | { |
1955 | 1955 | // Check depth |
1956 | 1956 | //print 'Analyse record id='.$id.' with parent '.$pid.'<br>'; |
1957 | 1957 | |
1958 | - $cursor=$id; $arrayidparsed=array(); // We start from child $id |
|
1958 | + $cursor = $id; $arrayidparsed = array(); // We start from child $id |
|
1959 | 1959 | while ($cursor > 0) |
1960 | 1960 | { |
1961 | - $arrayidparsed[$cursor]=1; |
|
1961 | + $arrayidparsed[$cursor] = 1; |
|
1962 | 1962 | if ($arrayidparsed[$listofparentid[$cursor]]) // We detect a loop. A record with a parent that was already into child |
1963 | 1963 | { |
1964 | 1964 | print 'Found a loop between id '.$id.' - '.$cursor.'<br>'; |
1965 | 1965 | unset($arrayidparsed); |
1966 | - $listofidtoclean[$cursor]=$id; |
|
1966 | + $listofidtoclean[$cursor] = $id; |
|
1967 | 1967 | break; |
1968 | 1968 | } |
1969 | - $cursor=$listofparentid[$cursor]; |
|
1969 | + $cursor = $listofparentid[$cursor]; |
|
1970 | 1970 | } |
1971 | 1971 | |
1972 | 1972 | if (count($listofidtoclean)) break; |
1973 | 1973 | } |
1974 | 1974 | |
1975 | 1975 | $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree; |
1976 | - $sql.= " SET ".$fieldfkparent." = 0"; |
|
1977 | - $sql.= " WHERE rowid IN (".join(',',$listofidtoclean).")"; // So we update only records detected wrong |
|
1976 | + $sql .= " SET ".$fieldfkparent." = 0"; |
|
1977 | + $sql .= " WHERE rowid IN (".join(',', $listofidtoclean).")"; // So we update only records detected wrong |
|
1978 | 1978 | $resql = $db->query($sql); |
1979 | 1979 | if ($resql) |
1980 | 1980 | { |
1981 | - $nb=$db->affected_rows($sql); |
|
1981 | + $nb = $db->affected_rows($sql); |
|
1982 | 1982 | if ($nb > 0) |
1983 | 1983 | { |
1984 | 1984 | // Removed orphelins records |
1985 | 1985 | print '<br>Some records were detected to have parent that is a child, we set them as root record for id: '; |
1986 | - print join(',',$listofidtoclean); |
|
1986 | + print join(',', $listofidtoclean); |
|
1987 | 1987 | } |
1988 | 1988 | |
1989 | - $totalnb+=$nb; |
|
1989 | + $totalnb += $nb; |
|
1990 | 1990 | } |
1991 | 1991 | //else dol_print_error($db); |
1992 | 1992 | |
1993 | 1993 | // Check and clean orphelins |
1994 | 1994 | $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree; |
1995 | - $sql.= " SET ".$fieldfkparent." = 0"; |
|
1996 | - $sql.= " WHERE ".$fieldfkparent." NOT IN (".join(',',$listofid).")"; // So we update only records linked to a non existing parent |
|
1995 | + $sql .= " SET ".$fieldfkparent." = 0"; |
|
1996 | + $sql .= " WHERE ".$fieldfkparent." NOT IN (".join(',', $listofid).")"; // So we update only records linked to a non existing parent |
|
1997 | 1997 | $resql = $db->query($sql); |
1998 | 1998 | if ($resql) |
1999 | 1999 | { |
2000 | - $nb=$db->affected_rows($sql); |
|
2000 | + $nb = $db->affected_rows($sql); |
|
2001 | 2001 | if ($nb > 0) |
2002 | 2002 | { |
2003 | 2003 | // Removed orphelins records |
2004 | 2004 | print '<br>Some orphelins were found and modified to be parent so records are visible again for id: '; |
2005 | - print join(',',$listofid); |
|
2005 | + print join(',', $listofid); |
|
2006 | 2006 | } |
2007 | 2007 | |
2008 | - $totalnb+=$nb; |
|
2008 | + $totalnb += $nb; |
|
2009 | 2009 | } |
2010 | 2010 | //else dol_print_error($db); |
2011 | 2011 | |
@@ -2026,21 +2026,21 @@ discard block |
||
2026 | 2026 | $module = $element = $subelement = $element_type; |
2027 | 2027 | |
2028 | 2028 | // If we ask an resource form external module (instead of default path) |
2029 | - if (preg_match('/^([^@]+)@([^@]+)$/i',$element_type,$regs)) |
|
2029 | + if (preg_match('/^([^@]+)@([^@]+)$/i', $element_type, $regs)) |
|
2030 | 2030 | { |
2031 | 2031 | $element = $subelement = $regs[1]; |
2032 | 2032 | $module = $regs[2]; |
2033 | 2033 | } |
2034 | 2034 | |
2035 | 2035 | //print '<br>1. element : '.$element.' - module : '.$module .'<br>'; |
2036 | - if ( preg_match('/^([^_]+)_([^_]+)/i',$element,$regs)) |
|
2036 | + if (preg_match('/^([^_]+)_([^_]+)/i', $element, $regs)) |
|
2037 | 2037 | { |
2038 | 2038 | $module = $element = $regs[1]; |
2039 | 2039 | $subelement = $regs[2]; |
2040 | 2040 | } |
2041 | 2041 | |
2042 | 2042 | // For compat |
2043 | - if($element_type == "action") { |
|
2043 | + if ($element_type == "action") { |
|
2044 | 2044 | $classpath = 'comm/action/class'; |
2045 | 2045 | $subelement = 'Actioncomm'; |
2046 | 2046 | $module = 'agenda'; |
@@ -2049,18 +2049,18 @@ discard block |
||
2049 | 2049 | // To work with non standard path |
2050 | 2050 | if ($element_type == 'facture' || $element_type == 'invoice') { |
2051 | 2051 | $classpath = 'compta/facture/class'; |
2052 | - $module='facture'; |
|
2053 | - $subelement='facture'; |
|
2052 | + $module = 'facture'; |
|
2053 | + $subelement = 'facture'; |
|
2054 | 2054 | } |
2055 | 2055 | if ($element_type == 'commande' || $element_type == 'order') { |
2056 | 2056 | $classpath = 'commande/class'; |
2057 | - $module='commande'; |
|
2058 | - $subelement='commande'; |
|
2057 | + $module = 'commande'; |
|
2058 | + $subelement = 'commande'; |
|
2059 | 2059 | } |
2060 | - if ($element_type == 'propal') { |
|
2060 | + if ($element_type == 'propal') { |
|
2061 | 2061 | $classpath = 'comm/propal/class'; |
2062 | 2062 | } |
2063 | - if ($element_type == 'supplier_proposal') { |
|
2063 | + if ($element_type == 'supplier_proposal') { |
|
2064 | 2064 | $classpath = 'supplier_proposal/class'; |
2065 | 2065 | } |
2066 | 2066 | if ($element_type == 'shipping') { |
@@ -2075,45 +2075,45 @@ discard block |
||
2075 | 2075 | } |
2076 | 2076 | if ($element_type == 'contract') { |
2077 | 2077 | $classpath = 'contrat/class'; |
2078 | - $module='contrat'; |
|
2079 | - $subelement='contrat'; |
|
2078 | + $module = 'contrat'; |
|
2079 | + $subelement = 'contrat'; |
|
2080 | 2080 | } |
2081 | 2081 | if ($element_type == 'member') { |
2082 | 2082 | $classpath = 'adherents/class'; |
2083 | - $module='adherent'; |
|
2084 | - $subelement='adherent'; |
|
2083 | + $module = 'adherent'; |
|
2084 | + $subelement = 'adherent'; |
|
2085 | 2085 | } |
2086 | 2086 | if ($element_type == 'cabinetmed_cons') { |
2087 | 2087 | $classpath = 'cabinetmed/class'; |
2088 | - $module='cabinetmed'; |
|
2089 | - $subelement='cabinetmedcons'; |
|
2088 | + $module = 'cabinetmed'; |
|
2089 | + $subelement = 'cabinetmedcons'; |
|
2090 | 2090 | } |
2091 | 2091 | if ($element_type == 'fichinter') { |
2092 | 2092 | $classpath = 'fichinter/class'; |
2093 | - $module='ficheinter'; |
|
2094 | - $subelement='fichinter'; |
|
2093 | + $module = 'ficheinter'; |
|
2094 | + $subelement = 'fichinter'; |
|
2095 | 2095 | } |
2096 | 2096 | if ($element_type == 'dolresource' || $element_type == 'resource') { |
2097 | 2097 | $classpath = 'resource/class'; |
2098 | - $module='resource'; |
|
2099 | - $subelement='dolresource'; |
|
2098 | + $module = 'resource'; |
|
2099 | + $subelement = 'dolresource'; |
|
2100 | 2100 | } |
2101 | 2101 | if ($element_type == 'propaldet') { |
2102 | 2102 | $classpath = 'comm/propal/class'; |
2103 | - $module='propal'; |
|
2104 | - $subelement='propaleligne'; |
|
2103 | + $module = 'propal'; |
|
2104 | + $subelement = 'propaleligne'; |
|
2105 | 2105 | } |
2106 | - if ($element_type == 'order_supplier') { |
|
2106 | + if ($element_type == 'order_supplier') { |
|
2107 | 2107 | $classpath = 'fourn/class'; |
2108 | - $module='fournisseur'; |
|
2109 | - $subelement='commandefournisseur'; |
|
2110 | - $classfile='fournisseur.commande'; |
|
2108 | + $module = 'fournisseur'; |
|
2109 | + $subelement = 'commandefournisseur'; |
|
2110 | + $classfile = 'fournisseur.commande'; |
|
2111 | 2111 | } |
2112 | - if ($element_type == 'invoice_supplier') { |
|
2112 | + if ($element_type == 'invoice_supplier') { |
|
2113 | 2113 | $classpath = 'fourn/class'; |
2114 | - $module='fournisseur'; |
|
2115 | - $subelement='facturefournisseur'; |
|
2116 | - $classfile='fournisseur.facture'; |
|
2114 | + $module = 'fournisseur'; |
|
2115 | + $subelement = 'facturefournisseur'; |
|
2116 | + $classfile = 'fournisseur.facture'; |
|
2117 | 2117 | } |
2118 | 2118 | |
2119 | 2119 | if (!isset($classfile)) $classfile = strtolower($subelement); |
@@ -2140,10 +2140,10 @@ discard block |
||
2140 | 2140 | * @param ref $element_ref Element ref (Use this if element_id but not both) |
2141 | 2141 | * @return int|object object || 0 || -1 if error |
2142 | 2142 | */ |
2143 | -function fetchObjectByElement($element_id, $element_type, $element_ref='') |
|
2143 | +function fetchObjectByElement($element_id, $element_type, $element_ref = '') |
|
2144 | 2144 | { |
2145 | 2145 | global $conf; |
2146 | - global $db,$conf; |
|
2146 | + global $db, $conf; |
|
2147 | 2147 | |
2148 | 2148 | $element_prop = getElementProperties($element_type); |
2149 | 2149 | if (is_array($element_prop) && $conf->{$element_prop['module']}->enabled) |
@@ -2170,11 +2170,11 @@ discard block |
||
2170 | 2170 | * @return string RGB hex value (without # before). For example: 'FF00FF', '01FF02' |
2171 | 2171 | * @see colorStringToArray |
2172 | 2172 | */ |
2173 | -function colorArrayToHex($arraycolor,$colorifnotfound='888888') |
|
2173 | +function colorArrayToHex($arraycolor, $colorifnotfound = '888888') |
|
2174 | 2174 | { |
2175 | - if (! is_array($arraycolor)) return $colorifnotfound; |
|
2175 | + if (!is_array($arraycolor)) return $colorifnotfound; |
|
2176 | 2176 | if (empty($arraycolor)) return $colorifnotfound; |
2177 | - return sprintf("%02s",dechex($arraycolor[0])).sprintf("%02s",dechex($arraycolor[1])).sprintf("%02s",dechex($arraycolor[2])); |
|
2177 | + return sprintf("%02s", dechex($arraycolor[0])).sprintf("%02s", dechex($arraycolor[1])).sprintf("%02s", dechex($arraycolor[2])); |
|
2178 | 2178 | } |
2179 | 2179 | |
2180 | 2180 | /** |
@@ -2187,17 +2187,17 @@ discard block |
||
2187 | 2187 | * @return string RGB hex value (without # before). For example: FF00FF |
2188 | 2188 | * @see colorArrayToHex |
2189 | 2189 | */ |
2190 | -function colorStringToArray($stringcolor,$colorifnotfound=array(88,88,88)) |
|
2190 | +function colorStringToArray($stringcolor, $colorifnotfound = array(88, 88, 88)) |
|
2191 | 2191 | { |
2192 | - if (is_array($stringcolor)) return $stringcolor; // If already into correct output format, we return as is |
|
2193 | - $tmp=preg_match('/^#?([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])$/',$stringcolor,$reg); |
|
2194 | - if (! $tmp) |
|
2192 | + if (is_array($stringcolor)) return $stringcolor; // If already into correct output format, we return as is |
|
2193 | + $tmp = preg_match('/^#?([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])$/', $stringcolor, $reg); |
|
2194 | + if (!$tmp) |
|
2195 | 2195 | { |
2196 | - $tmp=explode(',',$stringcolor); |
|
2196 | + $tmp = explode(',', $stringcolor); |
|
2197 | 2197 | if (count($tmp) < 3) return $colorifnotfound; |
2198 | 2198 | return $tmp; |
2199 | 2199 | } |
2200 | - return array(hexdec($reg[1]),hexdec($reg[2]),hexdec($reg[3])); |
|
2200 | + return array(hexdec($reg[1]), hexdec($reg[2]), hexdec($reg[3])); |
|
2201 | 2201 | } |
2202 | 2202 | |
2203 | 2203 | /** |
@@ -2217,8 +2217,8 @@ discard block |
||
2217 | 2217 | foreach ($input as $key => $values) { |
2218 | 2218 | $append = array(); |
2219 | 2219 | |
2220 | - foreach($result as $product) { |
|
2221 | - foreach($values as $item) { |
|
2220 | + foreach ($result as $product) { |
|
2221 | + foreach ($values as $item) { |
|
2222 | 2222 | $product[$key] = $item; |
2223 | 2223 | $append[] = $product; |
2224 | 2224 | } |
@@ -2239,8 +2239,8 @@ discard block |
||
2239 | 2239 | */ |
2240 | 2240 | function getModuleDirForApiClass($module) |
2241 | 2241 | { |
2242 | - $moduledirforclass=$module; |
|
2243 | - if ($moduledirforclass != 'api') $moduledirforclass = preg_replace('/api$/i','',$moduledirforclass); |
|
2242 | + $moduledirforclass = $module; |
|
2243 | + if ($moduledirforclass != 'api') $moduledirforclass = preg_replace('/api$/i', '', $moduledirforclass); |
|
2244 | 2244 | |
2245 | 2245 | if ($module == 'contracts') { |
2246 | 2246 | $moduledirforclass = 'contrat'; |
@@ -2316,9 +2316,9 @@ discard block |
||
2316 | 2316 | * @param $max int Between 0 and 255 |
2317 | 2317 | * @return String |
2318 | 2318 | */ |
2319 | -function random_color_part($min=0,$max=255) |
|
2319 | +function random_color_part($min = 0, $max = 255) |
|
2320 | 2320 | { |
2321 | - return str_pad( dechex( mt_rand( $min, $max) ), 2, '0', STR_PAD_LEFT); |
|
2321 | + return str_pad(dechex(mt_rand($min, $max)), 2, '0', STR_PAD_LEFT); |
|
2322 | 2322 | } |
2323 | 2323 | |
2324 | 2324 | /* |
@@ -2328,7 +2328,7 @@ discard block |
||
2328 | 2328 | * @param $max int Between 0 and 255 |
2329 | 2329 | * @return String |
2330 | 2330 | */ |
2331 | -function random_color($min=0, $max=255) |
|
2331 | +function random_color($min = 0, $max = 255) |
|
2332 | 2332 | { |
2333 | - return random_color_part($min, $max) . random_color_part($min, $max) . random_color_part($min, $max); |
|
2333 | + return random_color_part($min, $max).random_color_part($min, $max).random_color_part($min, $max); |
|
2334 | 2334 | } |
@@ -55,8 +55,7 @@ discard block |
||
55 | 55 | $entity = "&#". $unicode . ';'; |
56 | 56 | $decodedStr .= utf8_encode($entity); |
57 | 57 | $pos += 4; |
58 | - } |
|
59 | - else { |
|
58 | + } else { |
|
60 | 59 | // we have an escaped ascii character |
61 | 60 | $hexVal = substr($source, $pos, 2); |
62 | 61 | $decodedStr .= chr(hexdec($hexVal)); |
@@ -97,7 +96,10 @@ discard block |
||
97 | 96 | { |
98 | 97 | while (($file = readdir($handle))!==false) |
99 | 98 | { |
100 | - if (preg_match('/disabled/',$file)) continue; // We discard module if it contains disabled into name. |
|
99 | + if (preg_match('/disabled/',$file)) { |
|
100 | + continue; |
|
101 | + } |
|
102 | + // We discard module if it contains disabled into name. |
|
101 | 103 | |
102 | 104 | if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes') |
103 | 105 | { |
@@ -129,8 +131,14 @@ discard block |
||
129 | 131 | $outputlangs=$langs; |
130 | 132 | } |
131 | 133 | |
132 | - if ($outputlangs->defaultlang == 'ca_CA') $selected='CAP4'; // Canada |
|
133 | - if ($outputlangs->defaultlang == 'en_US') $selected='USLetter'; // US |
|
134 | + if ($outputlangs->defaultlang == 'ca_CA') { |
|
135 | + $selected='CAP4'; |
|
136 | + } |
|
137 | + // Canada |
|
138 | + if ($outputlangs->defaultlang == 'en_US') { |
|
139 | + $selected='USLetter'; |
|
140 | + } |
|
141 | + // US |
|
134 | 142 | return $selected; |
135 | 143 | } |
136 | 144 | |
@@ -155,29 +163,42 @@ discard block |
||
155 | 163 | { |
156 | 164 | $content=file_get_contents($formfile); |
157 | 165 | $isutf8=utf8_check($content); |
158 | - if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') print utf8_encode($content); |
|
159 | - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') print utf8_decode($content); |
|
160 | - else print $content; |
|
166 | + if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') { |
|
167 | + print utf8_encode($content); |
|
168 | + } elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') { |
|
169 | + print utf8_decode($content); |
|
170 | + } else { |
|
171 | + print $content; |
|
172 | + } |
|
161 | 173 | return true; |
174 | + } else { |
|
175 | + dol_syslog('functions2::dol_print_file not found', LOG_DEBUG); |
|
162 | 176 | } |
163 | - else dol_syslog('functions2::dol_print_file not found', LOG_DEBUG); |
|
164 | 177 | |
165 | 178 | if ($searchalt) { |
166 | 179 | // Test si fichier dans repertoire de la langue alternative |
167 | - if ($langs->defaultlang != "en_US") $formfilealt = $searchdir."/langs/en_US/".$filename; |
|
168 | - else $formfilealt = $searchdir."/langs/fr_FR/".$filename; |
|
180 | + if ($langs->defaultlang != "en_US") { |
|
181 | + $formfilealt = $searchdir."/langs/en_US/".$filename; |
|
182 | + } else { |
|
183 | + $formfilealt = $searchdir."/langs/fr_FR/".$filename; |
|
184 | + } |
|
169 | 185 | dol_syslog('functions2::dol_print_file search alt file '.$formfilealt, LOG_DEBUG); |
170 | 186 | //print 'getcwd='.getcwd().' htmlfilealt='.$formfilealt.' X '.file_exists(getcwd().'/'.$formfilealt); |
171 | 187 | if (is_readable($formfilealt)) |
172 | 188 | { |
173 | 189 | $content=file_get_contents($formfilealt); |
174 | 190 | $isutf8=utf8_check($content); |
175 | - if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') print utf8_encode($content); |
|
176 | - elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') print utf8_decode($content); |
|
177 | - else print $content; |
|
191 | + if (! $isutf8 && $conf->file->character_set_client == 'UTF-8') { |
|
192 | + print utf8_encode($content); |
|
193 | + } elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') { |
|
194 | + print utf8_decode($content); |
|
195 | + } else { |
|
196 | + print $content; |
|
197 | + } |
|
178 | 198 | return true; |
199 | + } else { |
|
200 | + dol_syslog('functions2::dol_print_file not found', LOG_DEBUG); |
|
179 | 201 | } |
180 | - else dol_syslog('functions2::dol_print_file not found', LOG_DEBUG); |
|
181 | 202 | } |
182 | 203 | } |
183 | 204 | |
@@ -207,279 +228,460 @@ discard block |
||
207 | 228 | $deltadateforuser=round($deltadateforclient-$deltadateforserver); |
208 | 229 | //print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser; |
209 | 230 | |
210 | - if ($usetable) print '<table class="border centpercent">'; |
|
231 | + if ($usetable) { |
|
232 | + print '<table class="border centpercent">'; |
|
233 | + } |
|
211 | 234 | |
212 | 235 | // Import key |
213 | 236 | if (! empty($object->import_key)) |
214 | 237 | { |
215 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
238 | + if ($usetable) { |
|
239 | + print '<tr><td class="titlefield">'; |
|
240 | + } |
|
216 | 241 | print $langs->trans("ImportedWithSet"); |
217 | - if ($usetable) print '</td><td>'; |
|
218 | - else print ': '; |
|
242 | + if ($usetable) { |
|
243 | + print '</td><td>'; |
|
244 | + } else { |
|
245 | + print ': '; |
|
246 | + } |
|
219 | 247 | print $object->import_key; |
220 | - if ($usetable) print '</td></tr>'; |
|
221 | - else print '<br>'; |
|
248 | + if ($usetable) { |
|
249 | + print '</td></tr>'; |
|
250 | + } else { |
|
251 | + print '<br>'; |
|
252 | + } |
|
222 | 253 | } |
223 | 254 | |
224 | 255 | // User creation (old method using already loaded object and not id is kept for backward compatibility) |
225 | 256 | if (! empty($object->user_creation) || ! empty($object->user_creation_id)) |
226 | 257 | { |
227 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
258 | + if ($usetable) { |
|
259 | + print '<tr><td class="titlefield">'; |
|
260 | + } |
|
228 | 261 | print $langs->trans("CreatedBy"); |
229 | - if ($usetable) print '</td><td>'; |
|
230 | - else print ': '; |
|
262 | + if ($usetable) { |
|
263 | + print '</td><td>'; |
|
264 | + } else { |
|
265 | + print ': '; |
|
266 | + } |
|
231 | 267 | if (is_object($object->user_creation)) |
232 | 268 | { |
233 | - if ($object->user_creation->id) print $object->user_creation->getNomUrl(1, '', 0, 0, 0); |
|
234 | - else print $langs->trans("Unknown"); |
|
235 | - } |
|
236 | - else |
|
269 | + if ($object->user_creation->id) { |
|
270 | + print $object->user_creation->getNomUrl(1, '', 0, 0, 0); |
|
271 | + } else { |
|
272 | + print $langs->trans("Unknown"); |
|
273 | + } |
|
274 | + } else |
|
237 | 275 | { |
238 | 276 | $userstatic=new User($db); |
239 | 277 | $userstatic->fetch($object->user_creation_id ? $object->user_creation_id : $object->user_creation); |
240 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
241 | - else print $langs->trans("Unknown"); |
|
278 | + if ($userstatic->id) { |
|
279 | + print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
280 | + } else { |
|
281 | + print $langs->trans("Unknown"); |
|
282 | + } |
|
283 | + } |
|
284 | + if ($usetable) { |
|
285 | + print '</td></tr>'; |
|
286 | + } else { |
|
287 | + print '<br>'; |
|
242 | 288 | } |
243 | - if ($usetable) print '</td></tr>'; |
|
244 | - else print '<br>'; |
|
245 | 289 | } |
246 | 290 | |
247 | 291 | // Date creation |
248 | 292 | if (! empty($object->date_creation)) |
249 | 293 | { |
250 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
294 | + if ($usetable) { |
|
295 | + print '<tr><td class="titlefield">'; |
|
296 | + } |
|
251 | 297 | print $langs->trans("DateCreation"); |
252 | - if ($usetable) print '</td><td>'; |
|
253 | - else print ': '; |
|
298 | + if ($usetable) { |
|
299 | + print '</td><td>'; |
|
300 | + } else { |
|
301 | + print ': '; |
|
302 | + } |
|
254 | 303 | print dol_print_date($object->date_creation, 'dayhour'); |
255 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_creation+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
256 | - if ($usetable) print '</td></tr>'; |
|
257 | - else print '<br>'; |
|
304 | + if ($deltadateforuser) { |
|
305 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_creation+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
306 | + } |
|
307 | + if ($usetable) { |
|
308 | + print '</td></tr>'; |
|
309 | + } else { |
|
310 | + print '<br>'; |
|
311 | + } |
|
258 | 312 | } |
259 | 313 | |
260 | 314 | // User change (old method using already loaded object and not id is kept for backward compatibility) |
261 | 315 | if (! empty($object->user_modification) || ! empty($object->user_modification_id)) |
262 | 316 | { |
263 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
317 | + if ($usetable) { |
|
318 | + print '<tr><td class="titlefield">'; |
|
319 | + } |
|
264 | 320 | print $langs->trans("ModifiedBy"); |
265 | - if ($usetable) print '</td><td>'; |
|
266 | - else print ': '; |
|
321 | + if ($usetable) { |
|
322 | + print '</td><td>'; |
|
323 | + } else { |
|
324 | + print ': '; |
|
325 | + } |
|
267 | 326 | if (is_object($object->user_modification)) |
268 | 327 | { |
269 | - if ($object->user_modification->id) print $object->user_modification->getNomUrl(1, '', 0, 0, 0); |
|
270 | - else print $langs->trans("Unknown"); |
|
271 | - } |
|
272 | - else |
|
328 | + if ($object->user_modification->id) { |
|
329 | + print $object->user_modification->getNomUrl(1, '', 0, 0, 0); |
|
330 | + } else { |
|
331 | + print $langs->trans("Unknown"); |
|
332 | + } |
|
333 | + } else |
|
273 | 334 | { |
274 | 335 | $userstatic=new User($db); |
275 | 336 | $userstatic->fetch($object->user_modification_id ? $object->user_modification_id : $object->user_modification); |
276 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
277 | - else print $langs->trans("Unknown"); |
|
337 | + if ($userstatic->id) { |
|
338 | + print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
339 | + } else { |
|
340 | + print $langs->trans("Unknown"); |
|
341 | + } |
|
342 | + } |
|
343 | + if ($usetable) { |
|
344 | + print '</td></tr>'; |
|
345 | + } else { |
|
346 | + print '<br>'; |
|
278 | 347 | } |
279 | - if ($usetable) print '</td></tr>'; |
|
280 | - else print '<br>'; |
|
281 | 348 | } |
282 | 349 | |
283 | 350 | // Date change |
284 | 351 | if (! empty($object->date_modification)) |
285 | 352 | { |
286 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
353 | + if ($usetable) { |
|
354 | + print '<tr><td class="titlefield">'; |
|
355 | + } |
|
287 | 356 | print $langs->trans("DateLastModification"); |
288 | - if ($usetable) print '</td><td>'; |
|
289 | - else print ': '; |
|
357 | + if ($usetable) { |
|
358 | + print '</td><td>'; |
|
359 | + } else { |
|
360 | + print ': '; |
|
361 | + } |
|
290 | 362 | print dol_print_date($object->date_modification, 'dayhour'); |
291 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_modification+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
292 | - if ($usetable) print '</td></tr>'; |
|
293 | - else print '<br>'; |
|
363 | + if ($deltadateforuser) { |
|
364 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_modification+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
365 | + } |
|
366 | + if ($usetable) { |
|
367 | + print '</td></tr>'; |
|
368 | + } else { |
|
369 | + print '<br>'; |
|
370 | + } |
|
294 | 371 | } |
295 | 372 | |
296 | 373 | // User validation (old method using already loaded object and not id is kept for backward compatibility) |
297 | 374 | if (! empty($object->user_validation) || ! empty($object->user_validation_id)) |
298 | 375 | { |
299 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
376 | + if ($usetable) { |
|
377 | + print '<tr><td class="titlefield">'; |
|
378 | + } |
|
300 | 379 | print $langs->trans("ValidatedBy"); |
301 | - if ($usetable) print '</td><td>'; |
|
302 | - else print ': '; |
|
380 | + if ($usetable) { |
|
381 | + print '</td><td>'; |
|
382 | + } else { |
|
383 | + print ': '; |
|
384 | + } |
|
303 | 385 | if (is_object($object->user_validation)) |
304 | 386 | { |
305 | - if ($object->user_validation->id) print $object->user_validation->getNomUrl(1, '', 0, 0, 0); |
|
306 | - else print $langs->trans("Unknown"); |
|
307 | - } |
|
308 | - else |
|
387 | + if ($object->user_validation->id) { |
|
388 | + print $object->user_validation->getNomUrl(1, '', 0, 0, 0); |
|
389 | + } else { |
|
390 | + print $langs->trans("Unknown"); |
|
391 | + } |
|
392 | + } else |
|
309 | 393 | { |
310 | 394 | $userstatic=new User($db); |
311 | 395 | $userstatic->fetch($object->user_validation_id ? $object->user_validation_id : $object->user_validation); |
312 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
313 | - else print $langs->trans("Unknown"); |
|
396 | + if ($userstatic->id) { |
|
397 | + print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
398 | + } else { |
|
399 | + print $langs->trans("Unknown"); |
|
400 | + } |
|
401 | + } |
|
402 | + if ($usetable) { |
|
403 | + print '</td></tr>'; |
|
404 | + } else { |
|
405 | + print '<br>'; |
|
314 | 406 | } |
315 | - if ($usetable) print '</td></tr>'; |
|
316 | - else print '<br>'; |
|
317 | 407 | } |
318 | 408 | |
319 | 409 | // Date validation |
320 | 410 | if (! empty($object->date_validation)) |
321 | 411 | { |
322 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
412 | + if ($usetable) { |
|
413 | + print '<tr><td class="titlefield">'; |
|
414 | + } |
|
323 | 415 | print $langs->trans("DateValidation"); |
324 | - if ($usetable) print '</td><td>'; |
|
325 | - else print ': '; |
|
416 | + if ($usetable) { |
|
417 | + print '</td><td>'; |
|
418 | + } else { |
|
419 | + print ': '; |
|
420 | + } |
|
326 | 421 | print dol_print_date($object->date_validation, 'dayhour'); |
327 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_validation+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
328 | - if ($usetable) print '</td></tr>'; |
|
329 | - else print '<br>'; |
|
422 | + if ($deltadateforuser) { |
|
423 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_validation+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
424 | + } |
|
425 | + if ($usetable) { |
|
426 | + print '</td></tr>'; |
|
427 | + } else { |
|
428 | + print '<br>'; |
|
429 | + } |
|
330 | 430 | } |
331 | 431 | |
332 | 432 | // User approve (old method using already loaded object and not id is kept for backward compatibility) |
333 | 433 | if (! empty($object->user_approve) || ! empty($object->user_approve_id)) |
334 | 434 | { |
335 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
435 | + if ($usetable) { |
|
436 | + print '<tr><td class="titlefield">'; |
|
437 | + } |
|
336 | 438 | print $langs->trans("ApprovedBy"); |
337 | - if ($usetable) print '</td><td>'; |
|
338 | - else print ': '; |
|
439 | + if ($usetable) { |
|
440 | + print '</td><td>'; |
|
441 | + } else { |
|
442 | + print ': '; |
|
443 | + } |
|
339 | 444 | if (is_object($object->user_approve)) |
340 | 445 | { |
341 | - if ($object->user_approve->id) print $object->user_approve->getNomUrl(1, '', 0, 0, 0); |
|
342 | - else print $langs->trans("Unknown"); |
|
343 | - } |
|
344 | - else |
|
446 | + if ($object->user_approve->id) { |
|
447 | + print $object->user_approve->getNomUrl(1, '', 0, 0, 0); |
|
448 | + } else { |
|
449 | + print $langs->trans("Unknown"); |
|
450 | + } |
|
451 | + } else |
|
345 | 452 | { |
346 | 453 | $userstatic=new User($db); |
347 | 454 | $userstatic->fetch($object->user_approve_id ? $object->user_approve_id : $object->user_approve); |
348 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
349 | - else print $langs->trans("Unknown"); |
|
455 | + if ($userstatic->id) { |
|
456 | + print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
457 | + } else { |
|
458 | + print $langs->trans("Unknown"); |
|
459 | + } |
|
460 | + } |
|
461 | + if ($usetable) { |
|
462 | + print '</td></tr>'; |
|
463 | + } else { |
|
464 | + print '<br>'; |
|
350 | 465 | } |
351 | - if ($usetable) print '</td></tr>'; |
|
352 | - else print '<br>'; |
|
353 | 466 | } |
354 | 467 | |
355 | 468 | // Date approve |
356 | 469 | if (! empty($object->date_approve)) |
357 | 470 | { |
358 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
471 | + if ($usetable) { |
|
472 | + print '<tr><td class="titlefield">'; |
|
473 | + } |
|
359 | 474 | print $langs->trans("DateApprove"); |
360 | - if ($usetable) print '</td><td>'; |
|
361 | - else print ': '; |
|
475 | + if ($usetable) { |
|
476 | + print '</td><td>'; |
|
477 | + } else { |
|
478 | + print ': '; |
|
479 | + } |
|
362 | 480 | print dol_print_date($object->date_approve, 'dayhour'); |
363 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_approve+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
364 | - if ($usetable) print '</td></tr>'; |
|
365 | - else print '<br>'; |
|
481 | + if ($deltadateforuser) { |
|
482 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_approve+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
483 | + } |
|
484 | + if ($usetable) { |
|
485 | + print '</td></tr>'; |
|
486 | + } else { |
|
487 | + print '<br>'; |
|
488 | + } |
|
366 | 489 | } |
367 | 490 | |
368 | 491 | // User approve |
369 | 492 | if (! empty($object->user_approve_id2)) |
370 | 493 | { |
371 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
494 | + if ($usetable) { |
|
495 | + print '<tr><td class="titlefield">'; |
|
496 | + } |
|
372 | 497 | print $langs->trans("ApprovedBy"); |
373 | - if ($usetable) print '</td><td>'; |
|
374 | - else print ': '; |
|
498 | + if ($usetable) { |
|
499 | + print '</td><td>'; |
|
500 | + } else { |
|
501 | + print ': '; |
|
502 | + } |
|
375 | 503 | $userstatic=new User($db); |
376 | 504 | $userstatic->fetch($object->user_approve_id2); |
377 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
378 | - else print $langs->trans("Unknown"); |
|
379 | - if ($usetable) print '</td></tr>'; |
|
380 | - else print '<br>'; |
|
505 | + if ($userstatic->id) { |
|
506 | + print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
507 | + } else { |
|
508 | + print $langs->trans("Unknown"); |
|
509 | + } |
|
510 | + if ($usetable) { |
|
511 | + print '</td></tr>'; |
|
512 | + } else { |
|
513 | + print '<br>'; |
|
514 | + } |
|
381 | 515 | } |
382 | 516 | |
383 | 517 | // Date approve |
384 | 518 | if (! empty($object->date_approve2)) |
385 | 519 | { |
386 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
520 | + if ($usetable) { |
|
521 | + print '<tr><td class="titlefield">'; |
|
522 | + } |
|
387 | 523 | print $langs->trans("DateApprove2"); |
388 | - if ($usetable) print '</td><td>'; |
|
389 | - else print ': '; |
|
524 | + if ($usetable) { |
|
525 | + print '</td><td>'; |
|
526 | + } else { |
|
527 | + print ': '; |
|
528 | + } |
|
390 | 529 | print dol_print_date($object->date_approve2, 'dayhour'); |
391 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_approve2+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
392 | - if ($usetable) print '</td></tr>'; |
|
393 | - else print '<br>'; |
|
530 | + if ($deltadateforuser) { |
|
531 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_approve2+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
532 | + } |
|
533 | + if ($usetable) { |
|
534 | + print '</td></tr>'; |
|
535 | + } else { |
|
536 | + print '<br>'; |
|
537 | + } |
|
394 | 538 | } |
395 | 539 | |
396 | 540 | // User close |
397 | 541 | if (! empty($object->user_cloture)) |
398 | 542 | { |
399 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
543 | + if ($usetable) { |
|
544 | + print '<tr><td class="titlefield">'; |
|
545 | + } |
|
400 | 546 | print $langs->trans("ClosedBy"); |
401 | - if ($usetable) print '</td><td>'; |
|
402 | - else print ': '; |
|
547 | + if ($usetable) { |
|
548 | + print '</td><td>'; |
|
549 | + } else { |
|
550 | + print ': '; |
|
551 | + } |
|
403 | 552 | if (is_object($object->user_cloture)) |
404 | 553 | { |
405 | - if ($object->user_cloture->id) print $object->user_cloture->getNomUrl(1, '', 0, 0, 0); |
|
406 | - else print $langs->trans("Unknown"); |
|
407 | - } |
|
408 | - else |
|
554 | + if ($object->user_cloture->id) { |
|
555 | + print $object->user_cloture->getNomUrl(1, '', 0, 0, 0); |
|
556 | + } else { |
|
557 | + print $langs->trans("Unknown"); |
|
558 | + } |
|
559 | + } else |
|
409 | 560 | { |
410 | 561 | $userstatic=new User($db); |
411 | 562 | $userstatic->fetch($object->user_cloture); |
412 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
413 | - else print $langs->trans("Unknown"); |
|
563 | + if ($userstatic->id) { |
|
564 | + print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
565 | + } else { |
|
566 | + print $langs->trans("Unknown"); |
|
567 | + } |
|
568 | + } |
|
569 | + if ($usetable) { |
|
570 | + print '</td></tr>'; |
|
571 | + } else { |
|
572 | + print '<br>'; |
|
414 | 573 | } |
415 | - if ($usetable) print '</td></tr>'; |
|
416 | - else print '<br>'; |
|
417 | 574 | } |
418 | 575 | |
419 | 576 | // Date close |
420 | 577 | if (! empty($object->date_cloture)) |
421 | 578 | { |
422 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
579 | + if ($usetable) { |
|
580 | + print '<tr><td class="titlefield">'; |
|
581 | + } |
|
423 | 582 | print $langs->trans("DateClosing"); |
424 | - if ($usetable) print '</td><td>'; |
|
425 | - else print ': '; |
|
583 | + if ($usetable) { |
|
584 | + print '</td><td>'; |
|
585 | + } else { |
|
586 | + print ': '; |
|
587 | + } |
|
426 | 588 | print dol_print_date($object->date_cloture, 'dayhour'); |
427 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_cloture+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
428 | - if ($usetable) print '</td></tr>'; |
|
429 | - else print '<br>'; |
|
589 | + if ($deltadateforuser) { |
|
590 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_cloture+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
591 | + } |
|
592 | + if ($usetable) { |
|
593 | + print '</td></tr>'; |
|
594 | + } else { |
|
595 | + print '<br>'; |
|
596 | + } |
|
430 | 597 | } |
431 | 598 | |
432 | 599 | // User conciliate |
433 | 600 | if (! empty($object->user_rappro)) |
434 | 601 | { |
435 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
602 | + if ($usetable) { |
|
603 | + print '<tr><td class="titlefield">'; |
|
604 | + } |
|
436 | 605 | print $langs->trans("ConciliatedBy"); |
437 | - if ($usetable) print '</td><td>'; |
|
438 | - else print ': '; |
|
606 | + if ($usetable) { |
|
607 | + print '</td><td>'; |
|
608 | + } else { |
|
609 | + print ': '; |
|
610 | + } |
|
439 | 611 | if (is_object($object->user_rappro)) |
440 | 612 | { |
441 | - if ($object->user_rappro->id) print $object->user_rappro->getNomUrl(1, '', 0, 0, 0); |
|
442 | - else print $langs->trans("Unknown"); |
|
443 | - } |
|
444 | - else |
|
613 | + if ($object->user_rappro->id) { |
|
614 | + print $object->user_rappro->getNomUrl(1, '', 0, 0, 0); |
|
615 | + } else { |
|
616 | + print $langs->trans("Unknown"); |
|
617 | + } |
|
618 | + } else |
|
445 | 619 | { |
446 | 620 | $userstatic=new User($db); |
447 | 621 | $userstatic->fetch($object->user_rappro); |
448 | - if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
449 | - else print $langs->trans("Unknown"); |
|
622 | + if ($userstatic->id) { |
|
623 | + print $userstatic->getNomUrl(1, '', 0, 0, 0); |
|
624 | + } else { |
|
625 | + print $langs->trans("Unknown"); |
|
626 | + } |
|
627 | + } |
|
628 | + if ($usetable) { |
|
629 | + print '</td></tr>'; |
|
630 | + } else { |
|
631 | + print '<br>'; |
|
450 | 632 | } |
451 | - if ($usetable) print '</td></tr>'; |
|
452 | - else print '<br>'; |
|
453 | 633 | } |
454 | 634 | |
455 | 635 | // Date conciliate |
456 | 636 | if (! empty($object->date_rappro)) |
457 | 637 | { |
458 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
638 | + if ($usetable) { |
|
639 | + print '<tr><td class="titlefield">'; |
|
640 | + } |
|
459 | 641 | print $langs->trans("DateConciliating"); |
460 | - if ($usetable) print '</td><td>'; |
|
461 | - else print ': '; |
|
642 | + if ($usetable) { |
|
643 | + print '</td><td>'; |
|
644 | + } else { |
|
645 | + print ': '; |
|
646 | + } |
|
462 | 647 | print dol_print_date($object->date_rappro, 'dayhour'); |
463 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_rappro+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
464 | - if ($usetable) print '</td></tr>'; |
|
465 | - else print '<br>'; |
|
648 | + if ($deltadateforuser) { |
|
649 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_rappro+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
650 | + } |
|
651 | + if ($usetable) { |
|
652 | + print '</td></tr>'; |
|
653 | + } else { |
|
654 | + print '<br>'; |
|
655 | + } |
|
466 | 656 | } |
467 | 657 | |
468 | 658 | // Date send |
469 | 659 | if (! empty($object->date_envoi)) |
470 | 660 | { |
471 | - if ($usetable) print '<tr><td class="titlefield">'; |
|
661 | + if ($usetable) { |
|
662 | + print '<tr><td class="titlefield">'; |
|
663 | + } |
|
472 | 664 | print $langs->trans("DateLastSend"); |
473 | - if ($usetable) print '</td><td>'; |
|
474 | - else print ': '; |
|
665 | + if ($usetable) { |
|
666 | + print '</td><td>'; |
|
667 | + } else { |
|
668 | + print ': '; |
|
669 | + } |
|
475 | 670 | print dol_print_date($object->date_envoi, 'dayhour'); |
476 | - if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_envoi+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
477 | - if ($usetable) print '</td></tr>'; |
|
478 | - else print '<br>'; |
|
671 | + if ($deltadateforuser) { |
|
672 | + print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_envoi+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour"); |
|
673 | + } |
|
674 | + if ($usetable) { |
|
675 | + print '</td></tr>'; |
|
676 | + } else { |
|
677 | + print '<br>'; |
|
678 | + } |
|
479 | 679 | } |
480 | 680 | |
481 | - if ($usetable) print '</table>'; |
|
482 | -} |
|
681 | + if ($usetable) { |
|
682 | + print '</table>'; |
|
683 | + } |
|
684 | + } |
|
483 | 685 | |
484 | 686 | |
485 | 687 | /** |
@@ -508,8 +710,7 @@ discard block |
||
508 | 710 | if (checkdnsrr($domain, "MX")) |
509 | 711 | { |
510 | 712 | return true; |
511 | - } |
|
512 | - else |
|
713 | + } else |
|
513 | 714 | { |
514 | 715 | return false; |
515 | 716 | } |
@@ -534,10 +735,14 @@ discard block |
||
534 | 735 | $urlregex = ''; |
535 | 736 | |
536 | 737 | // SCHEME |
537 | - if ($http) $urlregex .= "^(http:\/\/|https:\/\/)"; |
|
738 | + if ($http) { |
|
739 | + $urlregex .= "^(http:\/\/|https:\/\/)"; |
|
740 | + } |
|
538 | 741 | |
539 | 742 | // USER AND PASS |
540 | - if ($pass) $urlregex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)"; |
|
743 | + if ($pass) { |
|
744 | + $urlregex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)"; |
|
745 | + } |
|
541 | 746 | |
542 | 747 | // HOSTNAME OR IP |
543 | 748 | //$urlregex .= "[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*"; // x allowed (ex. http://localhost, http://routerlogin) |
@@ -546,13 +751,21 @@ discard block |
||
546 | 751 | //use only one of the above |
547 | 752 | |
548 | 753 | // PORT |
549 | - if ($port) $urlregex .= "(\:[0-9]{2,5})"; |
|
754 | + if ($port) { |
|
755 | + $urlregex .= "(\:[0-9]{2,5})"; |
|
756 | + } |
|
550 | 757 | // PATH |
551 | - if ($path) $urlregex .= "(\/([a-z0-9+\$_-]\.?)+)*\/"; |
|
758 | + if ($path) { |
|
759 | + $urlregex .= "(\/([a-z0-9+\$_-]\.?)+)*\/"; |
|
760 | + } |
|
552 | 761 | // GET Query |
553 | - if ($query) $urlregex .= "(\?[a-z+&\$_.-][a-z0-9;:@\/&%=+\$_.-]*)"; |
|
762 | + if ($query) { |
|
763 | + $urlregex .= "(\?[a-z+&\$_.-][a-z0-9;:@\/&%=+\$_.-]*)"; |
|
764 | + } |
|
554 | 765 | // ANCHOR |
555 | - if ($anchor) $urlregex .= "(#[a-z_.-][a-z0-9+\$_.-]*)$"; |
|
766 | + if ($anchor) { |
|
767 | + $urlregex .= "(#[a-z_.-][a-z0-9+\$_.-]*)$"; |
|
768 | + } |
|
556 | 769 | |
557 | 770 | // check |
558 | 771 | if (preg_match('/'.$urlregex.'/i', $url)) |
@@ -600,9 +813,10 @@ discard block |
||
600 | 813 | $CleanUrl = preg_replace('/^'.preg_quote($proto.$domain,'/').'/i', $newproto.strtolower($domain), $url); |
601 | 814 | |
602 | 815 | return $CleanUrl; |
816 | + } else { |
|
817 | + return $url; |
|
818 | + } |
|
603 | 819 | } |
604 | - else return $url; |
|
605 | -} |
|
606 | 820 | |
607 | 821 | |
608 | 822 | |
@@ -619,7 +833,9 @@ discard block |
||
619 | 833 | */ |
620 | 834 | function dolObfuscateEmail($mail, $replace="*", $nbreplace=8, $nbdisplaymail=4, $nbdisplaydomain=3, $displaytld=true) |
621 | 835 | { |
622 | - if(!isValidEmail($mail))return ''; |
|
836 | + if(!isValidEmail($mail)) { |
|
837 | + return ''; |
|
838 | + } |
|
623 | 839 | $tab = explode('@', $mail); |
624 | 840 | $tab2 = explode('.',$tab[1]); |
625 | 841 | $string_replace = ''; |
@@ -681,7 +897,9 @@ discard block |
||
681 | 897 | function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdoptions='') |
682 | 898 | { |
683 | 899 | $text='' ; |
684 | - if($tableMarkup) $text = '<table '.$tableoptions.'>' ; |
|
900 | + if($tableMarkup) { |
|
901 | + $text = '<table '.$tableoptions.'>' ; |
|
902 | + } |
|
685 | 903 | foreach($data as $key => $item){ |
686 | 904 | if(is_array($item)){ |
687 | 905 | $text.=array2tr($item,$troptions,$tdoptions); |
@@ -692,7 +910,9 @@ discard block |
||
692 | 910 | $text.= '</tr>' ; |
693 | 911 | } |
694 | 912 | } |
695 | - if($tableMarkup) $text.= '</table>' ; |
|
913 | + if($tableMarkup) { |
|
914 | + $text.= '</table>' ; |
|
915 | + } |
|
696 | 916 | return $text ; |
697 | 917 | } |
698 | 918 | |
@@ -716,15 +936,25 @@ discard block |
||
716 | 936 | { |
717 | 937 | global $conf,$user; |
718 | 938 | |
719 | - if (! is_object($objsoc)) $valueforccc=$objsoc; |
|
720 | - else if ($table == "commande_fournisseur" || $table == "facture_fourn" ) $valueforccc=$objsoc->code_fournisseur; |
|
721 | - else $valueforccc=$objsoc->code_client; |
|
939 | + if (! is_object($objsoc)) { |
|
940 | + $valueforccc=$objsoc; |
|
941 | + } else if ($table == "commande_fournisseur" || $table == "facture_fourn" ) { |
|
942 | + $valueforccc=$objsoc->code_fournisseur; |
|
943 | + } else { |
|
944 | + $valueforccc=$objsoc->code_client; |
|
945 | + } |
|
722 | 946 | |
723 | 947 | $sharetable = $table; |
724 | - if ($table == 'facture' || $table == 'invoice') $sharetable = 'invoicenumber'; // for getEntity function |
|
948 | + if ($table == 'facture' || $table == 'invoice') { |
|
949 | + $sharetable = 'invoicenumber'; |
|
950 | + } |
|
951 | + // for getEntity function |
|
725 | 952 | |
726 | 953 | // Clean parameters |
727 | - if ($date == '') $date=dol_now(); // We use local year and month of PHP server to search numbers |
|
954 | + if ($date == '') { |
|
955 | + $date=dol_now(); |
|
956 | + } |
|
957 | + // We use local year and month of PHP server to search numbers |
|
728 | 958 | // but we should use local year and month of user |
729 | 959 | |
730 | 960 | // For debugging |
@@ -741,8 +971,7 @@ discard block |
||
741 | 971 | $masktri=$reg[1].(! empty($reg[2])?$reg[2]:'').(! empty($reg[3])?$reg[3]:''); |
742 | 972 | $maskcounter=$reg[1]; |
743 | 973 | $hasglobalcounter=true; |
744 | - } |
|
745 | - else |
|
974 | + } else |
|
746 | 975 | { |
747 | 976 | // setting some defaults so the rest of the code won't fail if there is a third party counter |
748 | 977 | $masktri='00000'; |
@@ -752,7 +981,9 @@ discard block |
||
752 | 981 | $maskraz=-1; |
753 | 982 | $maskoffset=0; |
754 | 983 | $resetEveryMonth=false; |
755 | - if (dol_strlen($maskcounter) < 3 && empty($conf->global->MAIN_COUNTER_WITH_LESS_3_DIGITS)) return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
984 | + if (dol_strlen($maskcounter) < 3 && empty($conf->global->MAIN_COUNTER_WITH_LESS_3_DIGITS)) { |
|
985 | + return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
986 | + } |
|
756 | 987 | |
757 | 988 | // Extract value for third party mask counter |
758 | 989 | if (preg_match('/\{(c+)(0*)\}/i',$mask,$regClientRef)) |
@@ -764,9 +995,12 @@ discard block |
||
764 | 995 | $maskrefclient_clientcode=substr($valueforccc,0,dol_strlen($maskrefclient_maskclientcode));//get n first characters of client code where n is length in mask |
765 | 996 | $maskrefclient_clientcode=str_pad($maskrefclient_clientcode,dol_strlen($maskrefclient_maskclientcode),"#",STR_PAD_RIGHT);//padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode |
766 | 997 | $maskrefclient_clientcode=dol_string_nospecial($maskrefclient_clientcode);//sanitize maskrefclient_clientcode for sql insert and sql select like |
767 | - if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
998 | + if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) { |
|
999 | + return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
1000 | + } |
|
1001 | + } else { |
|
1002 | + $maskrefclient=''; |
|
768 | 1003 | } |
769 | - else $maskrefclient=''; |
|
770 | 1004 | |
771 | 1005 | // fail if there is neither a global nor a third party counter |
772 | 1006 | if (! $hasglobalcounter && ($maskrefclient_maskcounter == '')) |
@@ -780,8 +1014,7 @@ discard block |
||
780 | 1014 | $masktype=$regType[1]; |
781 | 1015 | $masktype_value=substr(preg_replace('/^TE_/','',$objsoc->typent_code),0,dol_strlen($regType[1]));// get n first characters of thirdpaty typent_code (where n is length in mask) |
782 | 1016 | $masktype_value=str_pad($masktype_value,dol_strlen($regType[1]),"#",STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask |
783 | - } |
|
784 | - else |
|
1017 | + } else |
|
785 | 1018 | { |
786 | 1019 | $masktype=''; |
787 | 1020 | $masktype_value=''; |
@@ -791,13 +1024,14 @@ discard block |
||
791 | 1024 | if (preg_match('/\{(u+)\}/i',$mask,$regType)) |
792 | 1025 | { |
793 | 1026 | $lastname = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; |
794 | - if (is_object($objuser)) $lastname = $objuser->lastname; |
|
1027 | + if (is_object($objuser)) { |
|
1028 | + $lastname = $objuser->lastname; |
|
1029 | + } |
|
795 | 1030 | |
796 | 1031 | $maskuser=$regType[1]; |
797 | 1032 | $maskuser_value=substr($lastname,0,dol_strlen($regType[1]));// get n first characters of user firstname (where n is length in mask) |
798 | 1033 | $maskuser_value=str_pad($maskuser_value,dol_strlen($regType[1]),"#",STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask |
799 | - } |
|
800 | - else |
|
1034 | + } else |
|
801 | 1035 | { |
802 | 1036 | $maskuser=''; |
803 | 1037 | $maskuser_value=''; |
@@ -844,8 +1078,12 @@ discard block |
||
844 | 1078 | //var_dump($reg); |
845 | 1079 | |
846 | 1080 | // If an offset is asked |
847 | - if (! empty($reg[2]) && preg_match('/^\+/',$reg[2])) $maskoffset=preg_replace('/^\+/','',$reg[2]); |
|
848 | - if (! empty($reg[3]) && preg_match('/^\+/',$reg[3])) $maskoffset=preg_replace('/^\+/','',$reg[3]); |
|
1081 | + if (! empty($reg[2]) && preg_match('/^\+/',$reg[2])) { |
|
1082 | + $maskoffset=preg_replace('/^\+/','',$reg[2]); |
|
1083 | + } |
|
1084 | + if (! empty($reg[3]) && preg_match('/^\+/',$reg[3])) { |
|
1085 | + $maskoffset=preg_replace('/^\+/','',$reg[3]); |
|
1086 | + } |
|
849 | 1087 | |
850 | 1088 | // Define $sqlwhere |
851 | 1089 | $sqlwhere=''; |
@@ -853,14 +1091,21 @@ discard block |
||
853 | 1091 | $yearoffsettype=false; // false: no reset, 0,-,=,+: reset at offset SOCIETE_FISCAL_MONTH_START, x=reset at offset x |
854 | 1092 | |
855 | 1093 | // If a restore to zero after a month is asked we check if there is already a value for this year. |
856 | - if (! empty($reg[2]) && preg_match('/^@/',$reg[2])) $yearoffsettype = preg_replace('/^@/','',$reg[2]); |
|
857 | - if (! empty($reg[3]) && preg_match('/^@/',$reg[3])) $yearoffsettype = preg_replace('/^@/','',$reg[3]); |
|
1094 | + if (! empty($reg[2]) && preg_match('/^@/',$reg[2])) { |
|
1095 | + $yearoffsettype = preg_replace('/^@/','',$reg[2]); |
|
1096 | + } |
|
1097 | + if (! empty($reg[3]) && preg_match('/^@/',$reg[3])) { |
|
1098 | + $yearoffsettype = preg_replace('/^@/','',$reg[3]); |
|
1099 | + } |
|
858 | 1100 | |
859 | 1101 | //print "yearoffset=".$yearoffset." yearoffsettype=".$yearoffsettype; |
860 | - if (is_numeric($yearoffsettype) && $yearoffsettype >= 1) |
|
861 | - $maskraz=$yearoffsettype; // For backward compatibility |
|
862 | - else if ($yearoffsettype === '0' || (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1)) |
|
863 | - $maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START; |
|
1102 | + if (is_numeric($yearoffsettype) && $yearoffsettype >= 1) { |
|
1103 | + $maskraz=$yearoffsettype; |
|
1104 | + } |
|
1105 | + // For backward compatibility |
|
1106 | + else if ($yearoffsettype === '0' || (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $conf->global->SOCIETE_FISCAL_MONTH_START > 1)) { |
|
1107 | + $maskraz = $conf->global->SOCIETE_FISCAL_MONTH_START; |
|
1108 | + } |
|
864 | 1109 | //print "maskraz=".$maskraz; // -1=no reset |
865 | 1110 | |
866 | 1111 | if ($maskraz > 0) { // A reset is required |
@@ -868,23 +1113,28 @@ discard block |
||
868 | 1113 | $maskraz = date('m', $date); |
869 | 1114 | $resetEveryMonth = true; |
870 | 1115 | } |
871 | - if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; |
|
1116 | + if ($maskraz > 12) { |
|
1117 | + return 'ErrorBadMaskBadRazMonth'; |
|
1118 | + } |
|
872 | 1119 | |
873 | 1120 | // Define posy, posm and reg |
874 | - if ($maskraz > 1) // if reset is not first month, we need month and year into mask |
|
1121 | + if ($maskraz > 1) { |
|
1122 | + // if reset is not first month, we need month and year into mask |
|
875 | 1123 | { |
876 | - if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; } |
|
877 | - elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; } |
|
878 | - else return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; |
|
879 | - |
|
880 | - if (dol_strlen($reg[$posy]) < 2) return 'ErrorCantUseRazWithYearOnOneDigit'; |
|
1124 | + if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; |
|
881 | 1125 | } |
882 | - else // if reset is for a specific month in year, we need year |
|
1126 | + $posm=3; } elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; } else { |
|
1127 | + return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; |
|
1128 | + } |
|
1129 | + |
|
1130 | + if (dol_strlen($reg[$posy]) < 2) { |
|
1131 | + return 'ErrorCantUseRazWithYearOnOneDigit'; |
|
1132 | + } |
|
1133 | + } else // if reset is for a specific month in year, we need year |
|
883 | 1134 | { |
884 | - if (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; } |
|
885 | - else if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; } |
|
886 | - else if (preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=0; } |
|
887 | - else return 'ErrorCantUseRazIfNoYearInMask'; |
|
1135 | + if (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=3; $posm=2; } else if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=3; } else if (preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) { $posy=2; $posm=0; } else { |
|
1136 | + return 'ErrorCantUseRazIfNoYearInMask'; |
|
1137 | + } |
|
888 | 1138 | } |
889 | 1139 | // Define length |
890 | 1140 | $yearlen = $posy?dol_strlen($reg[$posy]):0; |
@@ -902,9 +1152,11 @@ discard block |
||
902 | 1152 | $monthcomp=$maskraz; |
903 | 1153 | $yearcomp=0; |
904 | 1154 | |
905 | - if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') // $yearoffsettype is - or + |
|
1155 | + if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') { |
|
1156 | + // $yearoffsettype is - or + |
|
906 | 1157 | { |
907 | 1158 | $currentyear=date("Y", $date); |
1159 | + } |
|
908 | 1160 | $fiscaldate=dol_mktime('0','0','0',$maskraz,'1',$currentyear); |
909 | 1161 | $newyeardate=dol_mktime('0','0','0','1','1',$currentyear); |
910 | 1162 | $nextnewyeardate=dol_mktime('0','0','0','1','1',$currentyear+1); |
@@ -914,21 +1166,32 @@ discard block |
||
914 | 1166 | if ($date >= $fiscaldate) |
915 | 1167 | { |
916 | 1168 | // If before of next new year date |
917 | - if ($date < $nextnewyeardate && $yearoffsettype == '+') $yearoffset=1; |
|
1169 | + if ($date < $nextnewyeardate && $yearoffsettype == '+') { |
|
1170 | + $yearoffset=1; |
|
1171 | + } |
|
918 | 1172 | } |
919 | 1173 | // If after or equal of current new year date |
920 | - else if ($date >= $newyeardate && $yearoffsettype == '-') $yearoffset=-1; |
|
1174 | + else if ($date >= $newyeardate && $yearoffsettype == '-') { |
|
1175 | + $yearoffset=-1; |
|
1176 | + } |
|
921 | 1177 | } |
922 | 1178 | // For backward compatibility |
923 | 1179 | else if (date("m",$date) < $maskraz && empty($resetEveryMonth)) { $yearoffset=-1; } // If current month lower that month of return to zero, year is previous year |
924 | 1180 | |
925 | - if ($yearlen == 4) $yearcomp=sprintf("%04d",date("Y",$date)+$yearoffset); |
|
926 | - elseif ($yearlen == 2) $yearcomp=sprintf("%02d",date("y",$date)+$yearoffset); |
|
927 | - elseif ($yearlen == 1) $yearcomp=substr(date("y",$date),2,1)+$yearoffset; |
|
928 | - if ($monthcomp > 1 && empty($resetEveryMonth)) // Test with month is useless if monthcomp = 0 or 1 (0 is same as 1) (regis: $monthcomp can't equal 0) |
|
1181 | + if ($yearlen == 4) { |
|
1182 | + $yearcomp=sprintf("%04d",date("Y",$date)+$yearoffset); |
|
1183 | + } elseif ($yearlen == 2) { |
|
1184 | + $yearcomp=sprintf("%02d",date("y",$date)+$yearoffset); |
|
1185 | + } elseif ($yearlen == 1) { |
|
1186 | + $yearcomp=substr(date("y",$date),2,1)+$yearoffset; |
|
1187 | + } |
|
1188 | + if ($monthcomp > 1 && empty($resetEveryMonth)) { |
|
1189 | + // Test with month is useless if monthcomp = 0 or 1 (0 is same as 1) (regis: $monthcomp can't equal 0) |
|
929 | 1190 | { |
930 | 1191 | if ($yearlen == 4) $yearcomp1=sprintf("%04d",date("Y",$date)+$yearoffset+1); |
931 | - elseif ($yearlen == 2) $yearcomp1=sprintf("%02d",date("y",$date)+$yearoffset+1); |
|
1192 | + } elseif ($yearlen == 2) { |
|
1193 | + $yearcomp1=sprintf("%02d",date("y",$date)+$yearoffset+1); |
|
1194 | + } |
|
932 | 1195 | |
933 | 1196 | $sqlwhere.="("; |
934 | 1197 | $sqlwhere.=" (SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'"; |
@@ -937,13 +1200,11 @@ discard block |
||
937 | 1200 | $sqlwhere.=" (SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp1."'"; |
938 | 1201 | $sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") < '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."') "; |
939 | 1202 | $sqlwhere.=')'; |
940 | - } |
|
941 | - else if ($resetEveryMonth) |
|
1203 | + } else if ($resetEveryMonth) |
|
942 | 1204 | { |
943 | 1205 | $sqlwhere.="(SUBSTRING(".$field.", ".$yearpos.", ".$yearlen.") = '".$yearcomp."'"; |
944 | 1206 | $sqlwhere.=" AND SUBSTRING(".$field.", ".$monthpos.", ".$monthlen.") = '".str_pad($monthcomp, $monthlen, '0', STR_PAD_LEFT)."')"; |
945 | - } |
|
946 | - else // reset is done on january |
|
1207 | + } else // reset is done on january |
|
947 | 1208 | { |
948 | 1209 | $sqlwhere.='(SUBSTRING('.$field.', '.$yearpos.', '.$yearlen.") = '".$yearcomp."')"; |
949 | 1210 | } |
@@ -955,12 +1216,13 @@ discard block |
||
955 | 1216 | if (function_exists('mb_strrpos')) |
956 | 1217 | { |
957 | 1218 | $posnumstart=mb_strrpos($maskwithnocode,$maskcounter, 'UTF-8'); |
958 | - } |
|
959 | - else |
|
1219 | + } else |
|
960 | 1220 | { |
961 | 1221 | $posnumstart=strrpos($maskwithnocode,$maskcounter); |
962 | 1222 | } // Pos of counter in final string (from 0 to ...) |
963 | - if ($posnumstart < 0) return 'ErrorBadMaskFailedToLocatePosOfSequence'; |
|
1223 | + if ($posnumstart < 0) { |
|
1224 | + return 'ErrorBadMaskFailedToLocatePosOfSequence'; |
|
1225 | + } |
|
964 | 1226 | $sqlstring='SUBSTRING('.$field.', '.($posnumstart+1).', '.dol_strlen($maskcounter).')'; |
965 | 1227 | |
966 | 1228 | // Define $maskLike |
@@ -973,9 +1235,15 @@ discard block |
||
973 | 1235 | $maskLike = preg_replace('/\{mm\}/i','__',$maskLike); |
974 | 1236 | $maskLike = preg_replace('/\{dd\}/i','__',$maskLike); |
975 | 1237 | $maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'),str_pad("",dol_strlen($maskcounter),"_"),$maskLike); |
976 | - if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",dol_strlen($maskrefclient),"_"),$maskLike); |
|
977 | - if ($masktype) $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'),$masktype_value,$maskLike); |
|
978 | - if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'),$maskuser_value,$maskLike); |
|
1238 | + if ($maskrefclient) { |
|
1239 | + $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",dol_strlen($maskrefclient),"_"),$maskLike); |
|
1240 | + } |
|
1241 | + if ($masktype) { |
|
1242 | + $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'),$masktype_value,$maskLike); |
|
1243 | + } |
|
1244 | + if ($maskuser) { |
|
1245 | + $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'),$maskuser_value,$maskLike); |
|
1246 | + } |
|
979 | 1247 | foreach($maskperso as $key => $val) |
980 | 1248 | { |
981 | 1249 | $maskLike = str_replace(dol_string_nospecial($maskperso[$key]),$maskpersonew[$key],$maskLike); |
@@ -987,12 +1255,18 @@ discard block |
||
987 | 1255 | $sql.= " FROM ".MAIN_DB_PREFIX.$table; |
988 | 1256 | $sql.= " WHERE ".$field." LIKE '".$maskLike."'"; |
989 | 1257 | $sql.= " AND ".$field." NOT LIKE '(PROV%)'"; |
990 | - if ($bentityon) // only if entity enable |
|
1258 | + if ($bentityon) { |
|
1259 | + // only if entity enable |
|
991 | 1260 | $sql.= " AND entity IN (".getEntity($sharetable).")"; |
992 | - else if (! empty($forceentity)) |
|
993 | - $sql.= " AND entity IN (".$forceentity.")"; |
|
994 | - if ($where) $sql.=$where; |
|
995 | - if ($sqlwhere) $sql.=' AND '.$sqlwhere; |
|
1261 | + } else if (! empty($forceentity)) { |
|
1262 | + $sql.= " AND entity IN (".$forceentity.")"; |
|
1263 | + } |
|
1264 | + if ($where) { |
|
1265 | + $sql.=$where; |
|
1266 | + } |
|
1267 | + if ($sqlwhere) { |
|
1268 | + $sql.=' AND '.$sqlwhere; |
|
1269 | + } |
|
996 | 1270 | |
997 | 1271 | //print $sql.'<br>'; |
998 | 1272 | dol_syslog("functions2::get_next_value mode=".$mode."", LOG_DEBUG); |
@@ -1001,21 +1275,26 @@ discard block |
||
1001 | 1275 | { |
1002 | 1276 | $obj = $db->fetch_object($resql); |
1003 | 1277 | $counter = $obj->val; |
1278 | + } else { |
|
1279 | + dol_print_error($db); |
|
1004 | 1280 | } |
1005 | - else dol_print_error($db); |
|
1006 | 1281 | |
1007 | 1282 | // Check if we must force counter to maskoffset |
1008 | - if (empty($counter)) $counter=$maskoffset; |
|
1009 | - else if (preg_match('/[^0-9]/i',$counter)) |
|
1283 | + if (empty($counter)) { |
|
1284 | + $counter=$maskoffset; |
|
1285 | + } else if (preg_match('/[^0-9]/i',$counter)) |
|
1010 | 1286 | { |
1011 | 1287 | $counter=0; |
1012 | 1288 | dol_syslog("Error, the last counter found is '".$counter."' so is not a numeric value. We will restart to 1.", LOG_ERR); |
1289 | + } else if ($counter < $maskoffset && empty($conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) { |
|
1290 | + $counter=$maskoffset; |
|
1013 | 1291 | } |
1014 | - else if ($counter < $maskoffset && empty($conf->global->MAIN_NUMBERING_OFFSET_ONLY_FOR_FIRST)) $counter=$maskoffset; |
|
1015 | 1292 | |
1016 | - if ($mode == 'last') // We found value for counter = last counter value. Now need to get corresponding ref of invoice. |
|
1293 | + if ($mode == 'last') { |
|
1294 | + // We found value for counter = last counter value. Now need to get corresponding ref of invoice. |
|
1017 | 1295 | { |
1018 | 1296 | $counterpadded=str_pad($counter,dol_strlen($maskcounter),"0",STR_PAD_LEFT); |
1297 | + } |
|
1019 | 1298 | |
1020 | 1299 | // Define $maskLike |
1021 | 1300 | $maskLike = dol_string_nospecial($mask); |
@@ -1027,34 +1306,48 @@ discard block |
||
1027 | 1306 | $maskLike = preg_replace('/\{mm\}/i','__',$maskLike); |
1028 | 1307 | $maskLike = preg_replace('/\{dd\}/i','__',$maskLike); |
1029 | 1308 | $maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'),$counterpadded,$maskLike); |
1030 | - if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",dol_strlen($maskrefclient),"_"),$maskLike); |
|
1031 | - if ($masktype) $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'),$masktype_value,$maskLike); |
|
1032 | - if ($maskuser) $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'),$maskuser_value,$maskLike); |
|
1309 | + if ($maskrefclient) { |
|
1310 | + $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",dol_strlen($maskrefclient),"_"),$maskLike); |
|
1311 | + } |
|
1312 | + if ($masktype) { |
|
1313 | + $maskLike = str_replace(dol_string_nospecial('{'.$masktype.'}'),$masktype_value,$maskLike); |
|
1314 | + } |
|
1315 | + if ($maskuser) { |
|
1316 | + $maskLike = str_replace(dol_string_nospecial('{'.$maskuser.'}'),$maskuser_value,$maskLike); |
|
1317 | + } |
|
1033 | 1318 | |
1034 | 1319 | $ref=''; |
1035 | 1320 | $sql = "SELECT ".$field." as ref"; |
1036 | 1321 | $sql.= " FROM ".MAIN_DB_PREFIX.$table; |
1037 | 1322 | $sql.= " WHERE ".$field." LIKE '".$maskLike."'"; |
1038 | 1323 | $sql.= " AND ".$field." NOT LIKE '%PROV%'"; |
1039 | - if ($bentityon) // only if entity enable |
|
1324 | + if ($bentityon) { |
|
1325 | + // only if entity enable |
|
1040 | 1326 | $sql.= " AND entity IN (".getEntity($sharetable).")"; |
1041 | - else if (! empty($forceentity)) |
|
1042 | - $sql.= " AND entity IN (".$forceentity.")"; |
|
1043 | - if ($where) $sql.=$where; |
|
1044 | - if ($sqlwhere) $sql.=' AND '.$sqlwhere; |
|
1327 | + } else if (! empty($forceentity)) { |
|
1328 | + $sql.= " AND entity IN (".$forceentity.")"; |
|
1329 | + } |
|
1330 | + if ($where) { |
|
1331 | + $sql.=$where; |
|
1332 | + } |
|
1333 | + if ($sqlwhere) { |
|
1334 | + $sql.=' AND '.$sqlwhere; |
|
1335 | + } |
|
1045 | 1336 | |
1046 | 1337 | dol_syslog("functions2::get_next_value mode=".$mode."", LOG_DEBUG); |
1047 | 1338 | $resql=$db->query($sql); |
1048 | 1339 | if ($resql) |
1049 | 1340 | { |
1050 | 1341 | $obj = $db->fetch_object($resql); |
1051 | - if ($obj) $ref = $obj->ref; |
|
1342 | + if ($obj) { |
|
1343 | + $ref = $obj->ref; |
|
1344 | + } |
|
1345 | + } else { |
|
1346 | + dol_print_error($db); |
|
1052 | 1347 | } |
1053 | - else dol_print_error($db); |
|
1054 | 1348 | |
1055 | 1349 | $numFinal=$ref; |
1056 | - } |
|
1057 | - else if ($mode == 'next') |
|
1350 | + } else if ($mode == 'next') |
|
1058 | 1351 | { |
1059 | 1352 | $counter++; |
1060 | 1353 | |
@@ -1070,7 +1363,9 @@ discard block |
||
1070 | 1363 | |
1071 | 1364 | // Define $sqlstring |
1072 | 1365 | $maskrefclient_posnumstart=strpos($maskwithnocode,$maskrefclient_maskcounter,strpos($maskwithnocode,$maskrefclient)); // Pos of counter in final string (from 0 to ...) |
1073 | - if ($maskrefclient_posnumstart <= 0) return 'ErrorBadMask'; |
|
1366 | + if ($maskrefclient_posnumstart <= 0) { |
|
1367 | + return 'ErrorBadMask'; |
|
1368 | + } |
|
1074 | 1369 | $maskrefclient_sqlstring='SUBSTRING('.$field.', '.($maskrefclient_posnumstart+1).', '.dol_strlen($maskrefclient_maskcounter).')'; |
1075 | 1370 | //print "x".$sqlstring; |
1076 | 1371 | |
@@ -1092,12 +1387,20 @@ discard block |
||
1092 | 1387 | $maskrefclient_sql.= " FROM ".MAIN_DB_PREFIX.$table; |
1093 | 1388 | //$sql.= " WHERE ".$field." not like '(%'"; |
1094 | 1389 | $maskrefclient_sql.= " WHERE ".$field." LIKE '".$maskrefclient_maskLike."'"; |
1095 | - if ($bentityon) // only if entity enable |
|
1390 | + if ($bentityon) { |
|
1391 | + // only if entity enable |
|
1096 | 1392 | $maskrefclient_sql.= " AND entity IN (".getEntity($sharetable).")"; |
1097 | - else if (! empty($forceentity)) |
|
1098 | - $sql.= " AND entity IN (".$forceentity.")"; |
|
1099 | - if ($where) $maskrefclient_sql.=$where; //use the same optional where as general mask |
|
1100 | - if ($sqlwhere) $maskrefclient_sql.=' AND '.$sqlwhere; //use the same sqlwhere as general mask |
|
1393 | + } else if (! empty($forceentity)) { |
|
1394 | + $sql.= " AND entity IN (".$forceentity.")"; |
|
1395 | + } |
|
1396 | + if ($where) { |
|
1397 | + $maskrefclient_sql.=$where; |
|
1398 | + } |
|
1399 | + //use the same optional where as general mask |
|
1400 | + if ($sqlwhere) { |
|
1401 | + $maskrefclient_sql.=' AND '.$sqlwhere; |
|
1402 | + } |
|
1403 | + //use the same sqlwhere as general mask |
|
1101 | 1404 | $maskrefclient_sql.=' AND (SUBSTRING('.$field.', '.(strpos($maskwithnocode,$maskrefclient)+1).', '.dol_strlen($maskrefclient_maskclientcode).")='".$maskrefclient_clientcode."')"; |
1102 | 1405 | |
1103 | 1406 | dol_syslog("functions2::get_next_value maskrefclient", LOG_DEBUG); |
@@ -1106,10 +1409,13 @@ discard block |
||
1106 | 1409 | { |
1107 | 1410 | $maskrefclient_obj = $db->fetch_object($maskrefclient_resql); |
1108 | 1411 | $maskrefclient_counter = $maskrefclient_obj->val; |
1412 | + } else { |
|
1413 | + dol_print_error($db); |
|
1109 | 1414 | } |
1110 | - else dol_print_error($db); |
|
1111 | 1415 | |
1112 | - if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i',$maskrefclient_counter)) $maskrefclient_counter=$maskrefclient_maskoffset; |
|
1416 | + if (empty($maskrefclient_counter) || preg_match('/[^0-9]/i',$maskrefclient_counter)) { |
|
1417 | + $maskrefclient_counter=$maskrefclient_maskoffset; |
|
1418 | + } |
|
1113 | 1419 | $maskrefclient_counter++; |
1114 | 1420 | } |
1115 | 1421 | |
@@ -1117,13 +1423,14 @@ discard block |
||
1117 | 1423 | $numFinal = $mask; |
1118 | 1424 | |
1119 | 1425 | // We replace special codes except refclient |
1120 | - if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') // yearoffsettype is - or +, so we don't want current year |
|
1426 | + if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') { |
|
1427 | + // yearoffsettype is - or +, so we don't want current year |
|
1121 | 1428 | { |
1122 | 1429 | $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date)+$yearoffset, $numFinal); |
1430 | + } |
|
1123 | 1431 | $numFinal = preg_replace('/\{yy\}/i', date("y",$date)+$yearoffset, $numFinal); |
1124 | 1432 | $numFinal = preg_replace('/\{y\}/i', substr(date("y",$date),1,1)+$yearoffset, $numFinal); |
1125 | - } |
|
1126 | - else // we want yyyy to be current year |
|
1433 | + } else // we want yyyy to be current year |
|
1127 | 1434 | { |
1128 | 1435 | $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date), $numFinal); |
1129 | 1436 | $numFinal = preg_replace('/\{yy\}/i', date("y",$date), $numFinal); |
@@ -1180,7 +1487,9 @@ discard block |
||
1180 | 1487 | { |
1181 | 1488 | $string = " ".$string; |
1182 | 1489 | $ini = strpos($string,$start); |
1183 | - if ($ini == 0) return ""; |
|
1490 | + if ($ini == 0) { |
|
1491 | + return ""; |
|
1492 | + } |
|
1184 | 1493 | $ini += strlen($start); |
1185 | 1494 | $len = strpos($string,$end,$ini) - $ini; |
1186 | 1495 | return substr($string,$ini,$len); |
@@ -1204,8 +1513,7 @@ discard block |
||
1204 | 1513 | $masktri=$reg[1].(isset($reg[2])?$reg[2]:'').(isset($reg[3])?$reg[3]:''); |
1205 | 1514 | $maskcounter=$reg[1]; |
1206 | 1515 | $hasglobalcounter=true; |
1207 | - } |
|
1208 | - else |
|
1516 | + } else |
|
1209 | 1517 | { |
1210 | 1518 | // setting some defaults so the rest of the code won't fail if there is a third party counter |
1211 | 1519 | $masktri='00000'; |
@@ -1214,7 +1522,9 @@ discard block |
||
1214 | 1522 | |
1215 | 1523 | $maskraz=-1; |
1216 | 1524 | $maskoffset=0; |
1217 | - if (dol_strlen($maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
1525 | + if (dol_strlen($maskcounter) < 3) { |
|
1526 | + return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
1527 | + } |
|
1218 | 1528 | |
1219 | 1529 | // Extract value for third party mask counter |
1220 | 1530 | if (preg_match('/\{(c+)(0*)\}/i',$mask,$regClientRef)) |
@@ -1226,9 +1536,12 @@ discard block |
||
1226 | 1536 | $maskrefclient_clientcode=substr('',0,dol_strlen($maskrefclient_maskclientcode));//get n first characters of client code to form maskrefclient_clientcode |
1227 | 1537 | $maskrefclient_clientcode=str_pad($maskrefclient_clientcode,dol_strlen($maskrefclient_maskclientcode),"#",STR_PAD_RIGHT);//padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode |
1228 | 1538 | $maskrefclient_clientcode=dol_string_nospecial($maskrefclient_clientcode);//sanitize maskrefclient_clientcode for sql insert and sql select like |
1229 | - if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
1539 | + if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) { |
|
1540 | + return 'ErrorCounterMustHaveMoreThan3Digits'; |
|
1541 | + } |
|
1542 | + } else { |
|
1543 | + $maskrefclient=''; |
|
1230 | 1544 | } |
1231 | - else $maskrefclient=''; |
|
1232 | 1545 | |
1233 | 1546 | // fail if there is neither a global nor a third party counter |
1234 | 1547 | if (! $hasglobalcounter && ($maskrefclient_maskcounter == '')) |
@@ -1250,21 +1563,35 @@ discard block |
||
1250 | 1563 | //print "maskwithonlyymcode=".$maskwithonlyymcode." maskwithnocode=".$maskwithnocode."\n<br>"; |
1251 | 1564 | |
1252 | 1565 | // If an offset is asked |
1253 | - if (! empty($reg[2]) && preg_match('/^\+/',$reg[2])) $maskoffset=preg_replace('/^\+/','',$reg[2]); |
|
1254 | - if (! empty($reg[3]) && preg_match('/^\+/',$reg[3])) $maskoffset=preg_replace('/^\+/','',$reg[3]); |
|
1566 | + if (! empty($reg[2]) && preg_match('/^\+/',$reg[2])) { |
|
1567 | + $maskoffset=preg_replace('/^\+/','',$reg[2]); |
|
1568 | + } |
|
1569 | + if (! empty($reg[3]) && preg_match('/^\+/',$reg[3])) { |
|
1570 | + $maskoffset=preg_replace('/^\+/','',$reg[3]); |
|
1571 | + } |
|
1255 | 1572 | |
1256 | 1573 | // Define $sqlwhere |
1257 | 1574 | |
1258 | 1575 | // If a restore to zero after a month is asked we check if there is already a value for this year. |
1259 | - if (! empty($reg[2]) && preg_match('/^@/',$reg[2])) $maskraz=preg_replace('/^@/','',$reg[2]); |
|
1260 | - if (! empty($reg[3]) && preg_match('/^@/',$reg[3])) $maskraz=preg_replace('/^@/','',$reg[3]); |
|
1576 | + if (! empty($reg[2]) && preg_match('/^@/',$reg[2])) { |
|
1577 | + $maskraz=preg_replace('/^@/','',$reg[2]); |
|
1578 | + } |
|
1579 | + if (! empty($reg[3]) && preg_match('/^@/',$reg[3])) { |
|
1580 | + $maskraz=preg_replace('/^@/','',$reg[3]); |
|
1581 | + } |
|
1261 | 1582 | if ($maskraz >= 0) |
1262 | 1583 | { |
1263 | - if ($maskraz > 12) return 'ErrorBadMaskBadRazMonth'; |
|
1584 | + if ($maskraz > 12) { |
|
1585 | + return 'ErrorBadMaskBadRazMonth'; |
|
1586 | + } |
|
1264 | 1587 | |
1265 | 1588 | // Define reg |
1266 | - if ($maskraz > 1 && ! preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; |
|
1267 | - if ($maskraz <= 1 && ! preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) return 'ErrorCantUseRazIfNoYearInMask'; |
|
1589 | + if ($maskraz > 1 && ! preg_match('/^(.*)\{(y+)\}\{(m+)\}/i',$maskwithonlyymcode,$reg)) { |
|
1590 | + return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; |
|
1591 | + } |
|
1592 | + if ($maskraz <= 1 && ! preg_match('/^(.*)\{(y+)\}/i',$maskwithonlyymcode,$reg)) { |
|
1593 | + return 'ErrorCantUseRazIfNoYearInMask'; |
|
1594 | + } |
|
1268 | 1595 | //print "x".$maskwithonlyymcode." ".$maskraz; |
1269 | 1596 | } |
1270 | 1597 | //print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset."<br>\n"; |
@@ -1274,7 +1601,9 @@ discard block |
||
1274 | 1601 | |
1275 | 1602 | // Check length |
1276 | 1603 | $len=dol_strlen($maskwithnocode); |
1277 | - if (dol_strlen($value) != $len) $result=-1; |
|
1604 | + if (dol_strlen($value) != $len) { |
|
1605 | + $result=-1; |
|
1606 | + } |
|
1278 | 1607 | |
1279 | 1608 | // Define $maskLike |
1280 | 1609 | /* seems not used |
@@ -1355,29 +1684,37 @@ discard block |
||
1355 | 1684 | */ |
1356 | 1685 | |
1357 | 1686 | // Definition du Jeudi de la semaine |
1358 | - if (date("w",mktime(12,0,0,$mois,$jour,$annee))==0) // Dimanche |
|
1687 | + if (date("w",mktime(12,0,0,$mois,$jour,$annee))==0) { |
|
1688 | + // Dimanche |
|
1359 | 1689 | $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-3*24*60*60; |
1360 | - else if (date("w",mktime(12,0,0,$mois,$jour,$annee))<4) // du Lundi au Mercredi |
|
1690 | + } else if (date("w",mktime(12,0,0,$mois,$jour,$annee))<4) { |
|
1691 | + // du Lundi au Mercredi |
|
1361 | 1692 | $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)+(4-date("w",mktime(12,0,0,$mois,$jour,$annee)))*24*60*60; |
1362 | - else if (date("w",mktime(12,0,0,$mois,$jour,$annee))>4) // du Vendredi au Samedi |
|
1693 | + } else if (date("w",mktime(12,0,0,$mois,$jour,$annee))>4) { |
|
1694 | + // du Vendredi au Samedi |
|
1363 | 1695 | $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee)-(date("w",mktime(12,0,0,$mois,$jour,$annee))-4)*24*60*60; |
1364 | - else // Jeudi |
|
1696 | + } else { |
|
1697 | + // Jeudi |
|
1365 | 1698 | $jeudiSemaine = mktime(12,0,0,$mois,$jour,$annee); |
1699 | + } |
|
1366 | 1700 | |
1367 | 1701 | // Definition du premier Jeudi de l'annee |
1368 | - if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==0) // Dimanche |
|
1702 | + if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==0) { |
|
1703 | + // Dimanche |
|
1369 | 1704 | { |
1370 | 1705 | $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+4*24*60*60; |
1371 | 1706 | } |
1372 | - else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))<4) // du Lundi au Mercredi |
|
1707 | + } else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))<4) { |
|
1708 | + // du Lundi au Mercredi |
|
1373 | 1709 | { |
1374 | 1710 | $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+(4-date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine))))*24*60*60; |
1375 | 1711 | } |
1376 | - else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))>4) // du Vendredi au Samedi |
|
1712 | + } else if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))>4) { |
|
1713 | + // du Vendredi au Samedi |
|
1377 | 1714 | { |
1378 | 1715 | $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine))+(7-(date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))-4))*24*60*60; |
1379 | 1716 | } |
1380 | - else // Jeudi |
|
1717 | + } else // Jeudi |
|
1381 | 1718 | { |
1382 | 1719 | $premierJeudiAnnee = mktime(12,0,0,1,1,date("Y",$jeudiSemaine)); |
1383 | 1720 | } |
@@ -1398,8 +1735,7 @@ discard block |
||
1398 | 1735 | if (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==4 || (date("w",mktime(12,0,0,1,1,date("Y",$jeudiSemaine)))==3 && date("z",mktime(12,0,0,12,31,date("Y",$jeudiSemaine)))==365)) |
1399 | 1736 | { |
1400 | 1737 | $numeroSemaine = 53; |
1401 | - } |
|
1402 | - else |
|
1738 | + } else |
|
1403 | 1739 | { |
1404 | 1740 | $numeroSemaine = 1; |
1405 | 1741 | } |
@@ -1458,7 +1794,9 @@ discard block |
||
1458 | 1794 | function dol_set_user_param($db, $conf, &$user, $tab) |
1459 | 1795 | { |
1460 | 1796 | // Verification parametres |
1461 | - if (count($tab) < 1) return -1; |
|
1797 | + if (count($tab) < 1) { |
|
1798 | + return -1; |
|
1799 | + } |
|
1462 | 1800 | |
1463 | 1801 | $db->begin(); |
1464 | 1802 | |
@@ -1470,7 +1808,9 @@ discard block |
||
1470 | 1808 | $i=0; |
1471 | 1809 | foreach ($tab as $key => $value) |
1472 | 1810 | { |
1473 | - if ($i > 0) $sql.=','; |
|
1811 | + if ($i > 0) { |
|
1812 | + $sql.=','; |
|
1813 | + } |
|
1474 | 1814 | $sql.="'".$db->escape($key)."'"; |
1475 | 1815 | $i++; |
1476 | 1816 | } |
@@ -1504,8 +1844,7 @@ discard block |
||
1504 | 1844 | } |
1505 | 1845 | $user->conf->$key = $value; |
1506 | 1846 | //print "key=".$key." user->conf->key=".$user->conf->$key; |
1507 | - } |
|
1508 | - else |
|
1847 | + } else |
|
1509 | 1848 | { |
1510 | 1849 | unset($user->conf->$key); |
1511 | 1850 | } |
@@ -1528,8 +1867,7 @@ discard block |
||
1528 | 1867 | if ($reduction == 100) |
1529 | 1868 | { |
1530 | 1869 | $string = $langs->transnoentities("Offered"); |
1531 | - } |
|
1532 | - else |
|
1870 | + } else |
|
1533 | 1871 | { |
1534 | 1872 | $string = vatrate($reduction,true); |
1535 | 1873 | } |
@@ -1616,9 +1954,11 @@ discard block |
||
1616 | 1954 | |
1617 | 1955 | // If this generation module needs to scan a directory, then description field is filled |
1618 | 1956 | // with the constant that contains list of directories to scan (COMPANY_ADDON_PDF_ODT_PATH, ...). |
1619 | - if (! empty($obj->description)) // A list of directories to scan is defined |
|
1957 | + if (! empty($obj->description)) { |
|
1958 | + // A list of directories to scan is defined |
|
1620 | 1959 | { |
1621 | 1960 | include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
1961 | + } |
|
1622 | 1962 | |
1623 | 1963 | $const=$obj->description; |
1624 | 1964 | //irtoscan.=($dirtoscan?',':'').preg_replace('/[\r\n]+/',',',trim($conf->global->$const)); |
@@ -1637,7 +1977,9 @@ discard block |
||
1637 | 1977 | { |
1638 | 1978 | // all type of template is allowed |
1639 | 1979 | $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0); |
1640 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
1980 | + if (count($tmpfiles)) { |
|
1981 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
1982 | + } |
|
1641 | 1983 | } |
1642 | 1984 | } |
1643 | 1985 | |
@@ -1648,40 +1990,41 @@ discard block |
||
1648 | 1990 | $max=($maxfilenamelength?$maxfilenamelength:28); |
1649 | 1991 | $liste[$obj->id.':'.$record['fullname']]=dol_trunc($record['name'],$max,'middle'); |
1650 | 1992 | } |
1651 | - } |
|
1652 | - else |
|
1993 | + } else |
|
1653 | 1994 | { |
1654 | 1995 | $liste[0]=$obj->label.': '.$langs->trans("None"); |
1655 | 1996 | } |
1656 | - } |
|
1657 | - else |
|
1997 | + } else |
|
1658 | 1998 | { |
1659 | - if ($type == 'member' && $obj->lib == 'standard') // Special case, if member template, we add variant per format |
|
1999 | + if ($type == 'member' && $obj->lib == 'standard') { |
|
2000 | + // Special case, if member template, we add variant per format |
|
1660 | 2001 | { |
1661 | 2002 | global $_Avery_Labels; |
2003 | + } |
|
1662 | 2004 | include_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; |
1663 | 2005 | foreach($_Avery_Labels as $key => $val) |
1664 | 2006 | { |
1665 | 2007 | $liste[$obj->id.':'.$key]=($obj->label?$obj->label:$obj->lib).' '.$val['name']; |
1666 | 2008 | } |
1667 | - } |
|
1668 | - else // Common usage |
|
2009 | + } else // Common usage |
|
1669 | 2010 | { |
1670 | 2011 | $liste[$obj->id]=$obj->label?$obj->label:$obj->lib; |
1671 | 2012 | } |
1672 | 2013 | } |
1673 | 2014 | $i++; |
1674 | 2015 | } |
1675 | - } |
|
1676 | - else |
|
2016 | + } else |
|
1677 | 2017 | { |
1678 | 2018 | dol_print_error($db); |
1679 | 2019 | return -1; |
1680 | 2020 | } |
1681 | 2021 | |
1682 | - if ($found) return $liste; |
|
1683 | - else return 0; |
|
1684 | -} |
|
2022 | + if ($found) { |
|
2023 | + return $liste; |
|
2024 | + } else { |
|
2025 | + return 0; |
|
2026 | + } |
|
2027 | + } |
|
1685 | 2028 | |
1686 | 2029 | /** |
1687 | 2030 | * This function evaluates a string that should be a valid IPv4 |
@@ -1696,10 +2039,14 @@ discard block |
||
1696 | 2039 | if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
1697 | 2040 | |
1698 | 2041 | // Then we test if it is a private range |
1699 | - if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) return 2; |
|
2042 | + if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) { |
|
2043 | + return 2; |
|
2044 | + } |
|
1700 | 2045 | |
1701 | 2046 | // Then we test if it is a reserved range |
1702 | - if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) return 0; |
|
2047 | + if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)) { |
|
2048 | + return 0; |
|
2049 | + } |
|
1703 | 2050 | |
1704 | 2051 | return 1; |
1705 | 2052 | } |
@@ -1752,8 +2099,7 @@ discard block |
||
1752 | 2099 | 'proxy_password' => $proxypass, |
1753 | 2100 | 'trace' => 1 |
1754 | 2101 | ); |
1755 | - } |
|
1756 | - else |
|
2102 | + } else |
|
1757 | 2103 | { |
1758 | 2104 | $params=array('connection_timeout'=>$timeout, |
1759 | 2105 | 'response_timeout'=>$response_timeout, |
@@ -1860,14 +2206,12 @@ discard block |
||
1860 | 2206 | $classname='FactureFournisseur'; |
1861 | 2207 | $classpath = 'fourn/class'; |
1862 | 2208 | $module='fournisseur'; |
1863 | - } |
|
1864 | - elseif ($objecttype == 'order_supplier') { |
|
2209 | + } elseif ($objecttype == 'order_supplier') { |
|
1865 | 2210 | $classfile = 'fournisseur.commande'; |
1866 | 2211 | $classname='CommandeFournisseur'; |
1867 | 2212 | $classpath = 'fourn/class'; |
1868 | 2213 | $module='fournisseur'; |
1869 | - } |
|
1870 | - elseif ($objecttype == 'stock') { |
|
2214 | + } elseif ($objecttype == 'stock') { |
|
1871 | 2215 | $classpath = 'product/stock/class'; |
1872 | 2216 | $classfile='entrepot'; |
1873 | 2217 | $classname='Entrepot'; |
@@ -1887,8 +2231,9 @@ discard block |
||
1887 | 2231 | $ret=$langs->trans('Deleted'); |
1888 | 2232 | } |
1889 | 2233 | unset($object); |
2234 | + } else { |
|
2235 | + dol_syslog("Class with classname ".$classname." is unknown even after the include", LOG_ERR); |
|
1890 | 2236 | } |
1891 | - else dol_syslog("Class with classname ".$classname." is unknown even after the include", LOG_ERR); |
|
1892 | 2237 | } |
1893 | 2238 | } |
1894 | 2239 | return $ret; |
@@ -1920,11 +2265,12 @@ discard block |
||
1920 | 2265 | { |
1921 | 2266 | $obj = $db->fetch_object($resql); |
1922 | 2267 | $listofid[]=$obj->rowid; |
1923 | - if ($obj->parent_id > 0) $listofparentid[$obj->rowid]=$obj->parent_id; |
|
2268 | + if ($obj->parent_id > 0) { |
|
2269 | + $listofparentid[$obj->rowid]=$obj->parent_id; |
|
2270 | + } |
|
1924 | 2271 | $i++; |
1925 | 2272 | } |
1926 | - } |
|
1927 | - else |
|
2273 | + } else |
|
1928 | 2274 | { |
1929 | 2275 | dol_print_error($db); |
1930 | 2276 | } |
@@ -1959,9 +2305,11 @@ discard block |
||
1959 | 2305 | while ($cursor > 0) |
1960 | 2306 | { |
1961 | 2307 | $arrayidparsed[$cursor]=1; |
1962 | - if ($arrayidparsed[$listofparentid[$cursor]]) // We detect a loop. A record with a parent that was already into child |
|
2308 | + if ($arrayidparsed[$listofparentid[$cursor]]) { |
|
2309 | + // We detect a loop. A record with a parent that was already into child |
|
1963 | 2310 | { |
1964 | 2311 | print 'Found a loop between id '.$id.' - '.$cursor.'<br>'; |
2312 | + } |
|
1965 | 2313 | unset($arrayidparsed); |
1966 | 2314 | $listofidtoclean[$cursor]=$id; |
1967 | 2315 | break; |
@@ -1969,7 +2317,9 @@ discard block |
||
1969 | 2317 | $cursor=$listofparentid[$cursor]; |
1970 | 2318 | } |
1971 | 2319 | |
1972 | - if (count($listofidtoclean)) break; |
|
2320 | + if (count($listofidtoclean)) { |
|
2321 | + break; |
|
2322 | + } |
|
1973 | 2323 | } |
1974 | 2324 | |
1975 | 2325 | $sql = "UPDATE ".MAIN_DB_PREFIX.$tabletocleantree; |
@@ -2116,9 +2466,15 @@ discard block |
||
2116 | 2466 | $classfile='fournisseur.facture'; |
2117 | 2467 | } |
2118 | 2468 | |
2119 | - if (!isset($classfile)) $classfile = strtolower($subelement); |
|
2120 | - if (!isset($classname)) $classname = ucfirst($subelement); |
|
2121 | - if (!isset($classpath)) $classpath = $module.'/class'; |
|
2469 | + if (!isset($classfile)) { |
|
2470 | + $classfile = strtolower($subelement); |
|
2471 | + } |
|
2472 | + if (!isset($classname)) { |
|
2473 | + $classname = ucfirst($subelement); |
|
2474 | + } |
|
2475 | + if (!isset($classpath)) { |
|
2476 | + $classpath = $module.'/class'; |
|
2477 | + } |
|
2122 | 2478 | |
2123 | 2479 | $element_properties = array( |
2124 | 2480 | 'module' => $module, |
@@ -2172,8 +2528,12 @@ discard block |
||
2172 | 2528 | */ |
2173 | 2529 | function colorArrayToHex($arraycolor,$colorifnotfound='888888') |
2174 | 2530 | { |
2175 | - if (! is_array($arraycolor)) return $colorifnotfound; |
|
2176 | - if (empty($arraycolor)) return $colorifnotfound; |
|
2531 | + if (! is_array($arraycolor)) { |
|
2532 | + return $colorifnotfound; |
|
2533 | + } |
|
2534 | + if (empty($arraycolor)) { |
|
2535 | + return $colorifnotfound; |
|
2536 | + } |
|
2177 | 2537 | return sprintf("%02s",dechex($arraycolor[0])).sprintf("%02s",dechex($arraycolor[1])).sprintf("%02s",dechex($arraycolor[2])); |
2178 | 2538 | } |
2179 | 2539 | |
@@ -2189,12 +2549,17 @@ discard block |
||
2189 | 2549 | */ |
2190 | 2550 | function colorStringToArray($stringcolor,$colorifnotfound=array(88,88,88)) |
2191 | 2551 | { |
2192 | - if (is_array($stringcolor)) return $stringcolor; // If already into correct output format, we return as is |
|
2552 | + if (is_array($stringcolor)) { |
|
2553 | + return $stringcolor; |
|
2554 | + } |
|
2555 | + // If already into correct output format, we return as is |
|
2193 | 2556 | $tmp=preg_match('/^#?([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])$/',$stringcolor,$reg); |
2194 | 2557 | if (! $tmp) |
2195 | 2558 | { |
2196 | 2559 | $tmp=explode(',',$stringcolor); |
2197 | - if (count($tmp) < 3) return $colorifnotfound; |
|
2560 | + if (count($tmp) < 3) { |
|
2561 | + return $colorifnotfound; |
|
2562 | + } |
|
2198 | 2563 | return $tmp; |
2199 | 2564 | } |
2200 | 2565 | return array(hexdec($reg[1]),hexdec($reg[2]),hexdec($reg[3])); |
@@ -2240,69 +2605,51 @@ discard block |
||
2240 | 2605 | function getModuleDirForApiClass($module) |
2241 | 2606 | { |
2242 | 2607 | $moduledirforclass=$module; |
2243 | - if ($moduledirforclass != 'api') $moduledirforclass = preg_replace('/api$/i','',$moduledirforclass); |
|
2608 | + if ($moduledirforclass != 'api') { |
|
2609 | + $moduledirforclass = preg_replace('/api$/i','',$moduledirforclass); |
|
2610 | + } |
|
2244 | 2611 | |
2245 | 2612 | if ($module == 'contracts') { |
2246 | 2613 | $moduledirforclass = 'contrat'; |
2247 | - } |
|
2248 | - elseif (in_array($module, array('admin', 'login', 'setup', 'access', 'status', 'tools', 'documents'))) { |
|
2614 | + } elseif (in_array($module, array('admin', 'login', 'setup', 'access', 'status', 'tools', 'documents'))) { |
|
2249 | 2615 | $moduledirforclass = 'api'; |
2250 | - } |
|
2251 | - elseif ($module == 'contact' || $module == 'contacts' || $module == 'customer' || $module == 'thirdparty' || $module == 'thirdparties') { |
|
2616 | + } elseif ($module == 'contact' || $module == 'contacts' || $module == 'customer' || $module == 'thirdparty' || $module == 'thirdparties') { |
|
2252 | 2617 | $moduledirforclass = 'societe'; |
2253 | - } |
|
2254 | - elseif ($module == 'propale' || $module == 'proposals') { |
|
2618 | + } elseif ($module == 'propale' || $module == 'proposals') { |
|
2255 | 2619 | $moduledirforclass = 'comm/propal'; |
2256 | - } |
|
2257 | - elseif ($module == 'agenda' || $module == 'agendaevents') { |
|
2620 | + } elseif ($module == 'agenda' || $module == 'agendaevents') { |
|
2258 | 2621 | $moduledirforclass = 'comm/action'; |
2259 | - } |
|
2260 | - elseif ($module == 'adherent' || $module == 'members' || $module == 'memberstypes' || $module == 'subscriptions') { |
|
2622 | + } elseif ($module == 'adherent' || $module == 'members' || $module == 'memberstypes' || $module == 'subscriptions') { |
|
2261 | 2623 | $moduledirforclass = 'adherents'; |
2262 | - } |
|
2263 | - elseif ($module == 'banque' || $module == 'bankaccounts') { |
|
2624 | + } elseif ($module == 'banque' || $module == 'bankaccounts') { |
|
2264 | 2625 | $moduledirforclass = 'compta/bank'; |
2265 | - } |
|
2266 | - elseif ($module == 'category' || $module == 'categorie') { |
|
2626 | + } elseif ($module == 'category' || $module == 'categorie') { |
|
2267 | 2627 | $moduledirforclass = 'categories'; |
2268 | - } |
|
2269 | - elseif ($module == 'order' || $module == 'orders') { |
|
2628 | + } elseif ($module == 'order' || $module == 'orders') { |
|
2270 | 2629 | $moduledirforclass = 'commande'; |
2271 | - } |
|
2272 | - elseif ($module == 'shipments') { |
|
2630 | + } elseif ($module == 'shipments') { |
|
2273 | 2631 | $moduledirforclass = 'expedition'; |
2274 | - } |
|
2275 | - elseif ($module == 'facture' || $module == 'invoice' || $module == 'invoices') { |
|
2632 | + } elseif ($module == 'facture' || $module == 'invoice' || $module == 'invoices') { |
|
2276 | 2633 | $moduledirforclass = 'compta/facture'; |
2277 | - } |
|
2278 | - elseif ($module == 'products') { |
|
2634 | + } elseif ($module == 'products') { |
|
2279 | 2635 | $moduledirforclass = 'product'; |
2280 | - } |
|
2281 | - elseif ($module == 'project' || $module == 'projects' || $module == 'tasks') { |
|
2636 | + } elseif ($module == 'project' || $module == 'projects' || $module == 'tasks') { |
|
2282 | 2637 | $moduledirforclass = 'projet'; |
2283 | - } |
|
2284 | - elseif ($module == 'task') { |
|
2638 | + } elseif ($module == 'task') { |
|
2285 | 2639 | $moduledirforclass = 'projet'; |
2286 | - } |
|
2287 | - elseif ($module == 'stock' || $module == 'stockmovements' || $module == 'warehouses') { |
|
2640 | + } elseif ($module == 'stock' || $module == 'stockmovements' || $module == 'warehouses') { |
|
2288 | 2641 | $moduledirforclass = 'product/stock'; |
2289 | - } |
|
2290 | - elseif ($module == 'supplierproposals' || $module == 'supplierproposal' || $module == 'supplier_proposal') { |
|
2642 | + } elseif ($module == 'supplierproposals' || $module == 'supplierproposal' || $module == 'supplier_proposal') { |
|
2291 | 2643 | $moduledirforclass = 'supplier_proposal'; |
2292 | - } |
|
2293 | - elseif ($module == 'fournisseur' || $module == 'supplierinvoices' || $module == 'supplierorders') { |
|
2644 | + } elseif ($module == 'fournisseur' || $module == 'supplierinvoices' || $module == 'supplierorders') { |
|
2294 | 2645 | $moduledirforclass = 'fourn'; |
2295 | - } |
|
2296 | - elseif ($module == 'expensereports') { |
|
2646 | + } elseif ($module == 'expensereports') { |
|
2297 | 2647 | $moduledirforclass = 'expensereport'; |
2298 | - } |
|
2299 | - elseif ($module == 'users') { |
|
2648 | + } elseif ($module == 'users') { |
|
2300 | 2649 | $moduledirforclass = 'user'; |
2301 | - } |
|
2302 | - elseif ($module == 'ficheinter' || $module == 'interventions') { |
|
2650 | + } elseif ($module == 'ficheinter' || $module == 'interventions') { |
|
2303 | 2651 | $moduledirforclass = 'fichinter'; |
2304 | - } |
|
2305 | - elseif ($module == 'tickets') { |
|
2652 | + } elseif ($module == 'tickets') { |
|
2306 | 2653 | $moduledirforclass = 'ticket'; |
2307 | 2654 | } |
2308 | 2655 |
@@ -29,29 +29,29 @@ discard block |
||
29 | 29 | */ |
30 | 30 | function stock_prepare_head($object) |
31 | 31 | { |
32 | - global $langs, $conf; |
|
32 | + global $langs, $conf; |
|
33 | 33 | |
34 | - $h = 0; |
|
35 | - $head = array(); |
|
34 | + $h = 0; |
|
35 | + $head = array(); |
|
36 | 36 | |
37 | - $head[$h][0] = DOL_URL_ROOT.'/product/stock/card.php?id='.$object->id; |
|
38 | - $head[$h][1] = $langs->trans("Card"); |
|
39 | - $head[$h][2] = 'card'; |
|
40 | - $h++; |
|
37 | + $head[$h][0] = DOL_URL_ROOT.'/product/stock/card.php?id='.$object->id; |
|
38 | + $head[$h][1] = $langs->trans("Card"); |
|
39 | + $head[$h][2] = 'card'; |
|
40 | + $h++; |
|
41 | 41 | |
42 | - $head[$h][0] = DOL_URL_ROOT.'/product/stock/movement_list.php?id='.$object->id; |
|
43 | - $head[$h][1] = $langs->trans("StockMovements"); |
|
44 | - $head[$h][2] = 'movements'; |
|
45 | - $h++; |
|
42 | + $head[$h][0] = DOL_URL_ROOT.'/product/stock/movement_list.php?id='.$object->id; |
|
43 | + $head[$h][1] = $langs->trans("StockMovements"); |
|
44 | + $head[$h][2] = 'movements'; |
|
45 | + $h++; |
|
46 | 46 | |
47 | - /* |
|
47 | + /* |
|
48 | 48 | $head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche-valo.php?id='.$object->id; |
49 | 49 | $head[$h][1] = $langs->trans("EnhancedValue"); |
50 | 50 | $head[$h][2] = 'value'; |
51 | 51 | $h++; |
52 | 52 | */ |
53 | 53 | |
54 | - /* Disabled because will never be implemented. Table always empty. |
|
54 | + /* Disabled because will never be implemented. Table always empty. |
|
55 | 55 | if (! empty($conf->global->STOCK_USE_WAREHOUSE_BY_USER)) |
56 | 56 | { |
57 | 57 | // Should not be enabled by defaut because does not work yet correctly because |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | complete_head_from_modules($conf,$langs,$object,$head,$h,'stock'); |
71 | 71 | |
72 | 72 | $head[$h][0] = DOL_URL_ROOT.'/product/stock/info.php?id='.$object->id; |
73 | - $head[$h][1] = $langs->trans("Info"); |
|
74 | - $head[$h][2] = 'info'; |
|
75 | - $h++; |
|
73 | + $head[$h][1] = $langs->trans("Info"); |
|
74 | + $head[$h][2] = 'info'; |
|
75 | + $h++; |
|
76 | 76 | |
77 | 77 | complete_head_from_modules($conf,$langs,$object,$head,$h,'stock','remove'); |
78 | 78 |
@@ -67,14 +67,14 @@ |
||
67 | 67 | // Entries must be declared in modules descriptor with line |
68 | 68 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
69 | 69 | // $this->tabs = array('entity:-tabname); to remove a tab |
70 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'stock'); |
|
70 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'stock'); |
|
71 | 71 | |
72 | 72 | $head[$h][0] = DOL_URL_ROOT.'/product/stock/info.php?id='.$object->id; |
73 | 73 | $head[$h][1] = $langs->trans("Info"); |
74 | 74 | $head[$h][2] = 'info'; |
75 | 75 | $h++; |
76 | 76 | |
77 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'stock','remove'); |
|
77 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'stock', 'remove'); |
|
78 | 78 | |
79 | 79 | return $head; |
80 | 80 | } |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | function salaries_prepare_head($object) |
28 | 28 | { |
29 | 29 | |
30 | - global $db, $langs, $conf; |
|
30 | + global $db, $langs, $conf; |
|
31 | 31 | |
32 | - $h = 0; |
|
33 | - $head = array(); |
|
32 | + $h = 0; |
|
33 | + $head = array(); |
|
34 | 34 | |
35 | - $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/card.php?id='.$object->id; |
|
36 | - $head[$h][1] = $langs->trans("Card"); |
|
37 | - $head[$h][2] = 'card'; |
|
38 | - $h++; |
|
35 | + $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/card.php?id='.$object->id; |
|
36 | + $head[$h][1] = $langs->trans("Card"); |
|
37 | + $head[$h][2] = 'card'; |
|
38 | + $h++; |
|
39 | 39 | |
40 | 40 | // Show more tabs from modules |
41 | 41 | // Entries must be declared in modules descriptor with line |
@@ -43,23 +43,23 @@ discard block |
||
43 | 43 | // $this->tabs = array('entity:-tabname); to remove a tab |
44 | 44 | complete_head_from_modules($conf,$langs,$object,$head,$h,'salaries'); |
45 | 45 | |
46 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
46 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
47 | 47 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
48 | - $upload_dir = $conf->salaries->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
49 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
48 | + $upload_dir = $conf->salaries->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
49 | + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
50 | 50 | $nbLinks=Link::count($db, $object->element, $object->id); |
51 | - $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/document.php?id='.$object->id; |
|
52 | - $head[$h][1] = $langs->trans('Documents'); |
|
53 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
54 | - $head[$h][2] = 'documents'; |
|
55 | - $h++; |
|
51 | + $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/document.php?id='.$object->id; |
|
52 | + $head[$h][1] = $langs->trans('Documents'); |
|
53 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
54 | + $head[$h][2] = 'documents'; |
|
55 | + $h++; |
|
56 | 56 | |
57 | - $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/info.php?id='.$object->id; |
|
58 | - $head[$h][1] = $langs->trans("Info"); |
|
59 | - $head[$h][2] = 'info'; |
|
60 | - $h++; |
|
57 | + $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/info.php?id='.$object->id; |
|
58 | + $head[$h][1] = $langs->trans("Info"); |
|
59 | + $head[$h][2] = 'info'; |
|
60 | + $h++; |
|
61 | 61 | |
62 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'salaries', 'remove'); |
|
62 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'salaries', 'remove'); |
|
63 | 63 | |
64 | - return $head; |
|
64 | + return $head; |
|
65 | 65 | } |
@@ -41,16 +41,16 @@ discard block |
||
41 | 41 | // Entries must be declared in modules descriptor with line |
42 | 42 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
43 | 43 | // $this->tabs = array('entity:-tabname); to remove a tab |
44 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'salaries'); |
|
44 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries'); |
|
45 | 45 | |
46 | 46 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
47 | 47 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
48 | - $upload_dir = $conf->salaries->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
49 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
50 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
48 | + $upload_dir = $conf->salaries->dir_output."/".dol_sanitizeFileName($object->ref); |
|
49 | + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
50 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
51 | 51 | $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/document.php?id='.$object->id; |
52 | 52 | $head[$h][1] = $langs->trans('Documents'); |
53 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
53 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
54 | 54 | $head[$h][2] = 'documents'; |
55 | 55 | $h++; |
56 | 56 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $head[$h][2] = 'info'; |
60 | 60 | $h++; |
61 | 61 | |
62 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'salaries', 'remove'); |
|
62 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'remove'); |
|
63 | 63 | |
64 | 64 | return $head; |
65 | 65 | } |
@@ -50,7 +50,9 @@ |
||
50 | 50 | $nbLinks=Link::count($db, $object->element, $object->id); |
51 | 51 | $head[$h][0] = DOL_URL_ROOT.'/compta/salaries/document.php?id='.$object->id; |
52 | 52 | $head[$h][1] = $langs->trans('Documents'); |
53 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
53 | + if (($nbFiles+$nbLinks) > 0) { |
|
54 | + $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
55 | + } |
|
54 | 56 | $head[$h][2] = 'documents'; |
55 | 57 | $h++; |
56 | 58 |
@@ -26,18 +26,18 @@ discard block |
||
26 | 26 | */ |
27 | 27 | function showOnlineSignatureUrl($type,$ref) |
28 | 28 | { |
29 | - global $conf, $langs; |
|
29 | + global $conf, $langs; |
|
30 | 30 | |
31 | - // Load translation files required by the page |
|
31 | + // Load translation files required by the page |
|
32 | 32 | $langs->loadLangs(array("payment","paybox")); |
33 | 33 | |
34 | - $servicename='Online'; |
|
34 | + $servicename='Online'; |
|
35 | 35 | |
36 | - $out = img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlineSignature",$servicename).'<br>'; |
|
37 | - $url = getOnlineSignatureUrl(0, $type, $ref); |
|
38 | - $out.= '<input type="text" id="onlinesignatureurl" class="quatrevingtpercent" value="'.$url.'">'; |
|
39 | - $out.= ajax_autoselect("onlinesignatureurl", 0); |
|
40 | - return $out; |
|
36 | + $out = img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlineSignature",$servicename).'<br>'; |
|
37 | + $url = getOnlineSignatureUrl(0, $type, $ref); |
|
38 | + $out.= '<input type="text" id="onlinesignatureurl" class="quatrevingtpercent" value="'.$url.'">'; |
|
39 | + $out.= ajax_autoselect("onlinesignatureurl", 0); |
|
40 | + return $out; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -51,45 +51,45 @@ discard block |
||
51 | 51 | */ |
52 | 52 | function getOnlineSignatureUrl($mode, $type, $ref='') |
53 | 53 | { |
54 | - global $conf, $db, $langs; |
|
54 | + global $conf, $db, $langs; |
|
55 | 55 | |
56 | - $ref=str_replace(' ','',$ref); |
|
57 | - $out=''; |
|
56 | + $ref=str_replace(' ','',$ref); |
|
57 | + $out=''; |
|
58 | 58 | |
59 | - if ($type == 'proposal') |
|
60 | - { |
|
61 | - $out=DOL_MAIN_URL_ROOT.'/public/onlinesign/newonlinesign.php?source=proposal&ref='.($mode?'<font color="#666666">':''); |
|
62 | - if ($mode == 1) $out.='proposal_ref'; |
|
63 | - if ($mode == 0) $out.=urlencode($ref); |
|
64 | - $out.=($mode?'</font>':''); |
|
65 | - if ($mode == 1) $out.='&hashp=<font color="#666666">hash_of_file</font>'; |
|
66 | - else |
|
67 | - { |
|
68 | - include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
69 | - $propaltmp=new Propal($db); |
|
70 | - $res = $propaltmp->fetch(0, $ref); |
|
71 | - if ($res <= 0) return 'FailedToGetProposal'; |
|
59 | + if ($type == 'proposal') |
|
60 | + { |
|
61 | + $out=DOL_MAIN_URL_ROOT.'/public/onlinesign/newonlinesign.php?source=proposal&ref='.($mode?'<font color="#666666">':''); |
|
62 | + if ($mode == 1) $out.='proposal_ref'; |
|
63 | + if ($mode == 0) $out.=urlencode($ref); |
|
64 | + $out.=($mode?'</font>':''); |
|
65 | + if ($mode == 1) $out.='&hashp=<font color="#666666">hash_of_file</font>'; |
|
66 | + else |
|
67 | + { |
|
68 | + include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
|
69 | + $propaltmp=new Propal($db); |
|
70 | + $res = $propaltmp->fetch(0, $ref); |
|
71 | + if ($res <= 0) return 'FailedToGetProposal'; |
|
72 | 72 | |
73 | - include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
|
74 | - $ecmfile=new EcmFiles($db); |
|
73 | + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
|
74 | + $ecmfile=new EcmFiles($db); |
|
75 | 75 | |
76 | - $ecmfile->fetch(0, '', $propaltmp->last_main_doc); |
|
76 | + $ecmfile->fetch(0, '', $propaltmp->last_main_doc); |
|
77 | 77 | |
78 | - $hashp=$ecmfile->share; |
|
79 | - if (empty($hashp)) |
|
80 | - { |
|
81 | - $out = $langs->trans("FeatureOnlineSignDisabled"); |
|
82 | - return $out; |
|
83 | - } |
|
84 | - else |
|
85 | - { |
|
86 | - $out.='&hashp='.$hashp; |
|
87 | - } |
|
88 | - } |
|
89 | - } |
|
78 | + $hashp=$ecmfile->share; |
|
79 | + if (empty($hashp)) |
|
80 | + { |
|
81 | + $out = $langs->trans("FeatureOnlineSignDisabled"); |
|
82 | + return $out; |
|
83 | + } |
|
84 | + else |
|
85 | + { |
|
86 | + $out.='&hashp='.$hashp; |
|
87 | + } |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | - // For multicompany |
|
92 | - if (! empty($out)) $out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities |
|
91 | + // For multicompany |
|
92 | + if (! empty($out)) $out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities |
|
93 | 93 | |
94 | - return $out; |
|
94 | + return $out; |
|
95 | 95 | } |
@@ -24,19 +24,19 @@ discard block |
||
24 | 24 | * @param string $ref Ref of object |
25 | 25 | * @return string Url string |
26 | 26 | */ |
27 | -function showOnlineSignatureUrl($type,$ref) |
|
27 | +function showOnlineSignatureUrl($type, $ref) |
|
28 | 28 | { |
29 | 29 | global $conf, $langs; |
30 | 30 | |
31 | 31 | // Load translation files required by the page |
32 | - $langs->loadLangs(array("payment","paybox")); |
|
32 | + $langs->loadLangs(array("payment", "paybox")); |
|
33 | 33 | |
34 | - $servicename='Online'; |
|
34 | + $servicename = 'Online'; |
|
35 | 35 | |
36 | - $out = img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlineSignature",$servicename).'<br>'; |
|
36 | + $out = img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlineSignature", $servicename).'<br>'; |
|
37 | 37 | $url = getOnlineSignatureUrl(0, $type, $ref); |
38 | - $out.= '<input type="text" id="onlinesignatureurl" class="quatrevingtpercent" value="'.$url.'">'; |
|
39 | - $out.= ajax_autoselect("onlinesignatureurl", 0); |
|
38 | + $out .= '<input type="text" id="onlinesignatureurl" class="quatrevingtpercent" value="'.$url.'">'; |
|
39 | + $out .= ajax_autoselect("onlinesignatureurl", 0); |
|
40 | 40 | return $out; |
41 | 41 | } |
42 | 42 | |
@@ -49,33 +49,33 @@ discard block |
||
49 | 49 | * @param string $ref Ref of object |
50 | 50 | * @return string Url string |
51 | 51 | */ |
52 | -function getOnlineSignatureUrl($mode, $type, $ref='') |
|
52 | +function getOnlineSignatureUrl($mode, $type, $ref = '') |
|
53 | 53 | { |
54 | 54 | global $conf, $db, $langs; |
55 | 55 | |
56 | - $ref=str_replace(' ','',$ref); |
|
57 | - $out=''; |
|
56 | + $ref = str_replace(' ', '', $ref); |
|
57 | + $out = ''; |
|
58 | 58 | |
59 | 59 | if ($type == 'proposal') |
60 | 60 | { |
61 | - $out=DOL_MAIN_URL_ROOT.'/public/onlinesign/newonlinesign.php?source=proposal&ref='.($mode?'<font color="#666666">':''); |
|
62 | - if ($mode == 1) $out.='proposal_ref'; |
|
63 | - if ($mode == 0) $out.=urlencode($ref); |
|
64 | - $out.=($mode?'</font>':''); |
|
65 | - if ($mode == 1) $out.='&hashp=<font color="#666666">hash_of_file</font>'; |
|
61 | + $out = DOL_MAIN_URL_ROOT.'/public/onlinesign/newonlinesign.php?source=proposal&ref='.($mode ? '<font color="#666666">' : ''); |
|
62 | + if ($mode == 1) $out .= 'proposal_ref'; |
|
63 | + if ($mode == 0) $out .= urlencode($ref); |
|
64 | + $out .= ($mode ? '</font>' : ''); |
|
65 | + if ($mode == 1) $out .= '&hashp=<font color="#666666">hash_of_file</font>'; |
|
66 | 66 | else |
67 | 67 | { |
68 | 68 | include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
69 | - $propaltmp=new Propal($db); |
|
69 | + $propaltmp = new Propal($db); |
|
70 | 70 | $res = $propaltmp->fetch(0, $ref); |
71 | 71 | if ($res <= 0) return 'FailedToGetProposal'; |
72 | 72 | |
73 | 73 | include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
74 | - $ecmfile=new EcmFiles($db); |
|
74 | + $ecmfile = new EcmFiles($db); |
|
75 | 75 | |
76 | 76 | $ecmfile->fetch(0, '', $propaltmp->last_main_doc); |
77 | 77 | |
78 | - $hashp=$ecmfile->share; |
|
78 | + $hashp = $ecmfile->share; |
|
79 | 79 | if (empty($hashp)) |
80 | 80 | { |
81 | 81 | $out = $langs->trans("FeatureOnlineSignDisabled"); |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | } |
84 | 84 | else |
85 | 85 | { |
86 | - $out.='&hashp='.$hashp; |
|
86 | + $out .= '&hashp='.$hashp; |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | 91 | // For multicompany |
92 | - if (! empty($out)) $out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities |
|
92 | + if (!empty($out)) $out .= "&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities |
|
93 | 93 | |
94 | 94 | return $out; |
95 | 95 | } |
@@ -59,16 +59,23 @@ discard block |
||
59 | 59 | if ($type == 'proposal') |
60 | 60 | { |
61 | 61 | $out=DOL_MAIN_URL_ROOT.'/public/onlinesign/newonlinesign.php?source=proposal&ref='.($mode?'<font color="#666666">':''); |
62 | - if ($mode == 1) $out.='proposal_ref'; |
|
63 | - if ($mode == 0) $out.=urlencode($ref); |
|
62 | + if ($mode == 1) { |
|
63 | + $out.='proposal_ref'; |
|
64 | + } |
|
65 | + if ($mode == 0) { |
|
66 | + $out.=urlencode($ref); |
|
67 | + } |
|
64 | 68 | $out.=($mode?'</font>':''); |
65 | - if ($mode == 1) $out.='&hashp=<font color="#666666">hash_of_file</font>'; |
|
66 | - else |
|
69 | + if ($mode == 1) { |
|
70 | + $out.='&hashp=<font color="#666666">hash_of_file</font>'; |
|
71 | + } else |
|
67 | 72 | { |
68 | 73 | include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
69 | 74 | $propaltmp=new Propal($db); |
70 | 75 | $res = $propaltmp->fetch(0, $ref); |
71 | - if ($res <= 0) return 'FailedToGetProposal'; |
|
76 | + if ($res <= 0) { |
|
77 | + return 'FailedToGetProposal'; |
|
78 | + } |
|
72 | 79 | |
73 | 80 | include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
74 | 81 | $ecmfile=new EcmFiles($db); |
@@ -80,8 +87,7 @@ discard block |
||
80 | 87 | { |
81 | 88 | $out = $langs->trans("FeatureOnlineSignDisabled"); |
82 | 89 | return $out; |
83 | - } |
|
84 | - else |
|
90 | + } else |
|
85 | 91 | { |
86 | 92 | $out.='&hashp='.$hashp; |
87 | 93 | } |
@@ -89,7 +95,10 @@ discard block |
||
89 | 95 | } |
90 | 96 | |
91 | 97 | // For multicompany |
92 | - if (! empty($out)) $out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities |
|
98 | + if (! empty($out)) { |
|
99 | + $out.="&entity=".$conf->entity; |
|
100 | + } |
|
101 | + // Check the entity because He may be the same reference in several entities |
|
93 | 102 | |
94 | 103 | return $out; |
95 | 104 | } |
@@ -67,27 +67,27 @@ discard block |
||
67 | 67 | |
68 | 68 | if ($object->courant != Account::TYPE_CASH) |
69 | 69 | { |
70 | - $nbReceipts=0; |
|
71 | - |
|
72 | - // List of all standing receipts |
|
73 | - $sql = "SELECT COUNT(DISTINCT(b.num_releve)) as nb"; |
|
74 | - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; |
|
75 | - $sql.= " WHERE b.fk_account = ".$object->id; |
|
76 | - |
|
77 | - $resql = $db->query($sql); |
|
78 | - if ($resql) |
|
79 | - { |
|
80 | - $obj = $db->fetch_object($resql); |
|
81 | - if ($obj) $nbReceipts = $obj->nb; |
|
82 | - $db->free($resql); |
|
83 | - } |
|
84 | - |
|
85 | - $head[$h][0] = DOL_URL_ROOT."/compta/bank/releve.php?account=".$object->id; |
|
86 | - $head[$h][1] = $langs->trans("AccountStatements"); |
|
87 | - if (($nbReceipts) > 0) $head[$h][1].= ' <span class="badge">'.($nbReceipts).'</span>'; |
|
88 | - $head[$h][2] = 'statement'; |
|
89 | - $h++; |
|
90 | - } |
|
70 | + $nbReceipts=0; |
|
71 | + |
|
72 | + // List of all standing receipts |
|
73 | + $sql = "SELECT COUNT(DISTINCT(b.num_releve)) as nb"; |
|
74 | + $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; |
|
75 | + $sql.= " WHERE b.fk_account = ".$object->id; |
|
76 | + |
|
77 | + $resql = $db->query($sql); |
|
78 | + if ($resql) |
|
79 | + { |
|
80 | + $obj = $db->fetch_object($resql); |
|
81 | + if ($obj) $nbReceipts = $obj->nb; |
|
82 | + $db->free($resql); |
|
83 | + } |
|
84 | + |
|
85 | + $head[$h][0] = DOL_URL_ROOT."/compta/bank/releve.php?account=".$object->id; |
|
86 | + $head[$h][1] = $langs->trans("AccountStatements"); |
|
87 | + if (($nbReceipts) > 0) $head[$h][1].= ' <span class="badge">'.($nbReceipts).'</span>'; |
|
88 | + $head[$h][2] = 'statement'; |
|
89 | + $h++; |
|
90 | + } |
|
91 | 91 | |
92 | 92 | // Attached files |
93 | 93 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $head[$h][2] = 'document'; |
102 | 102 | $h++; |
103 | 103 | |
104 | - // Show more tabs from modules |
|
104 | + // Show more tabs from modules |
|
105 | 105 | // Entries must be declared in modules descriptor with line |
106 | 106 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
107 | 107 | // $this->tabs = array('entity:-tabname); to remove a tab |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $head[$h][2] = 'info'; |
113 | 113 | $h++;*/ |
114 | 114 | |
115 | - complete_head_from_modules($conf, $langs, $object, $head, $h, 'bank', 'remove'); |
|
115 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'bank', 'remove'); |
|
116 | 116 | |
117 | 117 | return $head; |
118 | 118 | } |
@@ -124,14 +124,14 @@ discard block |
||
124 | 124 | */ |
125 | 125 | function bank_admin_prepare_head($object) |
126 | 126 | { |
127 | - global $langs, $conf, $user; |
|
128 | - $h = 0; |
|
129 | - $head = array(); |
|
127 | + global $langs, $conf, $user; |
|
128 | + $h = 0; |
|
129 | + $head = array(); |
|
130 | 130 | |
131 | - $head[$h][0] = DOL_URL_ROOT . '/admin/bank.php'; |
|
132 | - $head[$h][1] = $langs->trans("Miscellaneous"); |
|
133 | - $head[$h][2] = 'general'; |
|
134 | - $h++; |
|
131 | + $head[$h][0] = DOL_URL_ROOT . '/admin/bank.php'; |
|
132 | + $head[$h][1] = $langs->trans("Miscellaneous"); |
|
133 | + $head[$h][2] = 'general'; |
|
134 | + $h++; |
|
135 | 135 | |
136 | 136 | $head[$h][0] = DOL_URL_ROOT . '/admin/chequereceipts.php'; |
137 | 137 | $head[$h][1] = $langs->trans("CheckReceiptShort"); |
@@ -139,20 +139,20 @@ discard block |
||
139 | 139 | $h++; |
140 | 140 | |
141 | 141 | |
142 | - // Show more tabs from modules |
|
143 | - // Entries must be declared in modules descriptor with line |
|
144 | - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
145 | - // $this->tabs = array('entity:-tabname); to remove a tab |
|
146 | - complete_head_from_modules($conf, $langs, $object, $head, $h, 'bank_admin'); |
|
142 | + // Show more tabs from modules |
|
143 | + // Entries must be declared in modules descriptor with line |
|
144 | + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
|
145 | + // $this->tabs = array('entity:-tabname); to remove a tab |
|
146 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'bank_admin'); |
|
147 | 147 | |
148 | - $head[$h][0] = DOL_URL_ROOT.'/admin/bank_extrafields.php'; |
|
149 | - $head[$h][1] = $langs->trans("ExtraFields"); |
|
150 | - $head[$h][2] = 'attributes'; |
|
151 | - $h++; |
|
148 | + $head[$h][0] = DOL_URL_ROOT.'/admin/bank_extrafields.php'; |
|
149 | + $head[$h][1] = $langs->trans("ExtraFields"); |
|
150 | + $head[$h][2] = 'attributes'; |
|
151 | + $h++; |
|
152 | 152 | |
153 | - complete_head_from_modules($conf, $langs, $object, $head, $h, 'bank_admin', 'remove'); |
|
153 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'bank_admin', 'remove'); |
|
154 | 154 | |
155 | - return $head; |
|
155 | + return $head; |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -164,15 +164,15 @@ discard block |
||
164 | 164 | function various_payment_prepare_head($object) |
165 | 165 | { |
166 | 166 | |
167 | - global $db, $langs, $conf; |
|
167 | + global $db, $langs, $conf; |
|
168 | 168 | |
169 | - $h = 0; |
|
170 | - $head = array(); |
|
169 | + $h = 0; |
|
170 | + $head = array(); |
|
171 | 171 | |
172 | - $head[$h][0] = DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$object->id; |
|
173 | - $head[$h][1] = $langs->trans("Card"); |
|
174 | - $head[$h][2] = 'card'; |
|
175 | - $h++; |
|
172 | + $head[$h][0] = DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$object->id; |
|
173 | + $head[$h][1] = $langs->trans("Card"); |
|
174 | + $head[$h][2] = 'card'; |
|
175 | + $h++; |
|
176 | 176 | |
177 | 177 | // Show more tabs from modules |
178 | 178 | // Entries must be declared in modules descriptor with line |
@@ -180,25 +180,25 @@ discard block |
||
180 | 180 | // $this->tabs = array('entity:-tabname); to remove a tab |
181 | 181 | complete_head_from_modules($conf,$langs,$object,$head,$h,'various_payment'); |
182 | 182 | |
183 | - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
183 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
184 | 184 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
185 | - $upload_dir = $conf->banque->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
186 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
185 | + $upload_dir = $conf->banque->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
186 | + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
187 | 187 | $nbLinks=Link::count($db, $object->element, $object->id); |
188 | - $head[$h][0] = DOL_URL_ROOT.'/compta/bank/various_payment/document.php?id='.$object->id; |
|
189 | - $head[$h][1] = $langs->trans('Documents'); |
|
190 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
191 | - $head[$h][2] = 'documents'; |
|
192 | - $h++; |
|
188 | + $head[$h][0] = DOL_URL_ROOT.'/compta/bank/various_payment/document.php?id='.$object->id; |
|
189 | + $head[$h][1] = $langs->trans('Documents'); |
|
190 | + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
191 | + $head[$h][2] = 'documents'; |
|
192 | + $h++; |
|
193 | 193 | |
194 | - $head[$h][0] = DOL_URL_ROOT.'/compta/bank/various_payment/info.php?id='.$object->id; |
|
195 | - $head[$h][1] = $langs->trans("Info"); |
|
196 | - $head[$h][2] = 'info'; |
|
197 | - $h++; |
|
194 | + $head[$h][0] = DOL_URL_ROOT.'/compta/bank/various_payment/info.php?id='.$object->id; |
|
195 | + $head[$h][1] = $langs->trans("Info"); |
|
196 | + $head[$h][2] = 'info'; |
|
197 | + $h++; |
|
198 | 198 | |
199 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'various_payment', 'remove'); |
|
199 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'various_payment', 'remove'); |
|
200 | 200 | |
201 | - return $head; |
|
201 | + return $head; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -37,42 +37,42 @@ discard block |
||
37 | 37 | $h = 0; |
38 | 38 | $head = array(); |
39 | 39 | |
40 | - $head[$h][0] = DOL_URL_ROOT . '/compta/bank/card.php?id=' . $object->id; |
|
40 | + $head[$h][0] = DOL_URL_ROOT.'/compta/bank/card.php?id='.$object->id; |
|
41 | 41 | $head[$h][1] = $langs->trans("Card"); |
42 | 42 | $head[$h][2] = 'bankname'; |
43 | 43 | $h++; |
44 | 44 | |
45 | - $head[$h][0] = DOL_URL_ROOT . "/compta/bank/bankentries_list.php?id=" . $object->id; |
|
45 | + $head[$h][0] = DOL_URL_ROOT."/compta/bank/bankentries_list.php?id=".$object->id; |
|
46 | 46 | $head[$h][1] = $langs->trans("BankTransactions"); |
47 | 47 | $head[$h][2] = 'journal'; |
48 | 48 | $h++; |
49 | 49 | |
50 | 50 | // if ($conf->global->MAIN_FEATURES_LEVEL >= 1) |
51 | 51 | // { |
52 | - $head[$h][0] = DOL_URL_ROOT . "/compta/bank/treso.php?account=" . $object->id; |
|
52 | + $head[$h][0] = DOL_URL_ROOT."/compta/bank/treso.php?account=".$object->id; |
|
53 | 53 | $head[$h][1] = $langs->trans("PlannedTransactions"); |
54 | 54 | $head[$h][2] = 'cash'; |
55 | 55 | $h++; |
56 | 56 | // } |
57 | 57 | |
58 | - $head[$h][0] = DOL_URL_ROOT . "/compta/bank/annuel.php?account=" . $object->id; |
|
58 | + $head[$h][0] = DOL_URL_ROOT."/compta/bank/annuel.php?account=".$object->id; |
|
59 | 59 | $head[$h][1] = $langs->trans("IOMonthlyReporting"); |
60 | 60 | $head[$h][2] = 'annual'; |
61 | 61 | $h++; |
62 | 62 | |
63 | - $head[$h][0] = DOL_URL_ROOT . "/compta/bank/graph.php?account=" . $object->id; |
|
63 | + $head[$h][0] = DOL_URL_ROOT."/compta/bank/graph.php?account=".$object->id; |
|
64 | 64 | $head[$h][1] = $langs->trans("Graph"); |
65 | 65 | $head[$h][2] = 'graph'; |
66 | 66 | $h++; |
67 | 67 | |
68 | 68 | if ($object->courant != Account::TYPE_CASH) |
69 | 69 | { |
70 | - $nbReceipts=0; |
|
70 | + $nbReceipts = 0; |
|
71 | 71 | |
72 | 72 | // List of all standing receipts |
73 | 73 | $sql = "SELECT COUNT(DISTINCT(b.num_releve)) as nb"; |
74 | - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; |
|
75 | - $sql.= " WHERE b.fk_account = ".$object->id; |
|
74 | + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; |
|
75 | + $sql .= " WHERE b.fk_account = ".$object->id; |
|
76 | 76 | |
77 | 77 | $resql = $db->query($sql); |
78 | 78 | if ($resql) |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | $head[$h][0] = DOL_URL_ROOT."/compta/bank/releve.php?account=".$object->id; |
86 | 86 | $head[$h][1] = $langs->trans("AccountStatements"); |
87 | - if (($nbReceipts) > 0) $head[$h][1].= ' <span class="badge">'.($nbReceipts).'</span>'; |
|
87 | + if (($nbReceipts) > 0) $head[$h][1] .= ' <span class="badge">'.($nbReceipts).'</span>'; |
|
88 | 88 | $head[$h][2] = 'statement'; |
89 | 89 | $h++; |
90 | 90 | } |
@@ -92,12 +92,12 @@ discard block |
||
92 | 92 | // Attached files |
93 | 93 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
94 | 94 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
95 | - $upload_dir = $conf->bank->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
96 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
97 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
98 | - $head[$h][0] = DOL_URL_ROOT . "/compta/bank/document.php?account=" . $object->id; |
|
95 | + $upload_dir = $conf->bank->dir_output."/".dol_sanitizeFileName($object->ref); |
|
96 | + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
97 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
98 | + $head[$h][0] = DOL_URL_ROOT."/compta/bank/document.php?account=".$object->id; |
|
99 | 99 | $head[$h][1] = $langs->trans("Documents"); |
100 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
100 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
101 | 101 | $head[$h][2] = 'document'; |
102 | 102 | $h++; |
103 | 103 | |
@@ -128,12 +128,12 @@ discard block |
||
128 | 128 | $h = 0; |
129 | 129 | $head = array(); |
130 | 130 | |
131 | - $head[$h][0] = DOL_URL_ROOT . '/admin/bank.php'; |
|
131 | + $head[$h][0] = DOL_URL_ROOT.'/admin/bank.php'; |
|
132 | 132 | $head[$h][1] = $langs->trans("Miscellaneous"); |
133 | 133 | $head[$h][2] = 'general'; |
134 | 134 | $h++; |
135 | 135 | |
136 | - $head[$h][0] = DOL_URL_ROOT . '/admin/chequereceipts.php'; |
|
136 | + $head[$h][0] = DOL_URL_ROOT.'/admin/chequereceipts.php'; |
|
137 | 137 | $head[$h][1] = $langs->trans("CheckReceiptShort"); |
138 | 138 | $head[$h][2] = 'checkreceipts'; |
139 | 139 | $h++; |
@@ -178,16 +178,16 @@ discard block |
||
178 | 178 | // Entries must be declared in modules descriptor with line |
179 | 179 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
180 | 180 | // $this->tabs = array('entity:-tabname); to remove a tab |
181 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'various_payment'); |
|
181 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'various_payment'); |
|
182 | 182 | |
183 | 183 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
184 | 184 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
185 | - $upload_dir = $conf->banque->dir_output . "/" . dol_sanitizeFileName($object->ref); |
|
186 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
187 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
185 | + $upload_dir = $conf->banque->dir_output."/".dol_sanitizeFileName($object->ref); |
|
186 | + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
187 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
188 | 188 | $head[$h][0] = DOL_URL_ROOT.'/compta/bank/various_payment/document.php?id='.$object->id; |
189 | 189 | $head[$h][1] = $langs->trans('Documents'); |
190 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
190 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
191 | 191 | $head[$h][2] = 'documents'; |
192 | 192 | $h++; |
193 | 193 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $head[$h][2] = 'info'; |
197 | 197 | $h++; |
198 | 198 | |
199 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'various_payment', 'remove'); |
|
199 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'various_payment', 'remove'); |
|
200 | 200 | |
201 | 201 | return $head; |
202 | 202 | } |
@@ -252,12 +252,12 @@ discard block |
||
252 | 252 | if (empty($account->cle)) |
253 | 253 | $account->cle = $account->cle_rib; |
254 | 254 | |
255 | - dol_syslog("bank.lib::checkBanForAccount account->code_banque=" . $account->code_banque . " account->code_guichet=" . $account->code_guichet . " account->number=" . $account->number . " account->cle=" . $account->cle . " account->iban=" . $account->iban . " country_code=" . $country_code, LOG_DEBUG); |
|
255 | + dol_syslog("bank.lib::checkBanForAccount account->code_banque=".$account->code_banque." account->code_guichet=".$account->code_guichet." account->number=".$account->number." account->cle=".$account->cle." account->iban=".$account->iban." country_code=".$country_code, LOG_DEBUG); |
|
256 | 256 | |
257 | 257 | if ($country_code == 'FR') { // France rules |
258 | 258 | $coef = array(62, 34, 3); |
259 | 259 | // Concatenation des differents codes. |
260 | - $rib = strtolower(trim($account->code_banque) . trim($account->code_guichet) . trim($account->number) . trim($account->cle)); |
|
260 | + $rib = strtolower(trim($account->code_banque).trim($account->code_guichet).trim($account->number).trim($account->cle)); |
|
261 | 261 | // On remplace les eventuelles lettres par des chiffres. |
262 | 262 | //$rib = strtr($rib, "abcdefghijklmnopqrstuvwxyz","12345678912345678912345678"); //Ne marche pas |
263 | 263 | $rib = strtr($rib, "abcdefghijklmnopqrstuvwxyz", "12345678912345678923456789"); |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | |
283 | 283 | if ($country_code == 'ES') { // Spanish rules |
284 | 284 | $CCC = strtolower(trim($account->number)); |
285 | - $rib = strtolower(trim($account->code_banque) . trim($account->code_guichet)); |
|
285 | + $rib = strtolower(trim($account->code_banque).trim($account->code_guichet)); |
|
286 | 286 | $cle_rib = strtolower(checkES($rib, $CCC)); |
287 | 287 | if ($cle_rib == strtolower($account->cle)) { |
288 | 288 | return true; |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | return $keycontrol; |
325 | 325 | } |
326 | 326 | |
327 | - $ccc = $IentOfi . $InumCta; |
|
327 | + $ccc = $IentOfi.$InumCta; |
|
328 | 328 | $numbers = "1234567890"; |
329 | 329 | |
330 | 330 | $i = 0; |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | $sum = 0; |
357 | 357 | |
358 | 358 | for ($i = 0; $i < 11; $i++) { |
359 | - $sum += $values[$i] * (int) substr($InumCta, $i, 1);//int to cast result of substr to a number |
|
359 | + $sum += $values[$i] * (int) substr($InumCta, $i, 1); //int to cast result of substr to a number |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | $key = 11 - $sum % 11; |
@@ -78,13 +78,17 @@ discard block |
||
78 | 78 | if ($resql) |
79 | 79 | { |
80 | 80 | $obj = $db->fetch_object($resql); |
81 | - if ($obj) $nbReceipts = $obj->nb; |
|
81 | + if ($obj) { |
|
82 | + $nbReceipts = $obj->nb; |
|
83 | + } |
|
82 | 84 | $db->free($resql); |
83 | 85 | } |
84 | 86 | |
85 | 87 | $head[$h][0] = DOL_URL_ROOT."/compta/bank/releve.php?account=".$object->id; |
86 | 88 | $head[$h][1] = $langs->trans("AccountStatements"); |
87 | - if (($nbReceipts) > 0) $head[$h][1].= ' <span class="badge">'.($nbReceipts).'</span>'; |
|
89 | + if (($nbReceipts) > 0) { |
|
90 | + $head[$h][1].= ' <span class="badge">'.($nbReceipts).'</span>'; |
|
91 | + } |
|
88 | 92 | $head[$h][2] = 'statement'; |
89 | 93 | $h++; |
90 | 94 | } |
@@ -97,7 +101,9 @@ discard block |
||
97 | 101 | $nbLinks=Link::count($db, $object->element, $object->id); |
98 | 102 | $head[$h][0] = DOL_URL_ROOT . "/compta/bank/document.php?account=" . $object->id; |
99 | 103 | $head[$h][1] = $langs->trans("Documents"); |
100 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
104 | + if (($nbFiles+$nbLinks) > 0) { |
|
105 | + $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
106 | + } |
|
101 | 107 | $head[$h][2] = 'document'; |
102 | 108 | $h++; |
103 | 109 | |
@@ -187,7 +193,9 @@ discard block |
||
187 | 193 | $nbLinks=Link::count($db, $object->element, $object->id); |
188 | 194 | $head[$h][0] = DOL_URL_ROOT.'/compta/bank/various_payment/document.php?id='.$object->id; |
189 | 195 | $head[$h][1] = $langs->trans('Documents'); |
190 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
196 | + if (($nbFiles+$nbLinks) > 0) { |
|
197 | + $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
198 | + } |
|
191 | 199 | $head[$h][2] = 'documents'; |
192 | 200 | $h++; |
193 | 201 | |
@@ -230,9 +238,12 @@ discard block |
||
230 | 238 | $iban = new IBAN($account->iban); |
231 | 239 | $check = $iban->Verify(); |
232 | 240 | |
233 | - if ($check) return true; |
|
234 | - else return false; |
|
235 | -} |
|
241 | + if ($check) { |
|
242 | + return true; |
|
243 | + } else { |
|
244 | + return false; |
|
245 | + } |
|
246 | + } |
|
236 | 247 | |
237 | 248 | /** |
238 | 249 | * Check account number informations for a bank account |
@@ -247,10 +258,12 @@ discard block |
||
247 | 258 | // For compatibility between |
248 | 259 | // account of type CompanyBankAccount class (we use number, cle_rib) |
249 | 260 | // account of type Account class (we use num_compte, cle) |
250 | - if (empty($account->number)) |
|
251 | - $account->number = $account->num_compte; |
|
252 | - if (empty($account->cle)) |
|
253 | - $account->cle = $account->cle_rib; |
|
261 | + if (empty($account->number)) { |
|
262 | + $account->number = $account->num_compte; |
|
263 | + } |
|
264 | + if (empty($account->cle)) { |
|
265 | + $account->cle = $account->cle_rib; |
|
266 | + } |
|
254 | 267 | |
255 | 268 | dol_syslog("bank.lib::checkBanForAccount account->code_banque=" . $account->code_banque . " account->code_guichet=" . $account->code_guichet . " account->number=" . $account->number . " account->cle=" . $account->cle . " account->iban=" . $account->iban . " country_code=" . $country_code, LOG_DEBUG); |
256 | 269 | |
@@ -290,12 +303,17 @@ discard block |
||
290 | 303 | return false; |
291 | 304 | } |
292 | 305 | if ($country_code == 'AU') { // Australian |
293 | - if (strlen($account->code_banque) > 7) |
|
294 | - return false; // Sould be 6 but can be 123-456 |
|
295 | - else if (strlen($account->code_banque) < 6) |
|
296 | - return false; // Sould be 6 |
|
297 | - else |
|
298 | - return true; |
|
306 | + if (strlen($account->code_banque) > 7) { |
|
307 | + return false; |
|
308 | + } |
|
309 | + // Sould be 6 but can be 123-456 |
|
310 | + else if (strlen($account->code_banque) < 6) { |
|
311 | + return false; |
|
312 | + } |
|
313 | + // Sould be 6 |
|
314 | + else { |
|
315 | + return true; |
|
316 | + } |
|
299 | 317 | } |
300 | 318 | |
301 | 319 | // No particular rule |
@@ -346,10 +364,12 @@ discard block |
||
346 | 364 | |
347 | 365 | $key = 11 - $sum % 11; |
348 | 366 | |
349 | - if ($key == 10) |
|
350 | - $key = 1; |
|
351 | - if ($key == 11) |
|
352 | - $key = 0; |
|
367 | + if ($key == 10) { |
|
368 | + $key = 1; |
|
369 | + } |
|
370 | + if ($key == 11) { |
|
371 | + $key = 0; |
|
372 | + } |
|
353 | 373 | |
354 | 374 | $keycontrol = $key; |
355 | 375 | |
@@ -361,10 +381,12 @@ discard block |
||
361 | 381 | |
362 | 382 | $key = 11 - $sum % 11; |
363 | 383 | |
364 | - if ($key == 10) |
|
365 | - $key = 1; |
|
366 | - if ($key == 11) |
|
367 | - $key = 0; |
|
384 | + if ($key == 10) { |
|
385 | + $key = 1; |
|
386 | + } |
|
387 | + if ($key == 11) { |
|
388 | + $key = 0; |
|
389 | + } |
|
368 | 390 | |
369 | 391 | $keycontrol .= $key; |
370 | 392 | return $keycontrol; |
@@ -29,28 +29,28 @@ |
||
29 | 29 | */ |
30 | 30 | function fiscalyear_prepare_head(Fiscalyear $object) |
31 | 31 | { |
32 | - global $langs, $conf; |
|
32 | + global $langs, $conf; |
|
33 | 33 | |
34 | - $h = 0; |
|
35 | - $head = array(); |
|
34 | + $h = 0; |
|
35 | + $head = array(); |
|
36 | 36 | |
37 | - $head[$h][0] = DOL_URL_ROOT . '/accountancy/admin/fiscalyear_card.php?id=' . $object->id; |
|
38 | - $head[$h][1] = $langs->trans("Card"); |
|
39 | - $head[$h][2] = 'card'; |
|
40 | - $h++; |
|
37 | + $head[$h][0] = DOL_URL_ROOT . '/accountancy/admin/fiscalyear_card.php?id=' . $object->id; |
|
38 | + $head[$h][1] = $langs->trans("Card"); |
|
39 | + $head[$h][2] = 'card'; |
|
40 | + $h++; |
|
41 | 41 | |
42 | - // Show more tabs from modules |
|
43 | - // Entries must be declared in modules descriptor with line |
|
42 | + // Show more tabs from modules |
|
43 | + // Entries must be declared in modules descriptor with line |
|
44 | 44 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
45 | 45 | // $this->tabs = array('entity:-tabname); to remove a tab |
46 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'fiscalyear'); |
|
46 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'fiscalyear'); |
|
47 | 47 | |
48 | - $head[$h][0] = DOL_URL_ROOT . '/accountancy/admin/fiscalyear_info.php?id=' . $object->id; |
|
49 | - $head[$h][1] = $langs->trans("Info"); |
|
50 | - $head[$h][2] = 'info'; |
|
51 | - $h++; |
|
48 | + $head[$h][0] = DOL_URL_ROOT . '/accountancy/admin/fiscalyear_info.php?id=' . $object->id; |
|
49 | + $head[$h][1] = $langs->trans("Info"); |
|
50 | + $head[$h][2] = 'info'; |
|
51 | + $h++; |
|
52 | 52 | |
53 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'fiscalyear','remove'); |
|
53 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'fiscalyear','remove'); |
|
54 | 54 | |
55 | - return $head; |
|
55 | + return $head; |
|
56 | 56 | } |
57 | 57 | \ No newline at end of file |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $h = 0; |
35 | 35 | $head = array(); |
36 | 36 | |
37 | - $head[$h][0] = DOL_URL_ROOT . '/accountancy/admin/fiscalyear_card.php?id=' . $object->id; |
|
37 | + $head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/fiscalyear_card.php?id='.$object->id; |
|
38 | 38 | $head[$h][1] = $langs->trans("Card"); |
39 | 39 | $head[$h][2] = 'card'; |
40 | 40 | $h++; |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | // Entries must be declared in modules descriptor with line |
44 | 44 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
45 | 45 | // $this->tabs = array('entity:-tabname); to remove a tab |
46 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'fiscalyear'); |
|
46 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'fiscalyear'); |
|
47 | 47 | |
48 | - $head[$h][0] = DOL_URL_ROOT . '/accountancy/admin/fiscalyear_info.php?id=' . $object->id; |
|
48 | + $head[$h][0] = DOL_URL_ROOT.'/accountancy/admin/fiscalyear_info.php?id='.$object->id; |
|
49 | 49 | $head[$h][1] = $langs->trans("Info"); |
50 | 50 | $head[$h][2] = 'info'; |
51 | 51 | $h++; |
52 | 52 | |
53 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'fiscalyear','remove'); |
|
53 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'fiscalyear', 'remove'); |
|
54 | 54 | |
55 | 55 | return $head; |
56 | 56 | } |
57 | 57 | \ No newline at end of file |
@@ -31,140 +31,140 @@ |
||
31 | 31 | */ |
32 | 32 | function dol_ch_controle_bvrb($bvrb) |
33 | 33 | { |
34 | - // Init array for control |
|
35 | - $tableau[0][0]=0; |
|
36 | - $tableau[0][1]=9; |
|
37 | - $tableau[0][2]=4; |
|
38 | - $tableau[0][3]=6; |
|
39 | - $tableau[0][4]=8; |
|
40 | - $tableau[0][5]=2; |
|
41 | - $tableau[0][6]=7; |
|
42 | - $tableau[0][7]=1; |
|
43 | - $tableau[0][8]=3; |
|
44 | - $tableau[0][9]=5; |
|
45 | - $tableau[0][10]=0; |
|
46 | - |
|
47 | - $tableau[1][0]=9; |
|
48 | - $tableau[1][1]=4; |
|
49 | - $tableau[1][2]=6; |
|
50 | - $tableau[1][3]=8; |
|
51 | - $tableau[1][4]=2; |
|
52 | - $tableau[1][5]=7; |
|
53 | - $tableau[1][6]=1; |
|
54 | - $tableau[1][7]=3; |
|
55 | - $tableau[1][8]=5; |
|
56 | - $tableau[1][9]=0; |
|
57 | - $tableau[1][10]=9; |
|
58 | - |
|
59 | - $tableau[2][0]=4; |
|
60 | - $tableau[2][1]=6; |
|
61 | - $tableau[2][2]=8; |
|
62 | - $tableau[2][3]=2; |
|
63 | - $tableau[2][4]=7; |
|
64 | - $tableau[2][5]=1; |
|
65 | - $tableau[2][6]=3; |
|
66 | - $tableau[2][7]=5; |
|
67 | - $tableau[2][8]=0; |
|
68 | - $tableau[2][9]=9; |
|
69 | - $tableau[2][10]=8; |
|
70 | - |
|
71 | - $tableau[3][0]=6; |
|
72 | - $tableau[3][1]=8; |
|
73 | - $tableau[3][2]=2; |
|
74 | - $tableau[3][3]=7; |
|
75 | - $tableau[3][4]=1; |
|
76 | - $tableau[3][5]=3; |
|
77 | - $tableau[3][6]=5; |
|
78 | - $tableau[3][7]=0; |
|
79 | - $tableau[3][8]=9; |
|
80 | - $tableau[3][9]=4; |
|
81 | - $tableau[3][10]=7; |
|
82 | - |
|
83 | - $tableau[4][0]=8; |
|
84 | - $tableau[4][1]=2; |
|
85 | - $tableau[4][2]=7; |
|
86 | - $tableau[4][3]=1; |
|
87 | - $tableau[4][4]=3; |
|
88 | - $tableau[4][5]=5; |
|
89 | - $tableau[4][6]=0; |
|
90 | - $tableau[4][7]=9; |
|
91 | - $tableau[4][8]=4; |
|
92 | - $tableau[4][9]=6; |
|
93 | - $tableau[4][10]=6; |
|
94 | - |
|
95 | - $tableau[5][0]=2; |
|
96 | - $tableau[5][1]=7; |
|
97 | - $tableau[5][2]=1; |
|
98 | - $tableau[5][3]=3; |
|
99 | - $tableau[5][4]=5; |
|
100 | - $tableau[5][5]=0; |
|
101 | - $tableau[5][6]=9; |
|
102 | - $tableau[5][7]=4; |
|
103 | - $tableau[5][8]=6; |
|
104 | - $tableau[5][9]=8; |
|
105 | - $tableau[5][10]=5; |
|
106 | - |
|
107 | - $tableau[6][0]=7; |
|
108 | - $tableau[6][1]=1; |
|
109 | - $tableau[6][2]=3; |
|
110 | - $tableau[6][3]=5; |
|
111 | - $tableau[6][4]=0; |
|
112 | - $tableau[6][5]=9; |
|
113 | - $tableau[6][6]=4; |
|
114 | - $tableau[6][7]=6; |
|
115 | - $tableau[6][8]=8; |
|
116 | - $tableau[6][9]=2; |
|
117 | - $tableau[6][10]=4; |
|
118 | - |
|
119 | - $tableau[7][0]=1; |
|
120 | - $tableau[7][1]=3; |
|
121 | - $tableau[7][2]=5; |
|
122 | - $tableau[7][3]=0; |
|
123 | - $tableau[7][4]=9; |
|
124 | - $tableau[7][5]=4; |
|
125 | - $tableau[7][6]=6; |
|
126 | - $tableau[7][7]=8; |
|
127 | - $tableau[7][8]=2; |
|
128 | - $tableau[7][9]=7; |
|
129 | - $tableau[7][10]=3; |
|
130 | - |
|
131 | - $tableau[8][0]=3; |
|
132 | - $tableau[8][1]=5; |
|
133 | - $tableau[8][2]=0; |
|
134 | - $tableau[8][3]=9; |
|
135 | - $tableau[8][4]=4; |
|
136 | - $tableau[8][5]=6; |
|
137 | - $tableau[8][6]=8; |
|
138 | - $tableau[8][7]=2; |
|
139 | - $tableau[8][8]=7; |
|
140 | - $tableau[8][9]=1; |
|
141 | - $tableau[8][10]=2; |
|
142 | - |
|
143 | - $tableau[9][0]=5; |
|
144 | - $tableau[9][1]=0; |
|
145 | - $tableau[9][2]=9; |
|
146 | - $tableau[9][3]=4; |
|
147 | - $tableau[9][4]=6; |
|
148 | - $tableau[9][5]=8; |
|
149 | - $tableau[9][6]=2; |
|
150 | - $tableau[9][7]=7; |
|
151 | - $tableau[9][8]=1; |
|
152 | - $tableau[9][9]=3; |
|
153 | - $tableau[9][10]=1; |
|
154 | - |
|
155 | - |
|
156 | - // Clean data |
|
157 | - $bv=str_replace(' ','',$bvrb); |
|
158 | - |
|
159 | - // Make control |
|
160 | - $report=0; |
|
161 | - while (dol_strlen($bv)>1) |
|
162 | - { |
|
163 | - $match=substr($bv,0,1); |
|
164 | - $report=$tableau[$report][$match]; |
|
165 | - $bv=substr($bv,1); |
|
166 | - } |
|
167 | - $controle=$tableau[$report][10]; |
|
168 | - |
|
169 | - return ($controle==$bv); |
|
34 | + // Init array for control |
|
35 | + $tableau[0][0]=0; |
|
36 | + $tableau[0][1]=9; |
|
37 | + $tableau[0][2]=4; |
|
38 | + $tableau[0][3]=6; |
|
39 | + $tableau[0][4]=8; |
|
40 | + $tableau[0][5]=2; |
|
41 | + $tableau[0][6]=7; |
|
42 | + $tableau[0][7]=1; |
|
43 | + $tableau[0][8]=3; |
|
44 | + $tableau[0][9]=5; |
|
45 | + $tableau[0][10]=0; |
|
46 | + |
|
47 | + $tableau[1][0]=9; |
|
48 | + $tableau[1][1]=4; |
|
49 | + $tableau[1][2]=6; |
|
50 | + $tableau[1][3]=8; |
|
51 | + $tableau[1][4]=2; |
|
52 | + $tableau[1][5]=7; |
|
53 | + $tableau[1][6]=1; |
|
54 | + $tableau[1][7]=3; |
|
55 | + $tableau[1][8]=5; |
|
56 | + $tableau[1][9]=0; |
|
57 | + $tableau[1][10]=9; |
|
58 | + |
|
59 | + $tableau[2][0]=4; |
|
60 | + $tableau[2][1]=6; |
|
61 | + $tableau[2][2]=8; |
|
62 | + $tableau[2][3]=2; |
|
63 | + $tableau[2][4]=7; |
|
64 | + $tableau[2][5]=1; |
|
65 | + $tableau[2][6]=3; |
|
66 | + $tableau[2][7]=5; |
|
67 | + $tableau[2][8]=0; |
|
68 | + $tableau[2][9]=9; |
|
69 | + $tableau[2][10]=8; |
|
70 | + |
|
71 | + $tableau[3][0]=6; |
|
72 | + $tableau[3][1]=8; |
|
73 | + $tableau[3][2]=2; |
|
74 | + $tableau[3][3]=7; |
|
75 | + $tableau[3][4]=1; |
|
76 | + $tableau[3][5]=3; |
|
77 | + $tableau[3][6]=5; |
|
78 | + $tableau[3][7]=0; |
|
79 | + $tableau[3][8]=9; |
|
80 | + $tableau[3][9]=4; |
|
81 | + $tableau[3][10]=7; |
|
82 | + |
|
83 | + $tableau[4][0]=8; |
|
84 | + $tableau[4][1]=2; |
|
85 | + $tableau[4][2]=7; |
|
86 | + $tableau[4][3]=1; |
|
87 | + $tableau[4][4]=3; |
|
88 | + $tableau[4][5]=5; |
|
89 | + $tableau[4][6]=0; |
|
90 | + $tableau[4][7]=9; |
|
91 | + $tableau[4][8]=4; |
|
92 | + $tableau[4][9]=6; |
|
93 | + $tableau[4][10]=6; |
|
94 | + |
|
95 | + $tableau[5][0]=2; |
|
96 | + $tableau[5][1]=7; |
|
97 | + $tableau[5][2]=1; |
|
98 | + $tableau[5][3]=3; |
|
99 | + $tableau[5][4]=5; |
|
100 | + $tableau[5][5]=0; |
|
101 | + $tableau[5][6]=9; |
|
102 | + $tableau[5][7]=4; |
|
103 | + $tableau[5][8]=6; |
|
104 | + $tableau[5][9]=8; |
|
105 | + $tableau[5][10]=5; |
|
106 | + |
|
107 | + $tableau[6][0]=7; |
|
108 | + $tableau[6][1]=1; |
|
109 | + $tableau[6][2]=3; |
|
110 | + $tableau[6][3]=5; |
|
111 | + $tableau[6][4]=0; |
|
112 | + $tableau[6][5]=9; |
|
113 | + $tableau[6][6]=4; |
|
114 | + $tableau[6][7]=6; |
|
115 | + $tableau[6][8]=8; |
|
116 | + $tableau[6][9]=2; |
|
117 | + $tableau[6][10]=4; |
|
118 | + |
|
119 | + $tableau[7][0]=1; |
|
120 | + $tableau[7][1]=3; |
|
121 | + $tableau[7][2]=5; |
|
122 | + $tableau[7][3]=0; |
|
123 | + $tableau[7][4]=9; |
|
124 | + $tableau[7][5]=4; |
|
125 | + $tableau[7][6]=6; |
|
126 | + $tableau[7][7]=8; |
|
127 | + $tableau[7][8]=2; |
|
128 | + $tableau[7][9]=7; |
|
129 | + $tableau[7][10]=3; |
|
130 | + |
|
131 | + $tableau[8][0]=3; |
|
132 | + $tableau[8][1]=5; |
|
133 | + $tableau[8][2]=0; |
|
134 | + $tableau[8][3]=9; |
|
135 | + $tableau[8][4]=4; |
|
136 | + $tableau[8][5]=6; |
|
137 | + $tableau[8][6]=8; |
|
138 | + $tableau[8][7]=2; |
|
139 | + $tableau[8][8]=7; |
|
140 | + $tableau[8][9]=1; |
|
141 | + $tableau[8][10]=2; |
|
142 | + |
|
143 | + $tableau[9][0]=5; |
|
144 | + $tableau[9][1]=0; |
|
145 | + $tableau[9][2]=9; |
|
146 | + $tableau[9][3]=4; |
|
147 | + $tableau[9][4]=6; |
|
148 | + $tableau[9][5]=8; |
|
149 | + $tableau[9][6]=2; |
|
150 | + $tableau[9][7]=7; |
|
151 | + $tableau[9][8]=1; |
|
152 | + $tableau[9][9]=3; |
|
153 | + $tableau[9][10]=1; |
|
154 | + |
|
155 | + |
|
156 | + // Clean data |
|
157 | + $bv=str_replace(' ','',$bvrb); |
|
158 | + |
|
159 | + // Make control |
|
160 | + $report=0; |
|
161 | + while (dol_strlen($bv)>1) |
|
162 | + { |
|
163 | + $match=substr($bv,0,1); |
|
164 | + $report=$tableau[$report][$match]; |
|
165 | + $bv=substr($bv,1); |
|
166 | + } |
|
167 | + $controle=$tableau[$report][10]; |
|
168 | + |
|
169 | + return ($controle==$bv); |
|
170 | 170 | } |
@@ -32,139 +32,139 @@ |
||
32 | 32 | function dol_ch_controle_bvrb($bvrb) |
33 | 33 | { |
34 | 34 | // Init array for control |
35 | - $tableau[0][0]=0; |
|
36 | - $tableau[0][1]=9; |
|
37 | - $tableau[0][2]=4; |
|
38 | - $tableau[0][3]=6; |
|
39 | - $tableau[0][4]=8; |
|
40 | - $tableau[0][5]=2; |
|
41 | - $tableau[0][6]=7; |
|
42 | - $tableau[0][7]=1; |
|
43 | - $tableau[0][8]=3; |
|
44 | - $tableau[0][9]=5; |
|
45 | - $tableau[0][10]=0; |
|
46 | - |
|
47 | - $tableau[1][0]=9; |
|
48 | - $tableau[1][1]=4; |
|
49 | - $tableau[1][2]=6; |
|
50 | - $tableau[1][3]=8; |
|
51 | - $tableau[1][4]=2; |
|
52 | - $tableau[1][5]=7; |
|
53 | - $tableau[1][6]=1; |
|
54 | - $tableau[1][7]=3; |
|
55 | - $tableau[1][8]=5; |
|
56 | - $tableau[1][9]=0; |
|
57 | - $tableau[1][10]=9; |
|
58 | - |
|
59 | - $tableau[2][0]=4; |
|
60 | - $tableau[2][1]=6; |
|
61 | - $tableau[2][2]=8; |
|
62 | - $tableau[2][3]=2; |
|
63 | - $tableau[2][4]=7; |
|
64 | - $tableau[2][5]=1; |
|
65 | - $tableau[2][6]=3; |
|
66 | - $tableau[2][7]=5; |
|
67 | - $tableau[2][8]=0; |
|
68 | - $tableau[2][9]=9; |
|
69 | - $tableau[2][10]=8; |
|
70 | - |
|
71 | - $tableau[3][0]=6; |
|
72 | - $tableau[3][1]=8; |
|
73 | - $tableau[3][2]=2; |
|
74 | - $tableau[3][3]=7; |
|
75 | - $tableau[3][4]=1; |
|
76 | - $tableau[3][5]=3; |
|
77 | - $tableau[3][6]=5; |
|
78 | - $tableau[3][7]=0; |
|
79 | - $tableau[3][8]=9; |
|
80 | - $tableau[3][9]=4; |
|
81 | - $tableau[3][10]=7; |
|
82 | - |
|
83 | - $tableau[4][0]=8; |
|
84 | - $tableau[4][1]=2; |
|
85 | - $tableau[4][2]=7; |
|
86 | - $tableau[4][3]=1; |
|
87 | - $tableau[4][4]=3; |
|
88 | - $tableau[4][5]=5; |
|
89 | - $tableau[4][6]=0; |
|
90 | - $tableau[4][7]=9; |
|
91 | - $tableau[4][8]=4; |
|
92 | - $tableau[4][9]=6; |
|
93 | - $tableau[4][10]=6; |
|
94 | - |
|
95 | - $tableau[5][0]=2; |
|
96 | - $tableau[5][1]=7; |
|
97 | - $tableau[5][2]=1; |
|
98 | - $tableau[5][3]=3; |
|
99 | - $tableau[5][4]=5; |
|
100 | - $tableau[5][5]=0; |
|
101 | - $tableau[5][6]=9; |
|
102 | - $tableau[5][7]=4; |
|
103 | - $tableau[5][8]=6; |
|
104 | - $tableau[5][9]=8; |
|
105 | - $tableau[5][10]=5; |
|
106 | - |
|
107 | - $tableau[6][0]=7; |
|
108 | - $tableau[6][1]=1; |
|
109 | - $tableau[6][2]=3; |
|
110 | - $tableau[6][3]=5; |
|
111 | - $tableau[6][4]=0; |
|
112 | - $tableau[6][5]=9; |
|
113 | - $tableau[6][6]=4; |
|
114 | - $tableau[6][7]=6; |
|
115 | - $tableau[6][8]=8; |
|
116 | - $tableau[6][9]=2; |
|
117 | - $tableau[6][10]=4; |
|
118 | - |
|
119 | - $tableau[7][0]=1; |
|
120 | - $tableau[7][1]=3; |
|
121 | - $tableau[7][2]=5; |
|
122 | - $tableau[7][3]=0; |
|
123 | - $tableau[7][4]=9; |
|
124 | - $tableau[7][5]=4; |
|
125 | - $tableau[7][6]=6; |
|
126 | - $tableau[7][7]=8; |
|
127 | - $tableau[7][8]=2; |
|
128 | - $tableau[7][9]=7; |
|
129 | - $tableau[7][10]=3; |
|
130 | - |
|
131 | - $tableau[8][0]=3; |
|
132 | - $tableau[8][1]=5; |
|
133 | - $tableau[8][2]=0; |
|
134 | - $tableau[8][3]=9; |
|
135 | - $tableau[8][4]=4; |
|
136 | - $tableau[8][5]=6; |
|
137 | - $tableau[8][6]=8; |
|
138 | - $tableau[8][7]=2; |
|
139 | - $tableau[8][8]=7; |
|
140 | - $tableau[8][9]=1; |
|
141 | - $tableau[8][10]=2; |
|
142 | - |
|
143 | - $tableau[9][0]=5; |
|
144 | - $tableau[9][1]=0; |
|
145 | - $tableau[9][2]=9; |
|
146 | - $tableau[9][3]=4; |
|
147 | - $tableau[9][4]=6; |
|
148 | - $tableau[9][5]=8; |
|
149 | - $tableau[9][6]=2; |
|
150 | - $tableau[9][7]=7; |
|
151 | - $tableau[9][8]=1; |
|
152 | - $tableau[9][9]=3; |
|
153 | - $tableau[9][10]=1; |
|
35 | + $tableau[0][0] = 0; |
|
36 | + $tableau[0][1] = 9; |
|
37 | + $tableau[0][2] = 4; |
|
38 | + $tableau[0][3] = 6; |
|
39 | + $tableau[0][4] = 8; |
|
40 | + $tableau[0][5] = 2; |
|
41 | + $tableau[0][6] = 7; |
|
42 | + $tableau[0][7] = 1; |
|
43 | + $tableau[0][8] = 3; |
|
44 | + $tableau[0][9] = 5; |
|
45 | + $tableau[0][10] = 0; |
|
46 | + |
|
47 | + $tableau[1][0] = 9; |
|
48 | + $tableau[1][1] = 4; |
|
49 | + $tableau[1][2] = 6; |
|
50 | + $tableau[1][3] = 8; |
|
51 | + $tableau[1][4] = 2; |
|
52 | + $tableau[1][5] = 7; |
|
53 | + $tableau[1][6] = 1; |
|
54 | + $tableau[1][7] = 3; |
|
55 | + $tableau[1][8] = 5; |
|
56 | + $tableau[1][9] = 0; |
|
57 | + $tableau[1][10] = 9; |
|
58 | + |
|
59 | + $tableau[2][0] = 4; |
|
60 | + $tableau[2][1] = 6; |
|
61 | + $tableau[2][2] = 8; |
|
62 | + $tableau[2][3] = 2; |
|
63 | + $tableau[2][4] = 7; |
|
64 | + $tableau[2][5] = 1; |
|
65 | + $tableau[2][6] = 3; |
|
66 | + $tableau[2][7] = 5; |
|
67 | + $tableau[2][8] = 0; |
|
68 | + $tableau[2][9] = 9; |
|
69 | + $tableau[2][10] = 8; |
|
70 | + |
|
71 | + $tableau[3][0] = 6; |
|
72 | + $tableau[3][1] = 8; |
|
73 | + $tableau[3][2] = 2; |
|
74 | + $tableau[3][3] = 7; |
|
75 | + $tableau[3][4] = 1; |
|
76 | + $tableau[3][5] = 3; |
|
77 | + $tableau[3][6] = 5; |
|
78 | + $tableau[3][7] = 0; |
|
79 | + $tableau[3][8] = 9; |
|
80 | + $tableau[3][9] = 4; |
|
81 | + $tableau[3][10] = 7; |
|
82 | + |
|
83 | + $tableau[4][0] = 8; |
|
84 | + $tableau[4][1] = 2; |
|
85 | + $tableau[4][2] = 7; |
|
86 | + $tableau[4][3] = 1; |
|
87 | + $tableau[4][4] = 3; |
|
88 | + $tableau[4][5] = 5; |
|
89 | + $tableau[4][6] = 0; |
|
90 | + $tableau[4][7] = 9; |
|
91 | + $tableau[4][8] = 4; |
|
92 | + $tableau[4][9] = 6; |
|
93 | + $tableau[4][10] = 6; |
|
94 | + |
|
95 | + $tableau[5][0] = 2; |
|
96 | + $tableau[5][1] = 7; |
|
97 | + $tableau[5][2] = 1; |
|
98 | + $tableau[5][3] = 3; |
|
99 | + $tableau[5][4] = 5; |
|
100 | + $tableau[5][5] = 0; |
|
101 | + $tableau[5][6] = 9; |
|
102 | + $tableau[5][7] = 4; |
|
103 | + $tableau[5][8] = 6; |
|
104 | + $tableau[5][9] = 8; |
|
105 | + $tableau[5][10] = 5; |
|
106 | + |
|
107 | + $tableau[6][0] = 7; |
|
108 | + $tableau[6][1] = 1; |
|
109 | + $tableau[6][2] = 3; |
|
110 | + $tableau[6][3] = 5; |
|
111 | + $tableau[6][4] = 0; |
|
112 | + $tableau[6][5] = 9; |
|
113 | + $tableau[6][6] = 4; |
|
114 | + $tableau[6][7] = 6; |
|
115 | + $tableau[6][8] = 8; |
|
116 | + $tableau[6][9] = 2; |
|
117 | + $tableau[6][10] = 4; |
|
118 | + |
|
119 | + $tableau[7][0] = 1; |
|
120 | + $tableau[7][1] = 3; |
|
121 | + $tableau[7][2] = 5; |
|
122 | + $tableau[7][3] = 0; |
|
123 | + $tableau[7][4] = 9; |
|
124 | + $tableau[7][5] = 4; |
|
125 | + $tableau[7][6] = 6; |
|
126 | + $tableau[7][7] = 8; |
|
127 | + $tableau[7][8] = 2; |
|
128 | + $tableau[7][9] = 7; |
|
129 | + $tableau[7][10] = 3; |
|
130 | + |
|
131 | + $tableau[8][0] = 3; |
|
132 | + $tableau[8][1] = 5; |
|
133 | + $tableau[8][2] = 0; |
|
134 | + $tableau[8][3] = 9; |
|
135 | + $tableau[8][4] = 4; |
|
136 | + $tableau[8][5] = 6; |
|
137 | + $tableau[8][6] = 8; |
|
138 | + $tableau[8][7] = 2; |
|
139 | + $tableau[8][8] = 7; |
|
140 | + $tableau[8][9] = 1; |
|
141 | + $tableau[8][10] = 2; |
|
142 | + |
|
143 | + $tableau[9][0] = 5; |
|
144 | + $tableau[9][1] = 0; |
|
145 | + $tableau[9][2] = 9; |
|
146 | + $tableau[9][3] = 4; |
|
147 | + $tableau[9][4] = 6; |
|
148 | + $tableau[9][5] = 8; |
|
149 | + $tableau[9][6] = 2; |
|
150 | + $tableau[9][7] = 7; |
|
151 | + $tableau[9][8] = 1; |
|
152 | + $tableau[9][9] = 3; |
|
153 | + $tableau[9][10] = 1; |
|
154 | 154 | |
155 | 155 | |
156 | 156 | // Clean data |
157 | - $bv=str_replace(' ','',$bvrb); |
|
157 | + $bv = str_replace(' ', '', $bvrb); |
|
158 | 158 | |
159 | 159 | // Make control |
160 | - $report=0; |
|
161 | - while (dol_strlen($bv)>1) |
|
160 | + $report = 0; |
|
161 | + while (dol_strlen($bv) > 1) |
|
162 | 162 | { |
163 | - $match=substr($bv,0,1); |
|
164 | - $report=$tableau[$report][$match]; |
|
165 | - $bv=substr($bv,1); |
|
163 | + $match = substr($bv, 0, 1); |
|
164 | + $report = $tableau[$report][$match]; |
|
165 | + $bv = substr($bv, 1); |
|
166 | 166 | } |
167 | - $controle=$tableau[$report][10]; |
|
167 | + $controle = $tableau[$report][10]; |
|
168 | 168 | |
169 | - return ($controle==$bv); |
|
169 | + return ($controle == $bv); |
|
170 | 170 | } |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | ); |
30 | 30 | if ($conf->global->MAIN_FEATURES_LEVEL >= 2) |
31 | 31 | { |
32 | - $supportedoauth2array['OAUTH_STRIPE_TEST_NAME']='stripetest'; |
|
33 | - $supportedoauth2array['OAUTH_STRIPE_LIVE_NAME']='stripelive'; |
|
32 | + $supportedoauth2array['OAUTH_STRIPE_TEST_NAME']='stripetest'; |
|
33 | + $supportedoauth2array['OAUTH_STRIPE_LIVE_NAME']='stripelive'; |
|
34 | 34 | } |
35 | 35 | $supportedoauth2array['OAUTH_GITHUB_NAME']='github'; |
36 | 36 | |
@@ -220,17 +220,17 @@ discard block |
||
220 | 220 | 'OAUTH_STRAVA_ID', |
221 | 221 | 'OAUTH_STRAVA_SECRET', |
222 | 222 | ), |
223 | - array( |
|
224 | - 'OAUTH_STRIPE_TEST_NAME', |
|
225 | - 'OAUTH_STRIPE_TEST_ID', |
|
226 | - 'STRIPE_TEST_SECRET_KEY', |
|
227 | - ), |
|
228 | - array( |
|
229 | - 'OAUTH_STRIPE_LIVE_NAME', |
|
230 | - 'OAUTH_STRIPE_LIVE_ID', |
|
231 | - 'STRIPE_LIVE_SECRET_KEY', |
|
232 | - ), |
|
233 | - array( |
|
223 | + array( |
|
224 | + 'OAUTH_STRIPE_TEST_NAME', |
|
225 | + 'OAUTH_STRIPE_TEST_ID', |
|
226 | + 'STRIPE_TEST_SECRET_KEY', |
|
227 | + ), |
|
228 | + array( |
|
229 | + 'OAUTH_STRIPE_LIVE_NAME', |
|
230 | + 'OAUTH_STRIPE_LIVE_ID', |
|
231 | + 'STRIPE_LIVE_SECRET_KEY', |
|
232 | + ), |
|
233 | + array( |
|
234 | 234 | 'OAUTH_TUMBLR_NAME', |
235 | 235 | 'OAUTH_TUMBLR_ID', |
236 | 236 | 'OAUTH_TUMBLR_SECRET', |
@@ -24,20 +24,20 @@ |
||
24 | 24 | |
25 | 25 | |
26 | 26 | // Supported OAUTH (a provider is supported when a file xxx_oauthcallback.php is available into htdocs/core/modules/oauth) |
27 | -$supportedoauth2array=array( |
|
27 | +$supportedoauth2array = array( |
|
28 | 28 | 'OAUTH_GOOGLE_NAME'=>'google', |
29 | 29 | ); |
30 | 30 | if ($conf->global->MAIN_FEATURES_LEVEL >= 2) |
31 | 31 | { |
32 | - $supportedoauth2array['OAUTH_STRIPE_TEST_NAME']='stripetest'; |
|
33 | - $supportedoauth2array['OAUTH_STRIPE_LIVE_NAME']='stripelive'; |
|
32 | + $supportedoauth2array['OAUTH_STRIPE_TEST_NAME'] = 'stripetest'; |
|
33 | + $supportedoauth2array['OAUTH_STRIPE_LIVE_NAME'] = 'stripelive'; |
|
34 | 34 | } |
35 | -$supportedoauth2array['OAUTH_GITHUB_NAME']='github'; |
|
35 | +$supportedoauth2array['OAUTH_GITHUB_NAME'] = 'github'; |
|
36 | 36 | |
37 | 37 | |
38 | 38 | |
39 | 39 | // API access parameters OAUTH |
40 | -$list = array ( |
|
40 | +$list = array( |
|
41 | 41 | array( |
42 | 42 | 'OAUTH_AMAZON_NAME', |
43 | 43 | 'OAUTH_AMAZON_ID', |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | */ |
30 | 30 | function holiday_prepare_head($object) |
31 | 31 | { |
32 | - global $db, $langs, $conf, $user; |
|
32 | + global $db, $langs, $conf, $user; |
|
33 | 33 | |
34 | - $h = 0; |
|
35 | - $head = array(); |
|
34 | + $h = 0; |
|
35 | + $head = array(); |
|
36 | 36 | |
37 | 37 | $head[$h][0] = DOL_URL_ROOT.'/holiday/card.php?id='.$object->id; |
38 | 38 | $head[$h][1] = $langs->trans("Card"); |
@@ -57,23 +57,23 @@ discard block |
||
57 | 57 | // $this->tabs = array('entity:-tabname); to remove a tab |
58 | 58 | complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday'); |
59 | 59 | |
60 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday','remove'); |
|
60 | + complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday','remove'); |
|
61 | 61 | |
62 | - return $head; |
|
62 | + return $head; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Return array head with list of tabs to view object informations |
68 | 68 | * |
69 | - * @return array head |
|
69 | + * @return array head |
|
70 | 70 | */ |
71 | 71 | function holiday_admin_prepare_head() |
72 | 72 | { |
73 | - global $db, $langs, $conf, $user; |
|
73 | + global $db, $langs, $conf, $user; |
|
74 | 74 | |
75 | - $h = 0; |
|
76 | - $head = array(); |
|
75 | + $h = 0; |
|
76 | + $head = array(); |
|
77 | 77 | |
78 | 78 | $head[$h][0] = DOL_URL_ROOT.'/admin/holiday.php'; |
79 | 79 | $head[$h][1] = $langs->trans("Setup"); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | // $this->tabs = array('entity:-tabname); to remove a tab |
87 | 87 | complete_head_from_modules($conf,$langs,null,$head,$h,'holiday_admin'); |
88 | 88 | |
89 | - complete_head_from_modules($conf,$langs,null,$head,$h,'holiday_admin','remove'); |
|
89 | + complete_head_from_modules($conf,$langs,null,$head,$h,'holiday_admin','remove'); |
|
90 | 90 | |
91 | - return $head; |
|
91 | + return $head; |
|
92 | 92 | } |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
44 | 44 | require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
45 | 45 | $upload_dir = $conf->holiday->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); |
46 | - $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); |
|
47 | - $nbLinks=Link::count($db, $object->element, $object->id); |
|
46 | + $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
|
47 | + $nbLinks = Link::count($db, $object->element, $object->id); |
|
48 | 48 | $head[$h][0] = DOL_URL_ROOT.'/holiday/document.php?id='.$object->id; |
49 | 49 | $head[$h][1] = $langs->trans('Documents'); |
50 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
50 | + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' <span class="badge">'.($nbFiles + $nbLinks).'</span>'; |
|
51 | 51 | $head[$h][2] = 'documents'; |
52 | 52 | $h++; |
53 | 53 | |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | // Entries must be declared in modules descriptor with line |
56 | 56 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
57 | 57 | // $this->tabs = array('entity:-tabname); to remove a tab |
58 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday'); |
|
58 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'holiday'); |
|
59 | 59 | |
60 | - complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday','remove'); |
|
60 | + complete_head_from_modules($conf, $langs, $object, $head, $h, 'holiday', 'remove'); |
|
61 | 61 | |
62 | 62 | return $head; |
63 | 63 | } |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | // Entries must be declared in modules descriptor with line |
85 | 85 | // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab |
86 | 86 | // $this->tabs = array('entity:-tabname); to remove a tab |
87 | - complete_head_from_modules($conf,$langs,null,$head,$h,'holiday_admin'); |
|
87 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'holiday_admin'); |
|
88 | 88 | |
89 | - complete_head_from_modules($conf,$langs,null,$head,$h,'holiday_admin','remove'); |
|
89 | + complete_head_from_modules($conf, $langs, null, $head, $h, 'holiday_admin', 'remove'); |
|
90 | 90 | |
91 | 91 | return $head; |
92 | 92 | } |
@@ -47,7 +47,9 @@ |
||
47 | 47 | $nbLinks=Link::count($db, $object->element, $object->id); |
48 | 48 | $head[$h][0] = DOL_URL_ROOT.'/holiday/document.php?id='.$object->id; |
49 | 49 | $head[$h][1] = $langs->trans('Documents'); |
50 | - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
50 | + if (($nbFiles+$nbLinks) > 0) { |
|
51 | + $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>'; |
|
52 | + } |
|
51 | 53 | $head[$h][2] = 'documents'; |
52 | 54 | $h++; |
53 | 55 |