@@ -212,8 +212,12 @@ discard block |
||
212 | 212 | |
213 | 213 | $this->db = $db; |
214 | 214 | |
215 | - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; |
|
216 | - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; |
|
215 | + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) { |
|
216 | + $this->fields['rowid']['visible'] = 0; |
|
217 | + } |
|
218 | + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) { |
|
219 | + $this->fields['entity']['enabled'] = 0; |
|
220 | + } |
|
217 | 221 | |
218 | 222 | // Unset fields that are disabled |
219 | 223 | foreach ($this->fields as $key => $val) |
@@ -473,7 +477,10 @@ discard block |
||
473 | 477 | { |
474 | 478 | global $conf, $langs, $hookmanager; |
475 | 479 | |
476 | - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips |
|
480 | + if (!empty($conf->dol_no_mouse_hover)) { |
|
481 | + $notooltip = 1; |
|
482 | + } |
|
483 | + // Force disable tooltips |
|
477 | 484 | |
478 | 485 | $result = ''; |
479 | 486 | |
@@ -512,15 +519,21 @@ discard block |
||
512 | 519 | $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
513 | 520 | if ($reshook > 0) $linkclose = $hookmanager->resPrint; |
514 | 521 | */ |
515 | - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); |
|
522 | + } else { |
|
523 | + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); |
|
524 | + } |
|
516 | 525 | |
517 | 526 | $linkstart = '<a href="'.$url.'"'; |
518 | 527 | $linkstart .= $linkclose.'>'; |
519 | 528 | $linkend = '</a>'; |
520 | 529 | |
521 | 530 | $result .= $linkstart; |
522 | - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
523 | - if ($withpicto != 2) $result .= $this->ref; |
|
531 | + if ($withpicto) { |
|
532 | + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
533 | + } |
|
534 | + if ($withpicto != 2) { |
|
535 | + $result .= $this->ref; |
|
536 | + } |
|
524 | 537 | $result .= $linkend; |
525 | 538 | //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); |
526 | 539 | |
@@ -528,8 +541,11 @@ discard block |
||
528 | 541 | $hookmanager->initHooks(array('emailcollectordao')); |
529 | 542 | $parameters = array('id'=>$this->id, 'getnomurl'=>$result); |
530 | 543 | $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
531 | - if ($reshook > 0) $result = $hookmanager->resPrint; |
|
532 | - else $result .= $hookmanager->resPrint; |
|
544 | + if ($reshook > 0) { |
|
545 | + $result = $hookmanager->resPrint; |
|
546 | + } else { |
|
547 | + $result .= $hookmanager->resPrint; |
|
548 | + } |
|
533 | 549 | |
534 | 550 | return $result; |
535 | 551 | } |
@@ -567,7 +583,9 @@ discard block |
||
567 | 583 | } |
568 | 584 | |
569 | 585 | $statusType = 'status5'; |
570 | - if ($status == self::STATUS_ENABLED) $statusType = 'status4'; |
|
586 | + if ($status == self::STATUS_ENABLED) { |
|
587 | + $statusType = 'status4'; |
|
588 | + } |
|
571 | 589 | |
572 | 590 | return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); |
573 | 591 | } |
@@ -661,7 +679,9 @@ discard block |
||
661 | 679 | $i++; |
662 | 680 | } |
663 | 681 | $this->db->free($resql); |
664 | - } else dol_print_error($this->db); |
|
682 | + } else { |
|
683 | + dol_print_error($this->db); |
|
684 | + } |
|
665 | 685 | |
666 | 686 | return 1; |
667 | 687 | } |
@@ -693,7 +713,9 @@ discard block |
||
693 | 713 | $i++; |
694 | 714 | } |
695 | 715 | $this->db->free($resql); |
696 | - } else dol_print_error($this->db); |
|
716 | + } else { |
|
717 | + dol_print_error($this->db); |
|
718 | + } |
|
697 | 719 | } |
698 | 720 | |
699 | 721 | |
@@ -710,11 +732,16 @@ discard block |
||
710 | 732 | |
711 | 733 | // Connect to IMAP |
712 | 734 | $flags = '/service=imap'; // IMAP |
713 | - if ($ssl) $flags .= '/ssl'; // '/tls' |
|
735 | + if ($ssl) { |
|
736 | + $flags .= '/ssl'; |
|
737 | + } |
|
738 | + // '/tls' |
|
714 | 739 | $flags .= '/novalidate-cert'; |
715 | 740 | //$flags.='/readonly'; |
716 | 741 | //$flags.='/debug'; |
717 | - if ($norsh || !empty($conf->global->IMPA_FORCE_NORSH)) $flags .= '/norsh'; |
|
742 | + if ($norsh || !empty($conf->global->IMPA_FORCE_NORSH)) { |
|
743 | + $flags .= '/norsh'; |
|
744 | + } |
|
718 | 745 | |
719 | 746 | $connectstringserver = '{'.$this->host.':993'.$flags.'}'; |
720 | 747 | |
@@ -770,7 +797,9 @@ discard block |
||
770 | 797 | dol_syslog("doCollect result = ".$result." for emailcollector->id = ".$emailcollector->id); |
771 | 798 | |
772 | 799 | $this->error .= 'EmailCollector ID '.$emailcollector->id.':'.$emailcollector->error.'<br>'; |
773 | - if (!empty($emailcollector->errors)) $this->error .= join('<br>', $emailcollector->errors); |
|
800 | + if (!empty($emailcollector->errors)) { |
|
801 | + $this->error .= join('<br>', $emailcollector->errors); |
|
802 | + } |
|
774 | 803 | $this->output .= 'EmailCollector ID '.$emailcollector->id.': '.$emailcollector->lastresult.'<br>'; |
775 | 804 | } |
776 | 805 | |
@@ -805,7 +834,10 @@ discard block |
||
805 | 834 | } else { |
806 | 835 | $tmpproperty = $tmparray[0]; |
807 | 836 | } |
808 | - if ($tmpclass && ($tmpclass != $object->element)) continue; // Property is for another type of object |
|
837 | + if ($tmpclass && ($tmpclass != $object->element)) { |
|
838 | + continue; |
|
839 | + } |
|
840 | + // Property is for another type of object |
|
809 | 841 | |
810 | 842 | //if (property_exists($object, $tmpproperty) || preg_match('/^options_/', $tmpproperty)) |
811 | 843 | if ($tmpproperty) |
@@ -827,16 +859,26 @@ discard block |
||
827 | 859 | } |
828 | 860 | if (!empty($sourcefield) && !empty($regexstring)) |
829 | 861 | { |
830 | - if (strtolower($sourcefield) == 'body') $sourcestring = $messagetext; |
|
831 | - elseif (strtolower($sourcefield) == 'subject') $sourcestring = $subject; |
|
832 | - elseif (strtolower($sourcefield) == 'header') $sourcestring = $header; |
|
862 | + if (strtolower($sourcefield) == 'body') { |
|
863 | + $sourcestring = $messagetext; |
|
864 | + } elseif (strtolower($sourcefield) == 'subject') { |
|
865 | + $sourcestring = $subject; |
|
866 | + } elseif (strtolower($sourcefield) == 'header') { |
|
867 | + $sourcestring = $header; |
|
868 | + } |
|
833 | 869 | |
834 | 870 | if ($sourcestring) |
835 | 871 | { |
836 | 872 | $regforval = array(); |
837 | 873 | $regexoptions = ''; |
838 | - if (strtolower($sourcefield) == 'body') $regexoptions = 'ms'; // The m means ^ and $ char is valid at each new line. The s means the char '.' is valid for new lines char too |
|
839 | - if (strtolower($sourcefield) == 'header') $regexoptions = 'm'; // The m means ^ and $ char is valid at each new line. |
|
874 | + if (strtolower($sourcefield) == 'body') { |
|
875 | + $regexoptions = 'ms'; |
|
876 | + } |
|
877 | + // The m means ^ and $ char is valid at each new line. The s means the char '.' is valid for new lines char too |
|
878 | + if (strtolower($sourcefield) == 'header') { |
|
879 | + $regexoptions = 'm'; |
|
880 | + } |
|
881 | + // The m means ^ and $ char is valid at each new line. |
|
840 | 882 | |
841 | 883 | //var_dump($tmpproperty.' - '.$regexstring.' - '.$regexoptions.' - '.$sourcestring); |
842 | 884 | if (preg_match('/'.$regexstring.'/'.$regexoptions, $sourcestring, $regforval)) |
@@ -862,8 +904,11 @@ discard block |
||
862 | 904 | } elseif (preg_match('/^(SET|SETIFEMPTY):(.*)$/', $valueforproperty, $regforregex)) |
863 | 905 | { |
864 | 906 | $valuecurrent = ''; |
865 | - if (preg_match('/^options_/', $tmpproperty)) $valuecurrent = $object->array_options[preg_replace('/^options_/', '', $tmpproperty)]; |
|
866 | - else $valuecurrent = $object->$tmpproperty; |
|
907 | + if (preg_match('/^options_/', $tmpproperty)) { |
|
908 | + $valuecurrent = $object->array_options[preg_replace('/^options_/', '', $tmpproperty)]; |
|
909 | + } else { |
|
910 | + $valuecurrent = $object->$tmpproperty; |
|
911 | + } |
|
867 | 912 | |
868 | 913 | if ($regforregex[1] == 'SET' || empty($valuecurrent)) |
869 | 914 | { |
@@ -872,13 +917,15 @@ discard block |
||
872 | 917 | $matcharray = array(); |
873 | 918 | preg_match_all('/__([a-z0-9]+(?:_[a-z0-9]+)?)__/i', $valuetouse, $matcharray); |
874 | 919 | //var_dump($tmpproperty.' - '.$object->$tmpproperty.' - '.$valuetouse); var_dump($matcharray); |
875 | - if (is_array($matcharray[1])) // $matcharray[1] is array with list of substitution key found without the __ |
|
920 | + if (is_array($matcharray[1])) { |
|
921 | + // $matcharray[1] is array with list of substitution key found without the __ |
|
876 | 922 | { |
877 | 923 | foreach ($matcharray[1] as $keytoreplace) |
878 | 924 | { |
879 | 925 | if ($keytoreplace && isset($object->$keytoreplace)) |
880 | 926 | { |
881 | 927 | $substitutionarray['__'.$keytoreplace.'__'] = $object->$keytoreplace; |
928 | + } |
|
882 | 929 | } |
883 | 930 | } |
884 | 931 | } |
@@ -886,8 +933,11 @@ discard block |
||
886 | 933 | dol_syslog(var_export($substitutionarray, true)); |
887 | 934 | //var_dump($substitutionarray); |
888 | 935 | $valuetouse = make_substitutions($valuetouse, $substitutionarray); |
889 | - if (preg_match('/^options_/', $tmpproperty)) $object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $valuetouse; |
|
890 | - else $object->$tmpproperty = $valuetouse; |
|
936 | + if (preg_match('/^options_/', $tmpproperty)) { |
|
937 | + $object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $valuetouse; |
|
938 | + } else { |
|
939 | + $object->$tmpproperty = $valuetouse; |
|
940 | + } |
|
891 | 941 | } |
892 | 942 | } else { |
893 | 943 | $errorforthisaction++; |
@@ -977,7 +1027,9 @@ discard block |
||
977 | 1027 | $searchfilterisnotanswer = 0; |
978 | 1028 | foreach ($this->filters as $rule) |
979 | 1029 | { |
980 | - if (empty($rule['status'])) continue; |
|
1030 | + if (empty($rule['status'])) { |
|
1031 | + continue; |
|
1032 | + } |
|
981 | 1033 | |
982 | 1034 | if ($rule['type'] == 'to') { |
983 | 1035 | $tmprulevaluearray = explode('*', $rule['rulevalue']); |
@@ -989,22 +1041,50 @@ discard block |
||
989 | 1041 | $search .= ($search ? ' ' : '').'TO "'.str_replace('"', '', $rule['rulevalue']).'"'; |
990 | 1042 | } |
991 | 1043 | } |
992 | - if ($rule['type'] == 'bcc') $search .= ($search ? ' ' : '').'BCC'; |
|
993 | - if ($rule['type'] == 'cc') $search .= ($search ? ' ' : '').'CC'; |
|
994 | - if ($rule['type'] == 'from') $search .= ($search ? ' ' : '').'FROM "'.str_replace('"', '', $rule['rulevalue']).'"'; |
|
995 | - if ($rule['type'] == 'subject') $search .= ($search ? ' ' : '').'SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"'; |
|
996 | - if ($rule['type'] == 'body') $search .= ($search ? ' ' : '').'BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; |
|
997 | - if ($rule['type'] == 'header') $search .= ($search ? ' ' : '').'HEADER '.$rule['rulevalue']; |
|
998 | - |
|
999 | - if ($rule['type'] == 'notinsubject') $search .= ($search ? ' ' : '').'SUBJECT NOT "'.str_replace('"', '', $rule['rulevalue']).'"'; |
|
1000 | - if ($rule['type'] == 'notinbody') $search .= ($search ? ' ' : '').'BODY NOT "'.str_replace('"', '', $rule['rulevalue']).'"'; |
|
1001 | - |
|
1002 | - if ($rule['type'] == 'seen') $search .= ($search ? ' ' : '').'SEEN'; |
|
1003 | - if ($rule['type'] == 'unseen') $search .= ($search ? ' ' : '').'UNSEEN'; |
|
1004 | - if ($rule['type'] == 'unanswered') $search .= ($search ? ' ' : '').'UNANSWERED'; |
|
1005 | - if ($rule['type'] == 'answered') $search .= ($search ? ' ' : '').'ANSWERED'; |
|
1006 | - if ($rule['type'] == 'smaller') $search .= ($search ? ' ' : '').'SMALLER "'.str_replace('"', '', $rule['rulevalue']).'"'; |
|
1007 | - if ($rule['type'] == 'larger') $search .= ($search ? ' ' : '').'LARGER "'.str_replace('"', '', $rule['rulevalue']).'"'; |
|
1044 | + if ($rule['type'] == 'bcc') { |
|
1045 | + $search .= ($search ? ' ' : '').'BCC'; |
|
1046 | + } |
|
1047 | + if ($rule['type'] == 'cc') { |
|
1048 | + $search .= ($search ? ' ' : '').'CC'; |
|
1049 | + } |
|
1050 | + if ($rule['type'] == 'from') { |
|
1051 | + $search .= ($search ? ' ' : '').'FROM "'.str_replace('"', '', $rule['rulevalue']).'"'; |
|
1052 | + } |
|
1053 | + if ($rule['type'] == 'subject') { |
|
1054 | + $search .= ($search ? ' ' : '').'SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"'; |
|
1055 | + } |
|
1056 | + if ($rule['type'] == 'body') { |
|
1057 | + $search .= ($search ? ' ' : '').'BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; |
|
1058 | + } |
|
1059 | + if ($rule['type'] == 'header') { |
|
1060 | + $search .= ($search ? ' ' : '').'HEADER '.$rule['rulevalue']; |
|
1061 | + } |
|
1062 | + |
|
1063 | + if ($rule['type'] == 'notinsubject') { |
|
1064 | + $search .= ($search ? ' ' : '').'SUBJECT NOT "'.str_replace('"', '', $rule['rulevalue']).'"'; |
|
1065 | + } |
|
1066 | + if ($rule['type'] == 'notinbody') { |
|
1067 | + $search .= ($search ? ' ' : '').'BODY NOT "'.str_replace('"', '', $rule['rulevalue']).'"'; |
|
1068 | + } |
|
1069 | + |
|
1070 | + if ($rule['type'] == 'seen') { |
|
1071 | + $search .= ($search ? ' ' : '').'SEEN'; |
|
1072 | + } |
|
1073 | + if ($rule['type'] == 'unseen') { |
|
1074 | + $search .= ($search ? ' ' : '').'UNSEEN'; |
|
1075 | + } |
|
1076 | + if ($rule['type'] == 'unanswered') { |
|
1077 | + $search .= ($search ? ' ' : '').'UNANSWERED'; |
|
1078 | + } |
|
1079 | + if ($rule['type'] == 'answered') { |
|
1080 | + $search .= ($search ? ' ' : '').'ANSWERED'; |
|
1081 | + } |
|
1082 | + if ($rule['type'] == 'smaller') { |
|
1083 | + $search .= ($search ? ' ' : '').'SMALLER "'.str_replace('"', '', $rule['rulevalue']).'"'; |
|
1084 | + } |
|
1085 | + if ($rule['type'] == 'larger') { |
|
1086 | + $search .= ($search ? ' ' : '').'LARGER "'.str_replace('"', '', $rule['rulevalue']).'"'; |
|
1087 | + } |
|
1008 | 1088 | |
1009 | 1089 | if ($rule['type'] == 'withtrackingidinmsgid') { $searchfilterdoltrackid++; $searchhead .= '/Message-ID.*@'.preg_quote($host, '/').'/'; } |
1010 | 1090 | if ($rule['type'] == 'withouttrackingidinmsgid') { $searchfilterdoltrackid++; $searchhead .= '/Message-ID.*@'.preg_quote($host, '/').'/'; } |
@@ -1015,11 +1095,18 @@ discard block |
||
1015 | 1095 | if ($rule['type'] == 'isnotanswer') { $searchfilterisnotanswer++; $searchhead .= '! /References.*@.*/'; } |
1016 | 1096 | } |
1017 | 1097 | |
1018 | - if (empty($targetdir)) // Use last date as filter if there is no targetdir defined. |
|
1098 | + if (empty($targetdir)) { |
|
1099 | + // Use last date as filter if there is no targetdir defined. |
|
1019 | 1100 | { |
1020 | 1101 | $fromdate = 0; |
1021 | - if ($this->datelastok) $fromdate = $this->datelastok; |
|
1022 | - if ($fromdate > 0) $search .= ($search ? ' ' : '').'SINCE '.date('j-M-Y', $fromdate - 1); // SENTSINCE not supported. Date must be X-Abc-9999 (X on 1 digit if < 10) |
|
1102 | + } |
|
1103 | + if ($this->datelastok) { |
|
1104 | + $fromdate = $this->datelastok; |
|
1105 | + } |
|
1106 | + if ($fromdate > 0) { |
|
1107 | + $search .= ($search ? ' ' : '').'SINCE '.date('j-M-Y', $fromdate - 1); |
|
1108 | + } |
|
1109 | + // SENTSINCE not supported. Date must be X-Abc-9999 (X on 1 digit if < 10) |
|
1023 | 1110 | //$search.=($search?' ':'').'SINCE 8-Apr-2018'; |
1024 | 1111 | } |
1025 | 1112 | dol_syslog("IMAP search string = ".$search); |
@@ -1178,7 +1265,9 @@ discard block |
||
1178 | 1265 | // Note: we can have |
1179 | 1266 | // Message-ID=A, In-Reply-To=B, References=B and message can BE an answer or NOT (a transfer rewriten) |
1180 | 1267 | $isanswer = 0; |
1181 | - if (preg_match('/Re\s*:\s+/i', $headers['Subject'])) $isanswer = 1; |
|
1268 | + if (preg_match('/Re\s*:\s+/i', $headers['Subject'])) { |
|
1269 | + $isanswer = 1; |
|
1270 | + } |
|
1182 | 1271 | //if ($headers['In-Reply-To'] != $headers['Message-ID'] && empty($headers['References'])) $isanswer = 1; // If in-reply-to differs of message-id, this is a reply |
1183 | 1272 | //if ($headers['In-Reply-To'] != $headers['Message-ID'] && !empty($headers['References']) && strpos($headers['References'], $headers['Message-ID']) !== false) $isanswer = 1; |
1184 | 1273 | |
@@ -1193,7 +1282,9 @@ discard block |
||
1193 | 1282 | // Note: we can have |
1194 | 1283 | // Message-ID=A, In-Reply-To=B, References=B and message can BE an answer or NOT (a transfer rewriten) |
1195 | 1284 | $isanswer = 0; |
1196 | - if (preg_match('/Re\s*:\s+/i', $headers['Subject'])) $isanswer = 1; |
|
1285 | + if (preg_match('/Re\s*:\s+/i', $headers['Subject'])) { |
|
1286 | + $isanswer = 1; |
|
1287 | + } |
|
1197 | 1288 | //if ($headers['In-Reply-To'] != $headers['Message-ID'] && empty($headers['References'])) $isanswer = 1; // If in-reply-to differs of message-id, this is a reply |
1198 | 1289 | //if ($headers['In-Reply-To'] != $headers['Message-ID'] && !empty($headers['References']) && strpos($headers['References'], $headers['Message-ID']) !== false) $isanswer = 1; |
1199 | 1290 | if ($isanswer) { |
@@ -1427,16 +1518,27 @@ discard block |
||
1427 | 1518 | $fk_element_id = $objectemail->id; |
1428 | 1519 | $fk_element_type = $objectemail->element; |
1429 | 1520 | // Fix fk_element_type |
1430 | - if ($fk_element_type == 'facture') $fk_element_type = 'invoice'; |
|
1521 | + if ($fk_element_type == 'facture') { |
|
1522 | + $fk_element_type = 'invoice'; |
|
1523 | + } |
|
1431 | 1524 | |
1432 | - if (get_class($objectemail) != 'Societe') $thirdpartyid = $objectemail->fk_soc; |
|
1433 | - else $thirdpartyid = $objectemail->id; |
|
1525 | + if (get_class($objectemail) != 'Societe') { |
|
1526 | + $thirdpartyid = $objectemail->fk_soc; |
|
1527 | + } else { |
|
1528 | + $thirdpartyid = $objectemail->id; |
|
1529 | + } |
|
1434 | 1530 | |
1435 | - if (get_class($objectemail) != 'Contact') $contactid = $objectemail->fk_socpeople; |
|
1436 | - else $contactid = $objectemail->id; |
|
1531 | + if (get_class($objectemail) != 'Contact') { |
|
1532 | + $contactid = $objectemail->fk_socpeople; |
|
1533 | + } else { |
|
1534 | + $contactid = $objectemail->id; |
|
1535 | + } |
|
1437 | 1536 | |
1438 | - if (get_class($objectemail) != 'Project') $projectid = isset($objectemail->fk_project) ? $objectemail->fk_project : $objectemail->fk_projet; |
|
1439 | - else $projectid = $objectemail->id; |
|
1537 | + if (get_class($objectemail) != 'Project') { |
|
1538 | + $projectid = isset($objectemail->fk_project) ? $objectemail->fk_project : $objectemail->fk_projet; |
|
1539 | + } else { |
|
1540 | + $projectid = $objectemail->id; |
|
1541 | + } |
|
1440 | 1542 | } |
1441 | 1543 | } |
1442 | 1544 | |
@@ -1444,33 +1546,48 @@ discard block |
||
1444 | 1546 | if ($projectid > 0) |
1445 | 1547 | { |
1446 | 1548 | $result = $projectstatic->fetch($projectid); |
1447 | - if ($result <= 0) $projectstatic->id = 0; |
|
1448 | - else { |
|
1549 | + if ($result <= 0) { |
|
1550 | + $projectstatic->id = 0; |
|
1551 | + } else { |
|
1449 | 1552 | $projectid = $projectstatic->id; |
1450 | - if ($trackid) $projectfoundby = 'trackid ('.$trackid.')'; |
|
1451 | - if (empty($contactid)) $contactid = $projectstatic->fk_contact; |
|
1452 | - if (empty($thirdpartyid)) $thirdpartyid = $projectstatic->fk_soc; |
|
1553 | + if ($trackid) { |
|
1554 | + $projectfoundby = 'trackid ('.$trackid.')'; |
|
1555 | + } |
|
1556 | + if (empty($contactid)) { |
|
1557 | + $contactid = $projectstatic->fk_contact; |
|
1558 | + } |
|
1559 | + if (empty($thirdpartyid)) { |
|
1560 | + $thirdpartyid = $projectstatic->fk_soc; |
|
1561 | + } |
|
1453 | 1562 | } |
1454 | 1563 | } |
1455 | 1564 | // Contact |
1456 | 1565 | if ($contactid > 0) |
1457 | 1566 | { |
1458 | 1567 | $result = $contactstatic->fetch($contactid); |
1459 | - if ($result <= 0) $contactstatic->id = 0; |
|
1460 | - else { |
|
1568 | + if ($result <= 0) { |
|
1569 | + $contactstatic->id = 0; |
|
1570 | + } else { |
|
1461 | 1571 | $contactid = $contactstatic->id; |
1462 | - if ($trackid) $contactfoundby = 'trackid ('.$trackid.')'; |
|
1463 | - if (empty($thirdpartyid)) $thirdpartyid = $contactstatic->fk_soc; |
|
1572 | + if ($trackid) { |
|
1573 | + $contactfoundby = 'trackid ('.$trackid.')'; |
|
1574 | + } |
|
1575 | + if (empty($thirdpartyid)) { |
|
1576 | + $thirdpartyid = $contactstatic->fk_soc; |
|
1577 | + } |
|
1464 | 1578 | } |
1465 | 1579 | } |
1466 | 1580 | // Thirdparty |
1467 | 1581 | if ($thirdpartyid > 0) |
1468 | 1582 | { |
1469 | 1583 | $result = $thirdpartystatic->fetch($thirdpartyid); |
1470 | - if ($result <= 0) $thirdpartystatic->id = 0; |
|
1471 | - else { |
|
1584 | + if ($result <= 0) { |
|
1585 | + $thirdpartystatic->id = 0; |
|
1586 | + } else { |
|
1472 | 1587 | $thirdpartyid = $thirdpartystatic->id; |
1473 | - if ($trackid) $thirdpartyfoundby = 'trackid ('.$trackid.')'; |
|
1588 | + if ($trackid) { |
|
1589 | + $thirdpartyfoundby = 'trackid ('.$trackid.')'; |
|
1590 | + } |
|
1474 | 1591 | } |
1475 | 1592 | } |
1476 | 1593 | |
@@ -1481,9 +1598,11 @@ discard block |
||
1481 | 1598 | } |
1482 | 1599 | } |
1483 | 1600 | |
1484 | - if (empty($contactid)) // Try to find contact using email |
|
1601 | + if (empty($contactid)) { |
|
1602 | + // Try to find contact using email |
|
1485 | 1603 | { |
1486 | 1604 | $result = $contactstatic->fetch(0, null, '', $from); |
1605 | + } |
|
1487 | 1606 | |
1488 | 1607 | if ($result > 0) |
1489 | 1608 | { |
@@ -1501,10 +1620,14 @@ discard block |
||
1501 | 1620 | } |
1502 | 1621 | } |
1503 | 1622 | |
1504 | - if (empty($thirdpartyid)) // Try to find thirdparty using email |
|
1623 | + if (empty($thirdpartyid)) { |
|
1624 | + // Try to find thirdparty using email |
|
1505 | 1625 | { |
1506 | 1626 | $result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $from); |
1507 | - if ($result > 0) $thirdpartyfoundby = 'email ('.$from.')'; |
|
1627 | + } |
|
1628 | + if ($result > 0) { |
|
1629 | + $thirdpartyfoundby = 'email ('.$from.')'; |
|
1630 | + } |
|
1508 | 1631 | } |
1509 | 1632 | |
1510 | 1633 | // Do operations |
@@ -1512,8 +1635,12 @@ discard block |
||
1512 | 1635 | { |
1513 | 1636 | $errorforthisaction = 0; |
1514 | 1637 | |
1515 | - if ($errorforactions) break; |
|
1516 | - if (empty($operation['status'])) continue; |
|
1638 | + if ($errorforactions) { |
|
1639 | + break; |
|
1640 | + } |
|
1641 | + if (empty($operation['status'])) { |
|
1642 | + continue; |
|
1643 | + } |
|
1517 | 1644 | |
1518 | 1645 | // Make Operation |
1519 | 1646 | dol_syslog("Execute action ".$operation['type']." actionparam=".$operation['actionparam'].' thirdpartystatic->id='.$thirdpartystatic->id.' contactstatic->id='.$contactstatic->id.' projectstatic->id='.$projectstatic->id); |
@@ -1521,7 +1648,9 @@ discard block |
||
1521 | 1648 | |
1522 | 1649 | $actioncode = 'EMAIL_IN'; |
1523 | 1650 | // If we scan the Sent box, we use the code for out email |
1524 | - if ($this->source_directory == 'Sent') $actioncode = 'EMAIL_OUT'; |
|
1651 | + if ($this->source_directory == 'Sent') { |
|
1652 | + $actioncode = 'EMAIL_OUT'; |
|
1653 | + } |
|
1525 | 1654 | |
1526 | 1655 | $description = $descriptiontitle = $descriptionmeta = $descriptionfull = ''; |
1527 | 1656 | |
@@ -1529,9 +1658,13 @@ discard block |
||
1529 | 1658 | |
1530 | 1659 | $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailTopic").' : '.dol_escape_htmltag($subject)); |
1531 | 1660 | $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailFrom").($langs->trans("MailFrom") != 'From' ? ' (From)' : '').' : '.dol_escape_htmltag($fromstring)); |
1532 | - if ($sender) $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("Sender").($langs->trans("Sender") != 'Sender' ? ' (Sender)' : '').' : '.dol_escape_htmltag($sender)); |
|
1661 | + if ($sender) { |
|
1662 | + $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("Sender").($langs->trans("Sender") != 'Sender' ? ' (Sender)' : '').' : '.dol_escape_htmltag($sender)); |
|
1663 | + } |
|
1533 | 1664 | $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailTo").($langs->trans("MailTo") != 'To' ? ' (To)' : '').' : '.dol_escape_htmltag($to)); |
1534 | - if ($sendtocc) $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailCC").($langs->trans("MailCC") != 'CC' ? ' (CC)' : '').' : '.dol_escape_htmltag($sendtocc)); |
|
1665 | + if ($sendtocc) { |
|
1666 | + $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailCC").($langs->trans("MailCC") != 'CC' ? ' (CC)' : '').' : '.dol_escape_htmltag($sendtocc)); |
|
1667 | + } |
|
1535 | 1668 | |
1536 | 1669 | // Search and create thirdparty |
1537 | 1670 | if ($operation['type'] == 'loadthirdparty' || $operation['type'] == 'loadandcreatethirdparty') |
@@ -1562,9 +1695,13 @@ discard block |
||
1562 | 1695 | |
1563 | 1696 | if (!empty($sourcefield) && !empty($regexstring)) |
1564 | 1697 | { |
1565 | - if (strtolower($sourcefield) == 'body') $sourcestring = $messagetext; |
|
1566 | - elseif (strtolower($sourcefield) == 'subject') $sourcestring = $subject; |
|
1567 | - elseif (strtolower($sourcefield) == 'header') $sourcestring = $header; |
|
1698 | + if (strtolower($sourcefield) == 'body') { |
|
1699 | + $sourcestring = $messagetext; |
|
1700 | + } elseif (strtolower($sourcefield) == 'subject') { |
|
1701 | + $sourcestring = $subject; |
|
1702 | + } elseif (strtolower($sourcefield) == 'header') { |
|
1703 | + $sourcestring = $header; |
|
1704 | + } |
|
1568 | 1705 | |
1569 | 1706 | if ($sourcestring) |
1570 | 1707 | { |
@@ -1623,7 +1760,9 @@ discard block |
||
1623 | 1760 | |
1624 | 1761 | // Create thirdparty |
1625 | 1762 | $thirdpartystatic->name = $nametouseforthirdparty; |
1626 | - if ($fromtext != $nametouseforthirdparty) $thirdpartystatic->name_alias = $fromtext; |
|
1763 | + if ($fromtext != $nametouseforthirdparty) { |
|
1764 | + $thirdpartystatic->name_alias = $fromtext; |
|
1765 | + } |
|
1627 | 1766 | $thirdpartystatic->email = $from; |
1628 | 1767 | |
1629 | 1768 | // Overwrite values with values extracted from source email |
@@ -1656,15 +1795,21 @@ discard block |
||
1656 | 1795 | { |
1657 | 1796 | if ($projectstatic->id > 0) |
1658 | 1797 | { |
1659 | - if ($projectfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Project found from '.$projectfoundby); |
|
1798 | + if ($projectfoundby) { |
|
1799 | + $descriptionmeta = dol_concatdesc($descriptionmeta, 'Project found from '.$projectfoundby); |
|
1800 | + } |
|
1660 | 1801 | } |
1661 | 1802 | if ($thirdpartystatic->id > 0) |
1662 | 1803 | { |
1663 | - if ($thirdpartyfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); |
|
1804 | + if ($thirdpartyfoundby) { |
|
1805 | + $descriptionmeta = dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); |
|
1806 | + } |
|
1664 | 1807 | } |
1665 | 1808 | if ($contactstatic->id > 0) |
1666 | 1809 | { |
1667 | - if ($contactfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); |
|
1810 | + if ($contactfoundby) { |
|
1811 | + $descriptionmeta = dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); |
|
1812 | + } |
|
1668 | 1813 | } |
1669 | 1814 | |
1670 | 1815 | $description = $descriptiontitle; |
@@ -1749,12 +1894,16 @@ discard block |
||
1749 | 1894 | if ($thirdpartystatic->id > 0) |
1750 | 1895 | { |
1751 | 1896 | $projecttocreate->socid = $thirdpartystatic->id; |
1752 | - if ($thirdpartyfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); |
|
1897 | + if ($thirdpartyfoundby) { |
|
1898 | + $descriptionmeta = dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); |
|
1899 | + } |
|
1753 | 1900 | } |
1754 | 1901 | if ($contactstatic->id > 0) |
1755 | 1902 | { |
1756 | 1903 | $projecttocreate->contact_id = $contactstatic->id; |
1757 | - if ($contactfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); |
|
1904 | + if ($contactfoundby) { |
|
1905 | + $descriptionmeta = dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); |
|
1906 | + } |
|
1758 | 1907 | } |
1759 | 1908 | |
1760 | 1909 | $description = $descriptiontitle; |
@@ -1865,12 +2014,16 @@ discard block |
||
1865 | 2014 | { |
1866 | 2015 | $tickettocreate->socid = $thirdpartystatic->id; |
1867 | 2016 | $tickettocreate->fk_soc = $thirdpartystatic->id; |
1868 | - if ($thirdpartyfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); |
|
2017 | + if ($thirdpartyfoundby) { |
|
2018 | + $descriptionmeta = dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); |
|
2019 | + } |
|
1869 | 2020 | } |
1870 | 2021 | if ($contactstatic->id > 0) |
1871 | 2022 | { |
1872 | 2023 | $tickettocreate->contact_id = $contactstatic->id; |
1873 | - if ($contactfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); |
|
2024 | + if ($contactfoundby) { |
|
2025 | + $descriptionmeta = dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); |
|
2026 | + } |
|
1874 | 2027 | } |
1875 | 2028 | |
1876 | 2029 | $description = $descriptiontitle; |
@@ -2175,11 +2328,17 @@ discard block |
||
2175 | 2328 | $this->datelastresult = $now; |
2176 | 2329 | $this->lastresult = $output; |
2177 | 2330 | $this->debuginfo = 'IMAP search string used : '.$search; |
2178 | - if ($searchhead) $this->debuginfo .= '<br>Then search string into email header : '.$searchhead; |
|
2331 | + if ($searchhead) { |
|
2332 | + $this->debuginfo .= '<br>Then search string into email header : '.$searchhead; |
|
2333 | + } |
|
2179 | 2334 | |
2180 | - if (!$error) $this->datelastok = $now; |
|
2335 | + if (!$error) { |
|
2336 | + $this->datelastok = $now; |
|
2337 | + } |
|
2181 | 2338 | |
2182 | - if (!empty($this->errors)) $this->lastresult .= " - ".join(" - ", $this->errors); |
|
2339 | + if (!empty($this->errors)) { |
|
2340 | + $this->lastresult .= " - ".join(" - ", $this->errors); |
|
2341 | + } |
|
2183 | 2342 | $this->codelastresult = ($error ? 'KO' : 'OK'); |
2184 | 2343 | $this->update($user); |
2185 | 2344 | |
@@ -2259,10 +2418,11 @@ discard block |
||
2259 | 2418 | imap_fetchbody($mbox, $mid, $partno) : // multipart |
2260 | 2419 | imap_body($mbox, $mid); // simple |
2261 | 2420 | // Any part may be encoded, even plain text messages, so check everything. |
2262 | - if ($p->encoding == 4) |
|
2263 | - $data = quoted_printable_decode($data); |
|
2264 | - elseif ($p->encoding == 3) |
|
2265 | - $data = base64_decode($data); |
|
2421 | + if ($p->encoding == 4) { |
|
2422 | + $data = quoted_printable_decode($data); |
|
2423 | + } elseif ($p->encoding == 3) { |
|
2424 | + $data = base64_decode($data); |
|
2425 | + } |
|
2266 | 2426 | |
2267 | 2427 | // PARAMETERS |
2268 | 2428 | // get all parameters, like charset, filenames of attachments, etc. |
@@ -2299,9 +2459,11 @@ discard block |
||
2299 | 2459 | } |
2300 | 2460 | // Messages may be split in different parts because of inline attachments, |
2301 | 2461 | // so append parts together with blank row. |
2302 | - if (strtolower($p->subtype) == 'plain') |
|
2303 | - $plainmsg .= trim($data)."\n\n"; |
|
2304 | - else $htmlmsg .= $data."<br><br>"; |
|
2462 | + if (strtolower($p->subtype) == 'plain') { |
|
2463 | + $plainmsg .= trim($data)."\n\n"; |
|
2464 | + } else { |
|
2465 | + $htmlmsg .= $data."<br><br>"; |
|
2466 | + } |
|
2305 | 2467 | $charset = $params['charset']; // assume all parts are same charset |
2306 | 2468 | } |
2307 | 2469 |
@@ -46,13 +46,19 @@ discard block |
||
46 | 46 | */ |
47 | 47 | function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLength = 2, $autoselect = 0, $ajaxoptions = array(), $moreparams = '') |
48 | 48 | { |
49 | - if (empty($minLength)) $minLength = 1; |
|
49 | + if (empty($minLength)) { |
|
50 | + $minLength = 1; |
|
51 | + } |
|
50 | 52 | |
51 | 53 | $dataforrenderITem = 'ui-autocomplete'; |
52 | 54 | $dataforitem = 'ui-autocomplete-item'; |
53 | 55 | // Allow two constant to use other values for backward compatibility |
54 | - if (defined('JS_QUERY_AUTOCOMPLETE_RENDERITEM')) $dataforrenderITem = constant('JS_QUERY_AUTOCOMPLETE_RENDERITEM'); |
|
55 | - if (defined('JS_QUERY_AUTOCOMPLETE_ITEM')) $dataforitem = constant('JS_QUERY_AUTOCOMPLETE_ITEM'); |
|
56 | + if (defined('JS_QUERY_AUTOCOMPLETE_RENDERITEM')) { |
|
57 | + $dataforrenderITem = constant('JS_QUERY_AUTOCOMPLETE_RENDERITEM'); |
|
58 | + } |
|
59 | + if (defined('JS_QUERY_AUTOCOMPLETE_ITEM')) { |
|
60 | + $dataforitem = constant('JS_QUERY_AUTOCOMPLETE_ITEM'); |
|
61 | + } |
|
56 | 62 | |
57 | 63 | // Input search_htmlname is original field |
58 | 64 | // Input htmlname is a second input field used when using ajax autocomplete. |
@@ -388,14 +394,26 @@ discard block |
||
388 | 394 | global $conf; |
389 | 395 | |
390 | 396 | // select2 can be disabled for smartphones |
391 | - if (!empty($conf->browser->layout) && $conf->browser->layout == 'phone' && !empty($conf->global->MAIN_DISALLOW_SELECT2_WITH_SMARTPHONE)) return ''; |
|
397 | + if (!empty($conf->browser->layout) && $conf->browser->layout == 'phone' && !empty($conf->global->MAIN_DISALLOW_SELECT2_WITH_SMARTPHONE)) { |
|
398 | + return ''; |
|
399 | + } |
|
392 | 400 | |
393 | - if (!empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return ''; |
|
394 | - if (empty($conf->use_javascript_ajax)) return ''; |
|
395 | - if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) return ''; |
|
396 | - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) return ''; |
|
401 | + if (!empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) { |
|
402 | + return ''; |
|
403 | + } |
|
404 | + if (empty($conf->use_javascript_ajax)) { |
|
405 | + return ''; |
|
406 | + } |
|
407 | + if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) { |
|
408 | + return ''; |
|
409 | + } |
|
410 | + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { |
|
411 | + return ''; |
|
412 | + } |
|
397 | 413 | |
398 | - if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete = 0; |
|
414 | + if (empty($minLengthToAutocomplete)) { |
|
415 | + $minLengthToAutocomplete = 0; |
|
416 | + } |
|
399 | 417 | |
400 | 418 | $tmpplugin = 'select2'; |
401 | 419 | $msg = "\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id = '.$htmlname.' --> |
@@ -422,10 +440,13 @@ discard block |
||
422 | 440 | }, |
423 | 441 | dropdownCssClass: \'ui-dialog\' |
424 | 442 | })'; |
425 | - if ($forcefocus) $msg .= '.select2(\'focus\')'; |
|
443 | + if ($forcefocus) { |
|
444 | + $msg .= '.select2(\'focus\')'; |
|
445 | + } |
|
426 | 446 | $msg .= ';'."\n"; |
427 | 447 | |
428 | - if (is_array($events) && count($events)) // If an array of js events to do were provided. |
|
448 | + if (is_array($events) && count($events)) { |
|
449 | + // If an array of js events to do were provided. |
|
429 | 450 | { |
430 | 451 | $msg .= ' |
431 | 452 | jQuery("#'.$htmlname.'").change(function () { |
@@ -475,6 +496,7 @@ discard block |
||
475 | 496 | ); |
476 | 497 | }'; |
477 | 498 | } |
499 | + } |
|
478 | 500 | |
479 | 501 | $msg .= '});'."\n"; |
480 | 502 | $msg .= "</script>\n"; |
@@ -500,12 +522,17 @@ discard block |
||
500 | 522 | global $conf, $langs, $user; |
501 | 523 | |
502 | 524 | $entity = ((isset($entity) && is_numeric($entity) && $entity >= 0) ? $entity : $conf->entity); |
503 | - if (!isset($input)) $input = array(); |
|
525 | + if (!isset($input)) { |
|
526 | + $input = array(); |
|
527 | + } |
|
504 | 528 | |
505 | 529 | if (empty($conf->use_javascript_ajax) || $forcenoajax) |
506 | 530 | { |
507 | - if (empty($conf->global->$code)) print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_'.$code.'&token='.newToken().'&entity='.$entity.'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; |
|
508 | - else print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_'.$code.'&token='.newToken().'&entity='.$entity.'">'.img_picto($langs->trans("Enabled"), 'on').'</a>'; |
|
531 | + if (empty($conf->global->$code)) { |
|
532 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_'.$code.'&token='.newToken().'&entity='.$entity.'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; |
|
533 | + } else { |
|
534 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_'.$code.'&token='.newToken().'&entity='.$entity.'">'.img_picto($langs->trans("Enabled"), 'on').'</a>'; |
|
535 | + } |
|
509 | 536 | } else { |
510 | 537 | $out = "\n<!-- Ajax code to switch constant ".$code." -->".' |
511 | 538 | <script> |
@@ -304,7 +304,9 @@ discard block |
||
304 | 304 | $sql[] = $sqlforexampleFilterA3; |
305 | 305 | $sql[] = $sqlforexampleA4; |
306 | 306 | } |
307 | - } else dol_print_error($this->db); |
|
307 | + } else { |
|
308 | + dol_print_error($this->db); |
|
309 | + } |
|
308 | 310 | |
309 | 311 | $tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_Out' and entity = ".$conf->entity; |
310 | 312 | $tmpresql = $this->db->query($tmpsql); |
@@ -346,7 +348,9 @@ discard block |
||
346 | 348 | $sql[] = $sqlforexampleB2; |
347 | 349 | $sql[] = $sqlforexampleB3; |
348 | 350 | } |
349 | - } else dol_print_error($this->db); |
|
351 | + } else { |
|
352 | + dol_print_error($this->db); |
|
353 | + } |
|
350 | 354 | |
351 | 355 | $tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".$conf->entity; |
352 | 356 | $tmpresql = $this->db->query($tmpsql); |
@@ -375,7 +379,9 @@ discard block |
||
375 | 379 | $sql[] = $sqlforexampleFilterC3; |
376 | 380 | $sql[] = $sqlforexampleC4; |
377 | 381 | } |
378 | - } else dol_print_error($this->db); |
|
382 | + } else { |
|
383 | + dol_print_error($this->db); |
|
384 | + } |
|
379 | 385 | |
380 | 386 | $tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Candidatures' and entity = ".$conf->entity; |
381 | 387 | $tmpresql = $this->db->query($tmpsql); |
@@ -403,7 +409,9 @@ discard block |
||
403 | 409 | $sql[] = $sqlforexampleFilterC3; |
404 | 410 | $sql[] = $sqlforexampleC4; |
405 | 411 | } |
406 | - } else dol_print_error($this->db); |
|
412 | + } else { |
|
413 | + dol_print_error($this->db); |
|
414 | + } |
|
407 | 415 | |
408 | 416 | return $this->_init($sql, $options); |
409 | 417 | } |
@@ -47,8 +47,12 @@ discard block |
||
47 | 47 | |
48 | 48 | $sortfield = GETPOST("sortfield", 'alpha'); |
49 | 49 | $sortorder = GETPOST("sortorder", 'alpha'); |
50 | -if (!$sortfield) $sortfield = "p.ref"; |
|
51 | -if (!$sortorder) $sortorder = "DESC"; |
|
50 | +if (!$sortfield) { |
|
51 | + $sortfield = "p.ref"; |
|
52 | +} |
|
53 | +if (!$sortorder) { |
|
54 | + $sortorder = "DESC"; |
|
55 | +} |
|
52 | 56 | |
53 | 57 | $backtopage = GETPOST('backtopage', 'alpha'); |
54 | 58 | |
@@ -87,7 +91,9 @@ discard block |
||
87 | 91 | |
88 | 92 | $parameters = array('id'=>$id, 'ref'=>$ref); |
89 | 93 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
90 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
94 | +if ($reshook < 0) { |
|
95 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
96 | +} |
|
91 | 97 | if (empty($reshook)) |
92 | 98 | { |
93 | 99 | // Ajout entrepot |
@@ -174,11 +180,15 @@ discard block |
||
174 | 180 | |
175 | 181 | // Fill array 'array_options' with data from add form |
176 | 182 | $ret = $extrafields->setOptionalsFromPost(null, $object); |
177 | - if ($ret < 0) $error++; |
|
183 | + if ($ret < 0) { |
|
184 | + $error++; |
|
185 | + } |
|
178 | 186 | |
179 | 187 | if (!$error) { |
180 | 188 | $ret = $object->update($id, $user); |
181 | - if ($ret < 0) $error++; |
|
189 | + if ($ret < 0) { |
|
190 | + $error++; |
|
191 | + } |
|
182 | 192 | } |
183 | 193 | |
184 | 194 | if ($error) { |
@@ -198,7 +208,9 @@ discard block |
||
198 | 208 | |
199 | 209 | // Fill array 'array_options' with data from update form |
200 | 210 | $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); |
201 | - if ($ret < 0) $error++; |
|
211 | + if ($ret < 0) { |
|
212 | + $error++; |
|
213 | + } |
|
202 | 214 | if (!$error) { |
203 | 215 | $result = $object->insertExtraFields(); |
204 | 216 | if ($result < 0) { |
@@ -206,7 +218,9 @@ discard block |
||
206 | 218 | $error++; |
207 | 219 | } |
208 | 220 | } |
209 | - if ($error) $action = 'edit_extras'; |
|
221 | + if ($error) { |
|
222 | + $action = 'edit_extras'; |
|
223 | + } |
|
210 | 224 | } |
211 | 225 | |
212 | 226 | if ($cancel == $langs->trans("Cancel")) |
@@ -285,7 +299,9 @@ discard block |
||
285 | 299 | print '<tr><td>'.$langs->trans('Country').'</td><td>'; |
286 | 300 | print img_picto('', 'globe-americas', 'class="paddingright"'); |
287 | 301 | print $form->select_country((!empty($object->country_id) ? $object->country_id : $mysoc->country_code), 'country_id'); |
288 | - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
302 | + if ($user->admin) { |
|
303 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
304 | + } |
|
289 | 305 | print '</td></tr>'; |
290 | 306 | |
291 | 307 | // Phone / Fax |
@@ -365,8 +381,11 @@ discard block |
||
365 | 381 | // Call Hook formConfirm |
366 | 382 | $parameters = array('formConfirm' => $formconfirm); |
367 | 383 | $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook |
368 | - if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; |
|
369 | - elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; |
|
384 | + if (empty($reshook)) { |
|
385 | + $formconfirm .= $hookmanager->resPrint; |
|
386 | + } elseif ($reshook > 0) { |
|
387 | + $formconfirm = $hookmanager->resPrint; |
|
388 | + } |
|
370 | 389 | |
371 | 390 | // Print form confirm |
372 | 391 | print $formconfirm; |
@@ -379,7 +398,9 @@ discard block |
||
379 | 398 | $morehtmlref .= '</div>'; |
380 | 399 | |
381 | 400 | $shownav = 1; |
382 | - if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; |
|
401 | + if ($user->socid && !in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { |
|
402 | + $shownav = 0; |
|
403 | + } |
|
383 | 404 | |
384 | 405 | dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref); |
385 | 406 | |
@@ -487,15 +508,13 @@ discard block |
||
487 | 508 | { |
488 | 509 | if ($user->rights->stock->creer) { |
489 | 510 | print '<a class="butAction" href="card.php?action=edit&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Modify").'</a>'; |
490 | - } |
|
491 | - else { |
|
511 | + } else { |
|
492 | 512 | print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("Modify").'</a>'; |
493 | 513 | } |
494 | 514 | |
495 | 515 | if ($user->rights->stock->supprimer) { |
496 | 516 | print '<a class="butActionDelete" href="card.php?action=delete&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Delete").'</a>'; |
497 | - } |
|
498 | - else { |
|
517 | + } else { |
|
499 | 518 | print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("Delete").'</a>'; |
500 | 519 | } |
501 | 520 | } |
@@ -516,7 +535,9 @@ discard block |
||
516 | 535 | print_liste_field_titre("Product", "", "p.ref", "&id=".$id, "", "", $sortfield, $sortorder); |
517 | 536 | print_liste_field_titre("Label", "", "p.label", "&id=".$id, "", "", $sortfield, $sortorder); |
518 | 537 | print_liste_field_titre("Units", "", "ps.reel", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); |
519 | - if (!empty($conf->global->PRODUCT_USE_UNITS)) print_liste_field_titre("Unit", "", "p.fk_unit", "&id=".$id, "", 'align="left"', $sortfield, $sortorder); |
|
538 | + if (!empty($conf->global->PRODUCT_USE_UNITS)) { |
|
539 | + print_liste_field_titre("Unit", "", "p.fk_unit", "&id=".$id, "", 'align="left"', $sortfield, $sortorder); |
|
540 | + } |
|
520 | 541 | print_liste_field_titre("AverageUnitPricePMPShort", "", "p.pmp", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); |
521 | 542 | print_liste_field_titre("EstimatedStockValueShort", "", "", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); |
522 | 543 | if (empty($conf->global->PRODUIT_MULTIPRICES)) { |
@@ -538,7 +559,9 @@ discard block |
||
538 | 559 | |
539 | 560 | $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc, p.entity,"; |
540 | 561 | $sql .= " ps.reel as value"; |
541 | - if (!empty($conf->global->PRODUCT_USE_UNITS)) $sql .= ",fk_unit"; |
|
562 | + if (!empty($conf->global->PRODUCT_USE_UNITS)) { |
|
563 | + $sql .= ",fk_unit"; |
|
564 | + } |
|
542 | 565 | $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p"; |
543 | 566 | $sql .= " WHERE ps.fk_product = p.rowid"; |
544 | 567 | $sql .= " AND ps.reel <> 0"; // We do not show if stock is 0 (no product in this warehouse) |
@@ -556,9 +579,11 @@ discard block |
||
556 | 579 | $objp = $db->fetch_object($resql); |
557 | 580 | |
558 | 581 | // Multilangs |
559 | - if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active |
|
582 | + if (!empty($conf->global->MAIN_MULTILANGS)) { |
|
583 | + // si l'option est active |
|
560 | 584 | { |
561 | 585 | $sql = "SELECT label"; |
586 | + } |
|
562 | 587 | $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; |
563 | 588 | $sql .= " WHERE fk_product=".$objp->rowid; |
564 | 589 | $sql .= " AND lang='".$db->escape($langs->getDefaultLang())."'"; |
@@ -568,7 +593,9 @@ discard block |
||
568 | 593 | if ($result) |
569 | 594 | { |
570 | 595 | $objtp = $db->fetch_object($result); |
571 | - if ($objtp->label != '') $objp->produit = $objtp->label; |
|
596 | + if ($objtp->label != '') { |
|
597 | + $objp->produit = $objtp->label; |
|
598 | + } |
|
572 | 599 | } |
573 | 600 | } |
574 | 601 | |
@@ -598,7 +625,9 @@ discard block |
||
598 | 625 | if (!empty($conf->global->PRODUCT_USE_UNITS)) { |
599 | 626 | // Units |
600 | 627 | print '<td align="left">'; |
601 | - if (is_null($productstatic->fk_unit))$productstatic->fk_unit = 1; |
|
628 | + if (is_null($productstatic->fk_unit)) { |
|
629 | + $productstatic->fk_unit = 1; |
|
630 | + } |
|
602 | 631 | print $langs->trans($productstatic->getLabelOfUnit()); |
603 | 632 | print '</td>'; |
604 | 633 | } |
@@ -637,8 +666,11 @@ discard block |
||
637 | 666 | print "</a></td>"; |
638 | 667 | } |
639 | 668 | if (!empty($conf->global->PRODUCT_USE_UNITS)) { |
640 | - if ($i == 0) $units = $productstatic->fk_unit; |
|
641 | - elseif ($productstatic->fk_unit != $units) $sameunits = false; |
|
669 | + if ($i == 0) { |
|
670 | + $units = $productstatic->fk_unit; |
|
671 | + } elseif ($productstatic->fk_unit != $units) { |
|
672 | + $sameunits = false; |
|
673 | + } |
|
642 | 674 | } |
643 | 675 | print "</tr>"; |
644 | 676 | $i++; |
@@ -648,10 +680,14 @@ discard block |
||
648 | 680 | print '<tr class="liste_total"><td class="liste_total" colspan="2">'.$langs->trans("Total").'</td>'; |
649 | 681 | print '<td class="liste_total right">'; |
650 | 682 | $valtoshow = price2num($totalunit, 'MS'); |
651 | - if (empty($conf->global->PRODUCT_USE_UNITS) || $sameunits) print empty($valtoshow) ? '0' : $valtoshow; |
|
683 | + if (empty($conf->global->PRODUCT_USE_UNITS) || $sameunits) { |
|
684 | + print empty($valtoshow) ? '0' : $valtoshow; |
|
685 | + } |
|
652 | 686 | print '</td>'; |
653 | 687 | print '<td class="liste_total">'; |
654 | - if (empty($conf->global->PRODUCT_USE_UNITS) && $sameunits) print $langs->trans($productstatic->getLabelOfUnit()); |
|
688 | + if (empty($conf->global->PRODUCT_USE_UNITS) && $sameunits) { |
|
689 | + print $langs->trans($productstatic->getLabelOfUnit()); |
|
690 | + } |
|
655 | 691 | print '</td>'; |
656 | 692 | print '<td class="liste_total right">'.price(price2num($totalvalue, 'MT')).'</td>'; |
657 | 693 | if (empty($conf->global->PRODUIT_MULTIPRICES)) |
@@ -721,7 +757,9 @@ discard block |
||
721 | 757 | print '<tr><td>'.$langs->trans('Country').'</td><td>'; |
722 | 758 | print img_picto('', 'globe-americas', 'class="paddingright"'); |
723 | 759 | print $form->select_country($object->country_id ? $object->country_id : $mysoc->country_code, 'country_id'); |
724 | - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
760 | + if ($user->admin) { |
|
761 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
762 | + } |
|
725 | 763 | print '</td></tr>'; |
726 | 764 | |
727 | 765 | // Phone / Fax |
@@ -31,7 +31,9 @@ discard block |
||
31 | 31 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
32 | 32 | } |
33 | 33 | |
34 | -if (!$user->rights->commande->lire) accessforbidden(); |
|
34 | +if (!$user->rights->commande->lire) { |
|
35 | + accessforbidden(); |
|
36 | +} |
|
35 | 37 | |
36 | 38 | // Load translation files required by the page |
37 | 39 | $langs->loadLangs(array('orders', 'sendings', 'bills')); |
@@ -42,7 +44,9 @@ discard block |
||
42 | 44 | $ref = GETPOST('ref', 'alpha'); |
43 | 45 | |
44 | 46 | // Security check |
45 | -if ($user->socid) $socid = $user->socid; |
|
47 | +if ($user->socid) { |
|
48 | + $socid = $user->socid; |
|
49 | +} |
|
46 | 50 | $result = restrictedArea($user, 'commande', $comid, ''); |
47 | 51 | |
48 | 52 | $object = new Commande($db); |
@@ -40,7 +40,9 @@ discard block |
||
40 | 40 | $module = GETPOST('module', 'alpha'); |
41 | 41 | $website = GETPOST('website', 'alpha'); |
42 | 42 | $pageid = GETPOST('pageid', 'int'); |
43 | -if (empty($module)) $module = 'ecm'; |
|
43 | +if (empty($module)) { |
|
44 | + $module = 'ecm'; |
|
45 | +} |
|
44 | 46 | |
45 | 47 | // Get parameters |
46 | 48 | $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; |
@@ -51,8 +53,12 @@ discard block |
||
51 | 53 | $offset = $limit * $page; |
52 | 54 | $pageprev = $page - 1; |
53 | 55 | $pagenext = $page + 1; |
54 | -if (!$sortorder) $sortorder = "ASC"; |
|
55 | -if (!$sortfield) $sortfield = "name"; |
|
56 | +if (!$sortorder) { |
|
57 | + $sortorder = "ASC"; |
|
58 | +} |
|
59 | +if (!$sortfield) { |
|
60 | + $sortfield = "name"; |
|
61 | +} |
|
56 | 62 | |
57 | 63 | $section = GETPOST("section", 'alpha') ?GETPOST("section", 'alpha') : GETPOST("relativedir", 'alpha'); |
58 | 64 | if (!$section) |
@@ -112,9 +118,11 @@ discard block |
||
112 | 118 | $result = $ecmdir->changeNbOfFiles('+'); |
113 | 119 | } else { |
114 | 120 | $langs->load("errors"); |
115 | - if ($resupload < 0) // Unknown error |
|
121 | + if ($resupload < 0) { |
|
122 | + // Unknown error |
|
116 | 123 | { |
117 | 124 | setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors'); |
125 | + } |
|
118 | 126 | } elseif (preg_match('/ErrorFileIsInfectedWithAVirus/', $resupload)) { |
119 | 127 | // Files infected by a virus |
120 | 128 | setEventMessages($langs->trans("ErrorFileIsInfectedWithAVirus"), null, 'errors'); |
@@ -136,8 +144,11 @@ discard block |
||
136 | 144 | $langs->load("other"); |
137 | 145 | $file = $upload_dir."/".GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). |
138 | 146 | $ret = dol_delete_file($file); |
139 | - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); |
|
140 | - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); |
|
147 | + if ($ret) { |
|
148 | + setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); |
|
149 | + } else { |
|
150 | + setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); |
|
151 | + } |
|
141 | 152 | |
142 | 153 | $result = $ecmdir->changeNbOfFiles('-'); |
143 | 154 | } |
@@ -169,8 +180,9 @@ discard block |
||
169 | 180 | } else { |
170 | 181 | $resbool = dol_delete_dir($upload_dir, 1); |
171 | 182 | } |
172 | - if ($resbool) $result = 1; |
|
173 | - else { |
|
183 | + if ($resbool) { |
|
184 | + $result = 1; |
|
185 | + } else { |
|
174 | 186 | $langs->load('errors'); |
175 | 187 | setEventMessages($langs->trans("ErrorFailToDeleteDir", $upload_dir), null, 'errors'); |
176 | 188 | $result = 0; |
@@ -206,7 +218,9 @@ discard block |
||
206 | 218 | $ecmdir->label = dol_sanitizeFileName(GETPOST("label")); |
207 | 219 | $ecmdir->description = GETPOST("description"); |
208 | 220 | $ret = $extrafields->setOptionalsFromPost(null, $ecmdir); |
209 | - if ($ret < 0) $error++; |
|
221 | + if ($ret < 0) { |
|
222 | + $error++; |
|
223 | + } |
|
210 | 224 | if (!$error) { |
211 | 225 | // Actions on extra fields |
212 | 226 | $result = $ecmdir->insertExtraFields(); |
@@ -330,7 +344,9 @@ discard block |
||
330 | 344 | if ($i == 0 && $action == 'edit') |
331 | 345 | { |
332 | 346 | $s = '<input type="text" name="label" class="minwidth300" maxlength="32" value="'.$tmpecmdir->label.'">'; |
333 | - } else $s = $tmpecmdir->getNomUrl(1).$s; |
|
347 | + } else { |
|
348 | + $s = $tmpecmdir->getNomUrl(1).$s; |
|
349 | + } |
|
334 | 350 | if ($tmpecmdir->fk_parent) |
335 | 351 | { |
336 | 352 | $s = ' -> '.$s; |
@@ -358,7 +374,9 @@ discard block |
||
358 | 374 | $s .= '<input type="text" name="label" class="minwidth300" maxlength="32" value="'.$subdir.'">'; |
359 | 375 | $s .= '<input type="hidden" name="oldrelparentdir" value="'.dirname($section).'">'; |
360 | 376 | $s .= '<input type="hidden" name="oldreldir" value="'.basename($section).'">'; |
361 | - } else $s .= $subdir; |
|
377 | + } else { |
|
378 | + $s .= $subdir; |
|
379 | + } |
|
362 | 380 | } |
363 | 381 | if ($i < (count($subdirs) - 1)) |
364 | 382 | { |
@@ -389,7 +407,9 @@ discard block |
||
389 | 407 | print '<textarea class="flat quatrevingtpercent" name="description">'; |
390 | 408 | print $ecmdir->description; |
391 | 409 | print '</textarea>'; |
392 | - } else print dol_nl2br($ecmdir->description); |
|
410 | + } else { |
|
411 | + print dol_nl2br($ecmdir->description); |
|
412 | + } |
|
393 | 413 | print '</td></tr>'; |
394 | 414 | |
395 | 415 | print '<tr><td class="titlefield">'.$langs->trans("ECMCreationUser").'</td><td>'; |
@@ -36,7 +36,9 @@ discard block |
||
36 | 36 | $cancel = GETPOST('cancel', 'alpha'); |
37 | 37 | $backtopage = GETPOST('backtopage', 'alpha'); |
38 | 38 | |
39 | -if (!$user->rights->ecm->setup) accessforbidden(); |
|
39 | +if (!$user->rights->ecm->setup) { |
|
40 | + accessforbidden(); |
|
41 | +} |
|
40 | 42 | |
41 | 43 | // Get parameters |
42 | 44 | $socid = GETPOST("socid", "int"); |
@@ -56,8 +58,12 @@ discard block |
||
56 | 58 | $offset = $limit * $page; |
57 | 59 | $pageprev = $page - 1; |
58 | 60 | $pagenext = $page + 1; |
59 | -if (!$sortorder) $sortorder = "ASC"; |
|
60 | -if (!$sortfield) $sortfield = "label"; |
|
61 | +if (!$sortorder) { |
|
62 | + $sortorder = "ASC"; |
|
63 | +} |
|
64 | +if (!$sortfield) { |
|
65 | + $sortfield = "label"; |
|
66 | +} |
|
61 | 67 | |
62 | 68 | $section = GETPOST("section", 'alpha'); |
63 | 69 | if (!$section) |
@@ -186,7 +192,9 @@ discard block |
||
186 | 192 | if ($object->id > 0) |
187 | 193 | { |
188 | 194 | $ret = $extrafields->setOptionalsFromPost(null, $object); |
189 | - if ($ret < 0) $error++; |
|
195 | + if ($ret < 0) { |
|
196 | + $error++; |
|
197 | + } |
|
190 | 198 | if (!$error) { |
191 | 199 | // Actions on extra fields |
192 | 200 | $result = $object->insertExtraFields(); |
@@ -284,8 +292,11 @@ discard block |
||
284 | 292 | $urlfiletoshow = preg_replace('/\.noexe$/', '', $urlfile); |
285 | 293 | |
286 | 294 | $s = img_picto('', 'object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> '.$s.' -> '; |
287 | -if ($action == 'edit') $s .= '<input type="text" name="label" class="quatrevingtpercent" value="'.$urlfiletoshow.'">'; |
|
288 | -else $s .= $urlfiletoshow; |
|
295 | +if ($action == 'edit') { |
|
296 | + $s .= '<input type="text" name="label" class="quatrevingtpercent" value="'.$urlfiletoshow.'">'; |
|
297 | +} else { |
|
298 | + $s .= $urlfiletoshow; |
|
299 | +} |
|
289 | 300 | |
290 | 301 | $linkback = ''; |
291 | 302 | if ($backtopage) { |
@@ -335,20 +346,33 @@ discard block |
||
335 | 346 | $modulepart = 'ecm'; |
336 | 347 | $forcedownload = 1; |
337 | 348 | $rellink = '/document.php?modulepart='.$modulepart; |
338 | -if ($forcedownload) $rellink .= '&attachment=1'; |
|
339 | -if (!empty($object->entity)) $rellink .= '&entity='.$object->entity; |
|
349 | +if ($forcedownload) { |
|
350 | + $rellink .= '&attachment=1'; |
|
351 | +} |
|
352 | +if (!empty($object->entity)) { |
|
353 | + $rellink .= '&entity='.$object->entity; |
|
354 | +} |
|
340 | 355 | $rellink .= '&file='.urlencode($filepath); |
341 | 356 | $fulllink = $urlwithroot.$rellink; |
342 | 357 | print img_picto('', 'globe').' '; |
343 | -if ($action != 'edit') print '<input type="text" class="quatrevingtpercent" id="downloadinternallink" name="downloadinternellink" value="'.dol_escape_htmltag($fulllink).'">'; |
|
344 | -else print $fulllink; |
|
345 | -if ($action != 'edit') print ' <a href="'.$fulllink.'">'.$langs->trans("Download").'</a>'; // No target here. |
|
358 | +if ($action != 'edit') { |
|
359 | + print '<input type="text" class="quatrevingtpercent" id="downloadinternallink" name="downloadinternellink" value="'.dol_escape_htmltag($fulllink).'">'; |
|
360 | +} else { |
|
361 | + print $fulllink; |
|
362 | +} |
|
363 | +if ($action != 'edit') { |
|
364 | + print ' <a href="'.$fulllink.'">'.$langs->trans("Download").'</a>'; |
|
365 | +} |
|
366 | +// No target here. |
|
346 | 367 | print '</td></tr>'; |
347 | 368 | |
348 | 369 | // Link for direct external download |
349 | 370 | print '<tr><td>'; |
350 | -if ($action != 'edit') print $langs->trans("DirectDownloadLink"); |
|
351 | -else print $langs->trans("FileSharedViaALink"); |
|
371 | +if ($action != 'edit') { |
|
372 | + print $langs->trans("DirectDownloadLink"); |
|
373 | +} else { |
|
374 | + print $langs->trans("FileSharedViaALink"); |
|
375 | +} |
|
352 | 376 | print '</td><td>'; |
353 | 377 | if (!empty($object->share)) |
354 | 378 | { |
@@ -357,17 +381,28 @@ discard block |
||
357 | 381 | $forcedownload = 0; |
358 | 382 | |
359 | 383 | $paramlink = ''; |
360 | - if (!empty($object->share)) $paramlink .= ($paramlink ? '&' : '').'hashp='.$object->share; // Hash for public share |
|
361 | - if ($forcedownload) $paramlink .= ($paramlink ? '&' : '').'attachment=1'; |
|
384 | + if (!empty($object->share)) { |
|
385 | + $paramlink .= ($paramlink ? '&' : '').'hashp='.$object->share; |
|
386 | + } |
|
387 | + // Hash for public share |
|
388 | + if ($forcedownload) { |
|
389 | + $paramlink .= ($paramlink ? '&' : '').'attachment=1'; |
|
390 | + } |
|
362 | 391 | |
363 | 392 | $fulllink = $urlwithroot.'/document.php'.($paramlink ? '?'.$paramlink : ''); |
364 | 393 | //if (! empty($object->ref)) $fulllink.='&hashn='.$object->ref; // Hash of file path |
365 | 394 | //elseif (! empty($object->label)) $fulllink.='&hashc='.$object->label; // Hash of file content |
366 | 395 | |
367 | 396 | print img_picto('', 'globe').' '; |
368 | - if ($action != 'edit') print '<input type="text" class="quatrevingtpercent" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).'">'; |
|
369 | - else print $fulllink; |
|
370 | - if ($action != 'edit') print ' <a href="'.$fulllink.'">'.$langs->trans("Download").'</a>'; // No target here |
|
397 | + if ($action != 'edit') { |
|
398 | + print '<input type="text" class="quatrevingtpercent" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).'">'; |
|
399 | + } else { |
|
400 | + print $fulllink; |
|
401 | + } |
|
402 | + if ($action != 'edit') { |
|
403 | + print ' <a href="'.$fulllink.'">'.$langs->trans("Download").'</a>'; |
|
404 | + } |
|
405 | + // No target here |
|
371 | 406 | } else { |
372 | 407 | print '<input type="checkbox" name="shareenabled"'.($object->share ? ' checked="checked"' : '').' /> '; |
373 | 408 | } |
@@ -192,7 +192,9 @@ discard block |
||
192 | 192 | $arrayyears[$val['year']] = $val['year']; |
193 | 193 | } |
194 | 194 | } |
195 | -if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; |
|
195 | +if (!count($arrayyears)) { |
|
196 | + $arrayyears[$nowyear] = $nowyear; |
|
197 | +} |
|
196 | 198 | |
197 | 199 | $h = 0; |
198 | 200 | $head = array(); |
@@ -229,8 +231,12 @@ discard block |
||
229 | 231 | print '</td></tr>'; |
230 | 232 | // Year |
231 | 233 | print '<tr><td class="left">'.$langs->trans("Year").'</td><td class="left">'; |
232 | - if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; |
|
233 | - if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear; |
|
234 | + if (!in_array($year, $arrayyears)) { |
|
235 | + $arrayyears[$year] = $year; |
|
236 | + } |
|
237 | + if (!in_array($nowyear, $arrayyears)) { |
|
238 | + $arrayyears[$nowyear] = $nowyear; |
|
239 | + } |
|
234 | 240 | arsort($arrayyears); |
235 | 241 | print $form->selectarray('year', $arrayyears, $year, 0); |
236 | 242 | print '</td></tr>'; |
@@ -332,11 +332,13 @@ discard block |
||
332 | 332 | // Add extra fields object |
333 | 333 | $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.")"; |
334 | 334 | $resql = $this->db->query($sql); |
335 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
335 | + if ($resql) { |
|
336 | + // This can fail when class is used on old database (during migration for example) |
|
336 | 337 | { |
337 | 338 | while ($obj = $this->db->fetch_object($resql)) |
338 | 339 | { |
339 | 340 | $fieldname = 'extra.'.$obj->name; |
341 | + } |
|
340 | 342 | $fieldlabel = ucfirst($obj->label); |
341 | 343 | $typeFilter = "Text"; |
342 | 344 | switch ($obj->type) |
@@ -360,7 +362,9 @@ discard block |
||
360 | 362 | $var = array_keys($tmpparam['options']); |
361 | 363 | $tmp = array_shift($var); |
362 | 364 | } |
363 | - if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp; |
|
365 | + if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) { |
|
366 | + $typeFilter = "List:".$tmp; |
|
367 | + } |
|
364 | 368 | break; |
365 | 369 | } |
366 | 370 | $this->export_fields_array[$r][$fieldname] = $fieldlabel; |
@@ -372,11 +376,13 @@ discard block |
||
372 | 376 | // Add extra fields line |
373 | 377 | $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det' AND entity IN (0, ".$conf->entity.")"; |
374 | 378 | $resql = $this->db->query($sql); |
375 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
379 | + if ($resql) { |
|
380 | + // This can fail when class is used on old database (during migration for example) |
|
376 | 381 | { |
377 | 382 | while ($obj = $this->db->fetch_object($resql)) |
378 | 383 | { |
379 | 384 | $fieldname = 'extraline.'.$obj->name; |
385 | + } |
|
380 | 386 | $fieldlabel = ucfirst($obj->label); |
381 | 387 | $typeFilter = "Text"; |
382 | 388 | switch ($obj->type) |
@@ -396,8 +402,12 @@ discard block |
||
396 | 402 | case 'sellist': |
397 | 403 | $tmp = ''; |
398 | 404 | $tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null |
399 | - if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift(array_keys($tmpparam['options'])); |
|
400 | - if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp; |
|
405 | + if ($tmpparam['options'] && is_array($tmpparam['options'])) { |
|
406 | + $tmp = array_shift(array_keys($tmpparam['options'])); |
|
407 | + } |
|
408 | + if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) { |
|
409 | + $typeFilter = "List:".$tmp; |
|
410 | + } |
|
401 | 411 | break; |
402 | 412 | } |
403 | 413 | $this->export_fields_array[$r][$fieldname] = $fieldlabel; |
@@ -408,7 +418,9 @@ discard block |
||
408 | 418 | // End add extra fields line |
409 | 419 | $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
410 | 420 | $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s'; |
411 | - if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
421 | + if (is_object($user) && empty($user->rights->societe->client->voir)) { |
|
422 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
423 | + } |
|
412 | 424 | $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,'; |
413 | 425 | $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'facture_fourn as f'; |
414 | 426 | $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)'; |
@@ -418,7 +430,9 @@ discard block |
||
418 | 430 | $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; |
419 | 431 | $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn'; |
420 | 432 | $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_invoice').')'; |
421 | - if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; |
|
433 | + if (is_object($user) && empty($user->rights->societe->client->voir)) { |
|
434 | + $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; |
|
435 | + } |
|
422 | 436 | |
423 | 437 | $r++; |
424 | 438 | $this->export_code[$r] = $this->rights_class.'_'.$r; |
@@ -465,11 +479,13 @@ discard block |
||
465 | 479 | // Add extra fields object |
466 | 480 | $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.")"; |
467 | 481 | $resql = $this->db->query($sql); |
468 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
482 | + if ($resql) { |
|
483 | + // This can fail when class is used on old database (during migration for example) |
|
469 | 484 | { |
470 | 485 | while ($obj = $this->db->fetch_object($resql)) |
471 | 486 | { |
472 | 487 | $fieldname = 'extra.'.$obj->name; |
488 | + } |
|
473 | 489 | $fieldlabel = ucfirst($obj->label); |
474 | 490 | $typeFilter = "Text"; |
475 | 491 | switch ($obj->type) |
@@ -489,8 +505,12 @@ discard block |
||
489 | 505 | case 'sellist': |
490 | 506 | $tmp = ''; |
491 | 507 | $tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null |
492 | - if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift(array_keys($tmpparam['options'])); |
|
493 | - if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp; |
|
508 | + if ($tmpparam['options'] && is_array($tmpparam['options'])) { |
|
509 | + $tmp = array_shift(array_keys($tmpparam['options'])); |
|
510 | + } |
|
511 | + if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) { |
|
512 | + $typeFilter = "List:".$tmp; |
|
513 | + } |
|
494 | 514 | break; |
495 | 515 | } |
496 | 516 | $this->export_fields_array[$r][$fieldname] = $fieldlabel; |
@@ -501,7 +521,9 @@ discard block |
||
501 | 521 | // End add extra fields object |
502 | 522 | $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
503 | 523 | $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s'; |
504 | - if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
524 | + if (is_object($user) && empty($user->rights->societe->client->voir)) { |
|
525 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
526 | + } |
|
505 | 527 | $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,'; |
506 | 528 | $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'facture_fourn as f'; |
507 | 529 | $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)'; |
@@ -510,7 +532,9 @@ discard block |
||
510 | 532 | $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid'; |
511 | 533 | $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid'; |
512 | 534 | $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_invoice').')'; |
513 | - if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; |
|
535 | + if (is_object($user) && empty($user->rights->societe->client->voir)) { |
|
536 | + $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; |
|
537 | + } |
|
514 | 538 | |
515 | 539 | // Order |
516 | 540 | $r++; |
@@ -560,11 +584,13 @@ discard block |
||
560 | 584 | // Add extra fields object |
561 | 585 | $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur' AND entity IN (0, ".$conf->entity.")"; |
562 | 586 | $resql = $this->db->query($sql); |
563 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
587 | + if ($resql) { |
|
588 | + // This can fail when class is used on old database (during migration for example) |
|
564 | 589 | { |
565 | 590 | while ($obj = $this->db->fetch_object($resql)) |
566 | 591 | { |
567 | 592 | $fieldname = 'extra.'.$obj->name; |
593 | + } |
|
568 | 594 | $fieldlabel = ucfirst($obj->label); |
569 | 595 | $typeFilter = "Text"; |
570 | 596 | switch ($obj->type) |
@@ -585,8 +611,12 @@ discard block |
||
585 | 611 | $tmp = ''; |
586 | 612 | $tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null |
587 | 613 | $tmpkey = array_keys($tmpparam['options']); |
588 | - if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift($tmpkey); |
|
589 | - if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp; |
|
614 | + if ($tmpparam['options'] && is_array($tmpparam['options'])) { |
|
615 | + $tmp = array_shift($tmpkey); |
|
616 | + } |
|
617 | + if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) { |
|
618 | + $typeFilter = "List:".$tmp; |
|
619 | + } |
|
590 | 620 | break; |
591 | 621 | } |
592 | 622 | $this->export_fields_array[$r][$fieldname] = $fieldlabel; |
@@ -598,11 +628,13 @@ discard block |
||
598 | 628 | // Add extra fields line |
599 | 629 | $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseurdet' AND entity IN (0, ".$conf->entity.")"; |
600 | 630 | $resql = $this->db->query($sql); |
601 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
631 | + if ($resql) { |
|
632 | + // This can fail when class is used on old database (during migration for example) |
|
602 | 633 | { |
603 | 634 | while ($obj = $this->db->fetch_object($resql)) |
604 | 635 | { |
605 | 636 | $fieldname = 'extraline.'.$obj->name; |
637 | + } |
|
606 | 638 | $fieldlabel = ucfirst($obj->label); |
607 | 639 | $typeFilter = "Text"; |
608 | 640 | switch ($obj->type) |
@@ -627,7 +659,9 @@ discard block |
||
627 | 659 | $tmpparam_param_key = array_keys($tmpparam['options']); |
628 | 660 | $tmp = array_shift($tmpparam_param_key); |
629 | 661 | } |
630 | - if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp; |
|
662 | + if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) { |
|
663 | + $typeFilter = "List:".$tmp; |
|
664 | + } |
|
631 | 665 | break; |
632 | 666 | } |
633 | 667 | $this->export_fields_array[$r][$fieldname] = $fieldlabel; |
@@ -638,7 +672,9 @@ discard block |
||
638 | 672 | // End add extra fields line |
639 | 673 | $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
640 | 674 | $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s'; |
641 | - if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
675 | + if (is_object($user) && empty($user->rights->societe->client->voir)) { |
|
676 | + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; |
|
677 | + } |
|
642 | 678 | $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,'; |
643 | 679 | $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'commande_fournisseur as f'; |
644 | 680 | $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)'; |
@@ -650,7 +686,9 @@ discard block |
||
650 | 686 | $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; |
651 | 687 | $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande'; |
652 | 688 | $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_order').')'; |
653 | - if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; |
|
689 | + if (is_object($user) && empty($user->rights->societe->client->voir)) { |
|
690 | + $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; |
|
691 | + } |
|
654 | 692 | |
655 | 693 | //Import Supplier Invoice |
656 | 694 | //-------- |