@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public $db; |
38 | 38 | |
39 | - var $dir; // Directory with all core and external triggers files |
|
39 | + var $dir; // Directory with all core and external triggers files |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @var string[] Error codes (or messages) |
@@ -65,22 +65,22 @@ discard block |
||
65 | 65 | * @param Conf $conf Objet conf |
66 | 66 | * @return int Nb of triggers ran if no error, -Nb of triggers with errors otherwise. |
67 | 67 | */ |
68 | - function run_triggers($action,$object,$user,$langs,$conf) |
|
68 | + function run_triggers($action, $object, $user, $langs, $conf) |
|
69 | 69 | { |
70 | 70 | // phpcs:enable |
71 | 71 | // Check parameters |
72 | - if (! is_object($object) || ! is_object($conf)) // Error |
|
72 | + if (!is_object($object) || !is_object($conf)) // Error |
|
73 | 73 | { |
74 | - $this->error='function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); |
|
74 | + $this->error = 'function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); |
|
75 | 75 | dol_syslog(get_class($this).'::run_triggers '.$this->error, LOG_ERR); |
76 | - $this->errors[]=$this->error; |
|
76 | + $this->errors[] = $this->error; |
|
77 | 77 | return -1; |
78 | 78 | } |
79 | - if (! is_object($langs)) // Warning |
|
79 | + if (!is_object($langs)) // Warning |
|
80 | 80 | { |
81 | 81 | dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING); |
82 | 82 | } |
83 | - if (! is_object($user)) // Warning |
|
83 | + if (!is_object($user)) // Warning |
|
84 | 84 | { |
85 | 85 | dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING); |
86 | 86 | global $db; |
@@ -92,43 +92,43 @@ discard block |
||
92 | 92 | $files = array(); |
93 | 93 | $modules = array(); |
94 | 94 | $orders = array(); |
95 | - $i=0; |
|
95 | + $i = 0; |
|
96 | 96 | |
97 | - $dirtriggers=array_merge(array('/core/triggers'),$conf->modules_parts['triggers']); |
|
98 | - foreach($dirtriggers as $reldir) |
|
97 | + $dirtriggers = array_merge(array('/core/triggers'), $conf->modules_parts['triggers']); |
|
98 | + foreach ($dirtriggers as $reldir) |
|
99 | 99 | { |
100 | - $dir=dol_buildpath($reldir,0); |
|
101 | - $newdir=dol_osencode($dir); |
|
100 | + $dir = dol_buildpath($reldir, 0); |
|
101 | + $newdir = dol_osencode($dir); |
|
102 | 102 | //print "xx".$dir;exit; |
103 | 103 | |
104 | 104 | // Check if directory exists (we do not use dol_is_dir to avoir loading files.lib.php at each call) |
105 | - if (! is_dir($newdir)) continue; |
|
105 | + if (!is_dir($newdir)) continue; |
|
106 | 106 | |
107 | - $handle=opendir($newdir); |
|
107 | + $handle = opendir($newdir); |
|
108 | 108 | if (is_resource($handle)) |
109 | 109 | { |
110 | - while (($file = readdir($handle))!==false) |
|
110 | + while (($file = readdir($handle)) !== false) |
|
111 | 111 | { |
112 | - if (is_readable($newdir."/".$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i',$file,$reg)) |
|
112 | + if (is_readable($newdir."/".$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i', $file, $reg)) |
|
113 | 113 | { |
114 | - $part1=$reg[1]; |
|
115 | - $part2=$reg[2]; |
|
116 | - $part3=$reg[3]; |
|
114 | + $part1 = $reg[1]; |
|
115 | + $part2 = $reg[2]; |
|
116 | + $part3 = $reg[3]; |
|
117 | 117 | |
118 | 118 | $nbfile++; |
119 | 119 | |
120 | 120 | // Check if trigger file is disabled by name |
121 | - if (preg_match('/NORUN$/i',$file)) continue; |
|
121 | + if (preg_match('/NORUN$/i', $file)) continue; |
|
122 | 122 | // Check if trigger file is for a particular module |
123 | - $qualified=true; |
|
123 | + $qualified = true; |
|
124 | 124 | if (strtolower($reg[2]) != 'all') |
125 | 125 | { |
126 | - $module=preg_replace('/^mod/i','',$reg[2]); |
|
127 | - $constparam='MAIN_MODULE_'.strtoupper($module); |
|
128 | - if (empty($conf->global->$constparam)) $qualified=false; |
|
126 | + $module = preg_replace('/^mod/i', '', $reg[2]); |
|
127 | + $constparam = 'MAIN_MODULE_'.strtoupper($module); |
|
128 | + if (empty($conf->global->$constparam)) $qualified = false; |
|
129 | 129 | } |
130 | 130 | |
131 | - if (! $qualified) |
|
131 | + if (!$qualified) |
|
132 | 132 | { |
133 | 133 | //dol_syslog(get_class($this)."::run_triggers action=".$action." Triggers for file '".$file."' need module to be enabled", LOG_DEBUG); |
134 | 134 | continue; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | $modName = "Interface".ucfirst($reg[3]); |
138 | 138 | //print "file=$file - modName=$modName\n"; |
139 | - if (in_array($modName,$modules)) // $modules = list of modName already loaded |
|
139 | + if (in_array($modName, $modules)) // $modules = list of modName already loaded |
|
140 | 140 | { |
141 | 141 | $langs->load("errors"); |
142 | 142 | dol_syslog(get_class($this)."::run_triggers action=".$action." ".$langs->trans("ErrorDuplicateTrigger", $newdir."/".$file, $fullpathfiles[$modName]), LOG_WARNING); |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | include_once $newdir.'/'.$file; |
149 | 149 | //print 'Done for '.$modName."\n"; |
150 | 150 | } |
151 | - catch(Exception $e) |
|
151 | + catch (Exception $e) |
|
152 | 152 | { |
153 | 153 | dol_syslog('ko for '.$modName." ".$e->getMessage()."\n", LOG_ERR); |
154 | 154 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $modules[$i] = $modName; |
157 | 157 | $files[$i] = $file; |
158 | 158 | $fullpathfiles[$modName] = $newdir.'/'.$file; |
159 | - $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value |
|
159 | + $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value |
|
160 | 160 | |
161 | 161 | $i++; |
162 | 162 | } |
@@ -175,17 +175,17 @@ discard block |
||
175 | 175 | $objMod = new $modName($this->db); |
176 | 176 | if ($objMod) |
177 | 177 | { |
178 | - $result=0; |
|
178 | + $result = 0; |
|
179 | 179 | |
180 | 180 | if (method_exists($objMod, 'runTrigger')) // New method to implement |
181 | 181 | { |
182 | 182 | //dol_syslog(get_class($this)."::run_triggers action=".$action." Launch runTrigger for file '".$files[$key]."'", LOG_DEBUG); |
183 | - $result=$objMod->runTrigger($action,$object,$user,$langs,$conf); |
|
183 | + $result = $objMod->runTrigger($action, $object, $user, $langs, $conf); |
|
184 | 184 | } |
185 | 185 | elseif (method_exists($objMod, 'run_trigger')) // Deprecated method |
186 | 186 | { |
187 | 187 | dol_syslog(get_class($this)."::run_triggers action=".$action." Launch old method run_trigger (rename your trigger into runTrigger) for file '".$files[$key]."'", LOG_WARNING); |
188 | - $result=$objMod->run_trigger($action,$object,$user,$langs,$conf); |
|
188 | + $result = $objMod->run_trigger($action, $object, $user, $langs, $conf); |
|
189 | 189 | } |
190 | 190 | else |
191 | 191 | { |
@@ -209,8 +209,8 @@ discard block |
||
209 | 209 | //dol_syslog("Error in trigger ".$action." - Nb of error string returned = ".count($objMod->errors), LOG_ERR); |
210 | 210 | $nbtotal++; |
211 | 211 | $nbko++; |
212 | - if (! empty($objMod->errors)) $this->errors=array_merge($this->errors,$objMod->errors); |
|
213 | - else if (! empty($objMod->error)) $this->errors[]=$objMod->error; |
|
212 | + if (!empty($objMod->errors)) $this->errors = array_merge($this->errors, $objMod->errors); |
|
213 | + else if (!empty($objMod->error)) $this->errors[] = $objMod->error; |
|
214 | 214 | //dol_syslog("Error in trigger ".$action." - Nb of error string returned = ".count($this->errors), LOG_ERR); |
215 | 215 | } |
216 | 216 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * @param array $forcedirtriggers null=All default directories. This parameter is used by modulebuilder module only. |
240 | 240 | * @return array Array list of triggers |
241 | 241 | */ |
242 | - function getTriggersList($forcedirtriggers=null) |
|
242 | + function getTriggersList($forcedirtriggers = null) |
|
243 | 243 | { |
244 | 244 | global $conf, $langs, $db; |
245 | 245 | |
@@ -251,39 +251,39 @@ discard block |
||
251 | 251 | $orders = array(); |
252 | 252 | $i = 0; |
253 | 253 | |
254 | - $dirtriggers=array_merge(array('/core/triggers/'),$conf->modules_parts['triggers']); |
|
254 | + $dirtriggers = array_merge(array('/core/triggers/'), $conf->modules_parts['triggers']); |
|
255 | 255 | if (is_array($forcedirtriggers)) |
256 | 256 | { |
257 | - $dirtriggers=$forcedirtriggers; |
|
257 | + $dirtriggers = $forcedirtriggers; |
|
258 | 258 | } |
259 | 259 | |
260 | - foreach($dirtriggers as $reldir) |
|
260 | + foreach ($dirtriggers as $reldir) |
|
261 | 261 | { |
262 | - $dir=dol_buildpath($reldir,0); |
|
263 | - $newdir=dol_osencode($dir); |
|
262 | + $dir = dol_buildpath($reldir, 0); |
|
263 | + $newdir = dol_osencode($dir); |
|
264 | 264 | |
265 | 265 | // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call) |
266 | - if (! is_dir($newdir)) continue; |
|
266 | + if (!is_dir($newdir)) continue; |
|
267 | 267 | |
268 | - $handle=opendir($newdir); |
|
268 | + $handle = opendir($newdir); |
|
269 | 269 | if (is_resource($handle)) |
270 | 270 | { |
271 | - while (($file = readdir($handle))!==false) |
|
271 | + while (($file = readdir($handle)) !== false) |
|
272 | 272 | { |
273 | - if (is_readable($newdir.'/'.$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/',$file,$reg)) |
|
273 | + if (is_readable($newdir.'/'.$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/', $file, $reg)) |
|
274 | 274 | { |
275 | - if (preg_match('/\.back$/',$file)) continue; |
|
275 | + if (preg_match('/\.back$/', $file)) continue; |
|
276 | 276 | |
277 | - $part1=$reg[1]; |
|
278 | - $part2=$reg[2]; |
|
279 | - $part3=$reg[3]; |
|
277 | + $part1 = $reg[1]; |
|
278 | + $part2 = $reg[2]; |
|
279 | + $part3 = $reg[3]; |
|
280 | 280 | |
281 | 281 | $modName = 'Interface'.ucfirst($reg[3]); |
282 | 282 | //print "file=$file"; print "modName=$modName"; exit; |
283 | - if (in_array($modName,$modules)) |
|
283 | + if (in_array($modName, $modules)) |
|
284 | 284 | { |
285 | 285 | $langs->load("errors"); |
286 | - print '<div class="error">'.$langs->trans("Error").' : '.$langs->trans("ErrorDuplicateTrigger",$modName,"/htdocs/core/triggers/").'</div>'; |
|
286 | + print '<div class="error">'.$langs->trans("Error").' : '.$langs->trans("ErrorDuplicateTrigger", $modName, "/htdocs/core/triggers/").'</div>'; |
|
287 | 287 | } |
288 | 288 | else |
289 | 289 | { |
@@ -292,10 +292,10 @@ discard block |
||
292 | 292 | |
293 | 293 | $files[$i] = $file; |
294 | 294 | $fullpath[$i] = $dir.'/'.$file; |
295 | - $relpath[$i] = preg_replace('/^\//','',$reldir).'/'.$file; |
|
296 | - $iscoreorexternal[$i] = ($reldir == '/core/triggers/'?'internal':'external'); |
|
295 | + $relpath[$i] = preg_replace('/^\//', '', $reldir).'/'.$file; |
|
296 | + $iscoreorexternal[$i] = ($reldir == '/core/triggers/' ? 'internal' : 'external'); |
|
297 | 297 | $modules[$i] = $modName; |
298 | - $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value |
|
298 | + $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value |
|
299 | 299 | |
300 | 300 | $i++; |
301 | 301 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | $modName = $modules[$key]; |
316 | 316 | if (empty($modName)) continue; |
317 | 317 | |
318 | - if (! class_exists($modName)) |
|
318 | + if (!class_exists($modName)) |
|
319 | 319 | { |
320 | 320 | print 'Error: A trigger file was found but its class "'.$modName.'" was not found.'."<br>\n"; |
321 | 321 | continue; |
@@ -324,45 +324,45 @@ discard block |
||
324 | 324 | $objMod = new $modName($db); |
325 | 325 | |
326 | 326 | // Define disabledbyname and disabledbymodule |
327 | - $disabledbyname=0; |
|
328 | - $disabledbymodule=1; |
|
329 | - $module=''; |
|
327 | + $disabledbyname = 0; |
|
328 | + $disabledbymodule = 1; |
|
329 | + $module = ''; |
|
330 | 330 | |
331 | 331 | // Check if trigger file is disabled by name |
332 | - if (preg_match('/NORUN$/i',$files[$key])) $disabledbyname=1; |
|
332 | + if (preg_match('/NORUN$/i', $files[$key])) $disabledbyname = 1; |
|
333 | 333 | // Check if trigger file is for a particular module |
334 | - if (preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/i',$files[$key],$reg)) |
|
334 | + if (preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/i', $files[$key], $reg)) |
|
335 | 335 | { |
336 | - $module=preg_replace('/^mod/i','',$reg[2]); |
|
337 | - $constparam='MAIN_MODULE_'.strtoupper($module); |
|
338 | - if (strtolower($module) == 'all') $disabledbymodule=0; |
|
339 | - else if (empty($conf->global->$constparam)) $disabledbymodule=2; |
|
340 | - $triggers[$j]['module']=strtolower($module); |
|
336 | + $module = preg_replace('/^mod/i', '', $reg[2]); |
|
337 | + $constparam = 'MAIN_MODULE_'.strtoupper($module); |
|
338 | + if (strtolower($module) == 'all') $disabledbymodule = 0; |
|
339 | + else if (empty($conf->global->$constparam)) $disabledbymodule = 2; |
|
340 | + $triggers[$j]['module'] = strtolower($module); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | // We set info of modules |
344 | - $triggers[$j]['picto'] = $objMod->picto?img_object('',$objMod->picto):img_object('','generic'); |
|
344 | + $triggers[$j]['picto'] = $objMod->picto ?img_object('', $objMod->picto) : img_object('', 'generic'); |
|
345 | 345 | $triggers[$j]['file'] = $files[$key]; |
346 | 346 | $triggers[$j]['fullpath'] = $fullpath[$key]; |
347 | 347 | $triggers[$j]['relpath'] = $relpath[$key]; |
348 | 348 | $triggers[$j]['iscoreorexternal'] = $iscoreorexternal[$key]; |
349 | 349 | $triggers[$j]['version'] = $objMod->getVersion(); |
350 | - $triggers[$j]['status'] = img_picto($langs->trans("Active"),'tick'); |
|
350 | + $triggers[$j]['status'] = img_picto($langs->trans("Active"), 'tick'); |
|
351 | 351 | if ($disabledbyname > 0 || $disabledbymodule > 1) $triggers[$j]['status'] = ''; |
352 | 352 | |
353 | - $text ='<b>'.$langs->trans("Description").':</b><br>'; |
|
354 | - $text.=$objMod->getDesc().'<br>'; |
|
355 | - $text.='<br><b>'.$langs->trans("Status").':</b><br>'; |
|
353 | + $text = '<b>'.$langs->trans("Description").':</b><br>'; |
|
354 | + $text .= $objMod->getDesc().'<br>'; |
|
355 | + $text .= '<br><b>'.$langs->trans("Status").':</b><br>'; |
|
356 | 356 | if ($disabledbyname == 1) |
357 | 357 | { |
358 | - $text.=$langs->trans("TriggerDisabledByName").'<br>'; |
|
359 | - if ($disabledbymodule == 2) $text.=$langs->trans("TriggerDisabledAsModuleDisabled",$module).'<br>'; |
|
358 | + $text .= $langs->trans("TriggerDisabledByName").'<br>'; |
|
359 | + if ($disabledbymodule == 2) $text .= $langs->trans("TriggerDisabledAsModuleDisabled", $module).'<br>'; |
|
360 | 360 | } |
361 | 361 | else |
362 | 362 | { |
363 | - if ($disabledbymodule == 0) $text.=$langs->trans("TriggerAlwaysActive").'<br>'; |
|
364 | - if ($disabledbymodule == 1) $text.=$langs->trans("TriggerActiveAsModuleActive",$module).'<br>'; |
|
365 | - if ($disabledbymodule == 2) $text.=$langs->trans("TriggerDisabledAsModuleDisabled",$module).'<br>'; |
|
363 | + if ($disabledbymodule == 0) $text .= $langs->trans("TriggerAlwaysActive").'<br>'; |
|
364 | + if ($disabledbymodule == 1) $text .= $langs->trans("TriggerActiveAsModuleActive", $module).'<br>'; |
|
365 | + if ($disabledbymodule == 2) $text .= $langs->trans("TriggerDisabledAsModuleDisabled", $module).'<br>'; |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | $triggers[$j]['info'] = $text; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * @var string Error code (or message) |
36 | 36 | */ |
37 | - public $error=''; |
|
37 | + public $error = ''; |
|
38 | 38 | |
39 | 39 | public $key; |
40 | 40 | |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | * @param DoliDB $db Database handler |
45 | 45 | * @param string $key Google key |
46 | 46 | */ |
47 | - function __construct($db,$key) |
|
47 | + function __construct($db, $key) |
|
48 | 48 | { |
49 | - $this->db=$db; |
|
50 | - $this->key=$key; |
|
49 | + $this->db = $db; |
|
50 | + $this->key = $key; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | { |
64 | 64 | global $conf; |
65 | 65 | |
66 | - $i=0; |
|
66 | + $i = 0; |
|
67 | 67 | |
68 | 68 | // Desired address |
69 | 69 | $urladdress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=xml&key=".$this->key; |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | |
74 | 74 | $code = strstr($page, '<coordinates>'); |
75 | 75 | $code = strstr($code, '>'); |
76 | - $val=strpos($code, "<"); |
|
77 | - $code = substr($code, 1, $val-1); |
|
76 | + $val = strpos($code, "<"); |
|
77 | + $code = substr($code, 1, $val - 1); |
|
78 | 78 | //print $code; |
79 | 79 | //print "<br>"; |
80 | 80 | $latitude = substr($code, 0, strpos($code, ",")); |
81 | - $longitude = substr($code, strpos($code, ",")+1, dol_strlen(strpos($code, ","))-3); |
|
81 | + $longitude = substr($code, strpos($code, ",") + 1, dol_strlen(strpos($code, ",")) - 3); |
|
82 | 82 | |
83 | 83 | // Output the coordinates |
84 | 84 | //echo "Longitude: $longitude ',' Latitude: $latitude"; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \brief File of the superclass of invoices classes (customer and supplier) |
24 | 24 | */ |
25 | 25 | |
26 | -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; |
|
26 | +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Superclass for invoices classes |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | * @param int $multicurrency Return multicurrency_amount instead of amount |
98 | 98 | * @return double Remain of amount to pay |
99 | 99 | */ |
100 | - function getRemainToPay($multicurrency=0) |
|
100 | + function getRemainToPay($multicurrency = 0) |
|
101 | 101 | { |
102 | - $alreadypaid=0; |
|
103 | - $alreadypaid+=$this->getSommePaiement($multicurrency); |
|
104 | - $alreadypaid+=$this->getSumDepositsUsed($multicurrency); |
|
105 | - $alreadypaid+=$this->getSumCreditNotesUsed($multicurrency); |
|
102 | + $alreadypaid = 0; |
|
103 | + $alreadypaid += $this->getSommePaiement($multicurrency); |
|
104 | + $alreadypaid += $this->getSumDepositsUsed($multicurrency); |
|
105 | + $alreadypaid += $this->getSumCreditNotesUsed($multicurrency); |
|
106 | 106 | return $this->total_ttc - $alreadypaid; |
107 | 107 | } |
108 | 108 | |
@@ -112,22 +112,22 @@ discard block |
||
112 | 112 | * @param int $multicurrency Return multicurrency_amount instead of amount |
113 | 113 | * @return int Amount of payment already done, <0 if KO |
114 | 114 | */ |
115 | - function getSommePaiement($multicurrency=0) |
|
115 | + function getSommePaiement($multicurrency = 0) |
|
116 | 116 | { |
117 | - $table='paiement_facture'; |
|
118 | - $field='fk_facture'; |
|
117 | + $table = 'paiement_facture'; |
|
118 | + $field = 'fk_facture'; |
|
119 | 119 | if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
120 | 120 | { |
121 | - $table='paiementfourn_facturefourn'; |
|
122 | - $field='fk_facturefourn'; |
|
121 | + $table = 'paiementfourn_facturefourn'; |
|
122 | + $field = 'fk_facturefourn'; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | $sql = 'SELECT sum(amount) as amount, sum(multicurrency_amount) as multicurrency_amount'; |
126 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$table; |
|
127 | - $sql.= ' WHERE '.$field.' = '.$this->id; |
|
126 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$table; |
|
127 | + $sql .= ' WHERE '.$field.' = '.$this->id; |
|
128 | 128 | |
129 | 129 | dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); |
130 | - $resql=$this->db->query($sql); |
|
130 | + $resql = $this->db->query($sql); |
|
131 | 131 | if ($resql) |
132 | 132 | { |
133 | 133 | $obj = $this->db->fetch_object($resql); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } |
138 | 138 | else |
139 | 139 | { |
140 | - $this->error=$this->db->lasterror(); |
|
140 | + $this->error = $this->db->lasterror(); |
|
141 | 141 | return -1; |
142 | 142 | } |
143 | 143 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @param int $multicurrency Return multicurrency_amount instead of amount |
150 | 150 | * @return int <0 if KO, Sum of deposits amount otherwise |
151 | 151 | */ |
152 | - function getSumDepositsUsed($multicurrency=0) |
|
152 | + function getSumDepositsUsed($multicurrency = 0) |
|
153 | 153 | { |
154 | 154 | if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
155 | 155 | { |
@@ -159,15 +159,15 @@ discard block |
||
159 | 159 | |
160 | 160 | require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; |
161 | 161 | |
162 | - $discountstatic=new DiscountAbsolute($this->db); |
|
163 | - $result=$discountstatic->getSumDepositsUsed($this, $multicurrency); |
|
162 | + $discountstatic = new DiscountAbsolute($this->db); |
|
163 | + $result = $discountstatic->getSumDepositsUsed($this, $multicurrency); |
|
164 | 164 | if ($result >= 0) |
165 | 165 | { |
166 | 166 | return $result; |
167 | 167 | } |
168 | 168 | else |
169 | 169 | { |
170 | - $this->error=$discountstatic->error; |
|
170 | + $this->error = $discountstatic->error; |
|
171 | 171 | return -1; |
172 | 172 | } |
173 | 173 | } |
@@ -178,19 +178,19 @@ discard block |
||
178 | 178 | * @param int $multicurrency Return multicurrency_amount instead of amount |
179 | 179 | * @return int <0 if KO, Sum of credit notes and deposits amount otherwise |
180 | 180 | */ |
181 | - function getSumCreditNotesUsed($multicurrency=0) |
|
181 | + function getSumCreditNotesUsed($multicurrency = 0) |
|
182 | 182 | { |
183 | 183 | require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; |
184 | 184 | |
185 | - $discountstatic=new DiscountAbsolute($this->db); |
|
186 | - $result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency); |
|
185 | + $discountstatic = new DiscountAbsolute($this->db); |
|
186 | + $result = $discountstatic->getSumCreditNotesUsed($this, $multicurrency); |
|
187 | 187 | if ($result >= 0) |
188 | 188 | { |
189 | 189 | return $result; |
190 | 190 | } |
191 | 191 | else |
192 | 192 | { |
193 | - $this->error=$discountstatic->error; |
|
193 | + $this->error = $discountstatic->error; |
|
194 | 194 | return -1; |
195 | 195 | } |
196 | 196 | } |
@@ -202,13 +202,13 @@ discard block |
||
202 | 202 | */ |
203 | 203 | function getListIdAvoirFromInvoice() |
204 | 204 | { |
205 | - $idarray=array(); |
|
205 | + $idarray = array(); |
|
206 | 206 | |
207 | 207 | $sql = 'SELECT rowid'; |
208 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
209 | - $sql.= ' WHERE fk_facture_source = '.$this->id; |
|
210 | - $sql.= ' AND type = 2'; |
|
211 | - $resql=$this->db->query($sql); |
|
208 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
209 | + $sql .= ' WHERE fk_facture_source = '.$this->id; |
|
210 | + $sql .= ' AND type = 2'; |
|
211 | + $resql = $this->db->query($sql); |
|
212 | 212 | if ($resql) |
213 | 213 | { |
214 | 214 | $num = $this->db->num_rows($resql); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | while ($i < $num) |
217 | 217 | { |
218 | 218 | $row = $this->db->fetch_row($resql); |
219 | - $idarray[]=$row[0]; |
|
219 | + $idarray[] = $row[0]; |
|
220 | 220 | $i++; |
221 | 221 | } |
222 | 222 | } |
@@ -233,21 +233,21 @@ discard block |
||
233 | 233 | * @param string $option filtre sur statut ('', 'validated', ...) |
234 | 234 | * @return int <0 si KO, 0 si aucune facture ne remplace, id facture sinon |
235 | 235 | */ |
236 | - function getIdReplacingInvoice($option='') |
|
236 | + function getIdReplacingInvoice($option = '') |
|
237 | 237 | { |
238 | 238 | $sql = 'SELECT rowid'; |
239 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
240 | - $sql.= ' WHERE fk_facture_source = '.$this->id; |
|
241 | - $sql.= ' AND type < 2'; |
|
242 | - if ($option == 'validated') $sql.= ' AND fk_statut = 1'; |
|
239 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element; |
|
240 | + $sql .= ' WHERE fk_facture_source = '.$this->id; |
|
241 | + $sql .= ' AND type < 2'; |
|
242 | + if ($option == 'validated') $sql .= ' AND fk_statut = 1'; |
|
243 | 243 | // PROTECTION BAD DATA |
244 | 244 | // Au cas ou base corrompue et qu'il y a une facture de remplacement validee |
245 | 245 | // et une autre non, on donne priorite a la validee. |
246 | 246 | // Ne devrait pas arriver (sauf si acces concurrentiel et que 2 personnes |
247 | 247 | // ont cree en meme temps une facture de remplacement pour la meme facture) |
248 | - $sql.= ' ORDER BY fk_statut DESC'; |
|
248 | + $sql .= ' ORDER BY fk_statut DESC'; |
|
249 | 249 | |
250 | - $resql=$this->db->query($sql); |
|
250 | + $resql = $this->db->query($sql); |
|
251 | 251 | if ($resql) |
252 | 252 | { |
253 | 253 | $obj = $this->db->fetch_object($resql); |
@@ -274,43 +274,43 @@ discard block |
||
274 | 274 | * @param string $filtertype 1 to filter on type of payment == 'PRE' |
275 | 275 | * @return array Array with list of payments |
276 | 276 | */ |
277 | - function getListOfPayments($filtertype='') |
|
277 | + function getListOfPayments($filtertype = '') |
|
278 | 278 | { |
279 | - $retarray=array(); |
|
279 | + $retarray = array(); |
|
280 | 280 | |
281 | - $table='paiement_facture'; |
|
282 | - $table2='paiement'; |
|
283 | - $field='fk_facture'; |
|
284 | - $field2='fk_paiement'; |
|
285 | - $sharedentity='facture'; |
|
281 | + $table = 'paiement_facture'; |
|
282 | + $table2 = 'paiement'; |
|
283 | + $field = 'fk_facture'; |
|
284 | + $field2 = 'fk_paiement'; |
|
285 | + $sharedentity = 'facture'; |
|
286 | 286 | if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') |
287 | 287 | { |
288 | - $table='paiementfourn_facturefourn'; |
|
289 | - $table2='paiementfourn'; |
|
290 | - $field='fk_facturefourn'; |
|
291 | - $field2='fk_paiementfourn'; |
|
292 | - $sharedentity='facture_fourn'; |
|
288 | + $table = 'paiementfourn_facturefourn'; |
|
289 | + $table2 = 'paiementfourn'; |
|
290 | + $field = 'fk_facturefourn'; |
|
291 | + $field2 = 'fk_paiementfourn'; |
|
292 | + $sharedentity = 'facture_fourn'; |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | $sql = 'SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code'; |
296 | - $sql.= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t'; |
|
297 | - $sql.= ' WHERE pf.'.$field.' = '.$this->id; |
|
296 | + $sql .= ' FROM '.MAIN_DB_PREFIX.$table.' as pf, '.MAIN_DB_PREFIX.$table2.' as p, '.MAIN_DB_PREFIX.'c_paiement as t'; |
|
297 | + $sql .= ' WHERE pf.'.$field.' = '.$this->id; |
|
298 | 298 | //$sql.= ' WHERE pf.'.$field.' = 1'; |
299 | - $sql.= ' AND pf.'.$field2.' = p.rowid'; |
|
300 | - $sql.= ' AND p.fk_paiement = t.id'; |
|
301 | - $sql.= ' AND p.entity IN (' . getEntity($sharedentity).')'; |
|
302 | - if ($filtertype) $sql.=" AND t.code='PRE'"; |
|
299 | + $sql .= ' AND pf.'.$field2.' = p.rowid'; |
|
300 | + $sql .= ' AND p.fk_paiement = t.id'; |
|
301 | + $sql .= ' AND p.entity IN ('.getEntity($sharedentity).')'; |
|
302 | + if ($filtertype) $sql .= " AND t.code='PRE'"; |
|
303 | 303 | |
304 | 304 | dol_syslog(get_class($this)."::getListOfPayments", LOG_DEBUG); |
305 | - $resql=$this->db->query($sql); |
|
305 | + $resql = $this->db->query($sql); |
|
306 | 306 | if ($resql) |
307 | 307 | { |
308 | 308 | $num = $this->db->num_rows($resql); |
309 | - $i=0; |
|
309 | + $i = 0; |
|
310 | 310 | while ($i < $num) |
311 | 311 | { |
312 | 312 | $obj = $this->db->fetch_object($resql); |
313 | - $retarray[]=array('amount'=>$obj->amount,'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); |
|
313 | + $retarray[] = array('amount'=>$obj->amount, 'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref); |
|
314 | 314 | $i++; |
315 | 315 | } |
316 | 316 | $this->db->free($resql); |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | } |
319 | 319 | else |
320 | 320 | { |
321 | - $this->error=$this->db->lasterror(); |
|
321 | + $this->error = $this->db->lasterror(); |
|
322 | 322 | dol_print_error($this->db); |
323 | 323 | return array(); |
324 | 324 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | return 1; |
353 | 353 | } |
354 | 354 | |
355 | - if (! empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) return 0; |
|
355 | + if (!empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) return 0; |
|
356 | 356 | |
357 | 357 | // If not a draft invoice and not temporary invoice |
358 | 358 | if ($tmppart !== 'PROV') |
@@ -363,8 +363,8 @@ discard block |
||
363 | 363 | // Get last number of validated invoice |
364 | 364 | if ($this->element != 'invoice_supplier') |
365 | 365 | { |
366 | - if (empty($this->thirdparty)) $this->fetch_thirdparty(); // We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag). |
|
367 | - $maxref = $this->getNextNumRef($this->thirdparty,'last'); |
|
366 | + if (empty($this->thirdparty)) $this->fetch_thirdparty(); // We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag). |
|
367 | + $maxref = $this->getNextNumRef($this->thirdparty, 'last'); |
|
368 | 368 | |
369 | 369 | // If there is no invoice into the reset range and not already dispatched, we can delete |
370 | 370 | // If invoice to delete is last one and not already dispatched, we can delete |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | if ($this->situation_cycle_ref && method_exists($this, 'is_last_in_cycle')) |
377 | 377 | { |
378 | 378 | $last = $this->is_last_in_cycle(); |
379 | - if (! $last) return -3; |
|
379 | + if (!$last) return -3; |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | } |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement"); |
436 | 436 | elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir"); |
437 | 437 | elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit"); |
438 | - elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. |
|
438 | + elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used. |
|
439 | 439 | elseif ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation"); |
440 | 440 | return $langs->trans("Unknown"); |
441 | 441 | } |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) |
448 | 448 | * @return string Label of status |
449 | 449 | */ |
450 | - function getLibStatut($mode=0, $alreadypaid=-1) |
|
450 | + function getLibStatut($mode = 0, $alreadypaid = -1) |
|
451 | 451 | { |
452 | 452 | return $this->LibStatut($this->paye, $this->statut, $mode, $alreadypaid, $this->type); |
453 | 453 | } |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | * @param int $type Type invoice |
464 | 464 | * @return string Label of status |
465 | 465 | */ |
466 | - function LibStatut($paye, $status, $mode=0, $alreadypaid=-1, $type=0) |
|
466 | + function LibStatut($paye, $status, $mode = 0, $alreadypaid = -1, $type = 0) |
|
467 | 467 | { |
468 | 468 | // phpcs:enable |
469 | 469 | global $langs; |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | //print "$paye,$status,$mode,$alreadypaid,$type"; |
473 | 473 | if ($mode == 0) |
474 | 474 | { |
475 | - $prefix=''; |
|
476 | - if (! $paye) |
|
475 | + $prefix = ''; |
|
476 | + if (!$paye) |
|
477 | 477 | { |
478 | 478 | if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); |
479 | 479 | elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); |
@@ -483,15 +483,15 @@ discard block |
||
483 | 483 | } |
484 | 484 | else |
485 | 485 | { |
486 | - if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note |
|
487 | - elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); // deposit invoice |
|
486 | + if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); // credit note |
|
487 | + elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted'); // deposit invoice |
|
488 | 488 | else return $langs->trans('Bill'.$prefix.'StatusPaid'); |
489 | 489 | } |
490 | 490 | } |
491 | 491 | elseif ($mode == 1) |
492 | 492 | { |
493 | - $prefix='Short'; |
|
494 | - if (! $paye) |
|
493 | + $prefix = 'Short'; |
|
494 | + if (!$paye) |
|
495 | 495 | { |
496 | 496 | if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); |
497 | 497 | elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled'); |
@@ -508,79 +508,79 @@ discard block |
||
508 | 508 | } |
509 | 509 | elseif ($mode == 2) |
510 | 510 | { |
511 | - $prefix='Short'; |
|
512 | - if (! $paye) |
|
511 | + $prefix = 'Short'; |
|
512 | + if (!$paye) |
|
513 | 513 | { |
514 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft'); |
|
515 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
516 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
517 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
518 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); |
|
514 | + if ($status == 0) return img_picto($langs->trans('BillStatusDraft'), 'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft'); |
|
515 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'), 'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
516 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'), 'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
517 | + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'), 'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); |
|
518 | + else return img_picto($langs->trans('BillStatusStarted'), 'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); |
|
519 | 519 | } |
520 | 520 | else |
521 | 521 | { |
522 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
523 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted'); |
|
524 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid'); |
|
522 | + if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'), 'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted'); |
|
523 | + elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'), 'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted'); |
|
524 | + else return img_picto($langs->trans('BillStatusPaid'), 'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid'); |
|
525 | 525 | } |
526 | 526 | } |
527 | 527 | elseif ($mode == 3) |
528 | 528 | { |
529 | - $prefix='Short'; |
|
530 | - if (! $paye) |
|
529 | + $prefix = 'Short'; |
|
530 | + if (!$paye) |
|
531 | 531 | { |
532 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
533 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
534 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
535 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
|
536 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
532 | + if ($status == 0) return img_picto($langs->trans('BillStatusDraft'), 'statut0'); |
|
533 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'), 'statut5'); |
|
534 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'), 'statut9'); |
|
535 | + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'), 'statut1'); |
|
536 | + else return img_picto($langs->trans('BillStatusStarted'), 'statut3'); |
|
537 | 537 | } |
538 | 538 | else |
539 | 539 | { |
540 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
541 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
542 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
540 | + if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'), 'statut6'); |
|
541 | + elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'), 'statut6'); |
|
542 | + else return img_picto($langs->trans('BillStatusPaid'), 'statut6'); |
|
543 | 543 | } |
544 | 544 | } |
545 | 545 | elseif ($mode == 4) |
546 | 546 | { |
547 | - $prefix=''; |
|
548 | - if (! $paye) |
|
547 | + $prefix = ''; |
|
548 | + if (!$paye) |
|
549 | 549 | { |
550 | - if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft'); |
|
551 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
552 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
553 | - elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid'); |
|
554 | - else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted'); |
|
550 | + if ($status == 0) return img_picto($langs->trans('BillStatusDraft'), 'statut0').' '.$langs->trans('BillStatusDraft'); |
|
551 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'), 'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); |
|
552 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'), 'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); |
|
553 | + elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'), 'statut1').' '.$langs->trans('BillStatusNotPaid'); |
|
554 | + else return img_picto($langs->trans('BillStatusStarted'), 'statut3').' '.$langs->trans('BillStatusStarted'); |
|
555 | 555 | } |
556 | 556 | else |
557 | 557 | { |
558 | - if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted'); |
|
559 | - elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('BillStatusConverted'); |
|
560 | - else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('BillStatusPaid'); |
|
558 | + if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'), 'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted'); |
|
559 | + elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'), 'statut6').' '.$langs->trans('BillStatusConverted'); |
|
560 | + else return img_picto($langs->trans('BillStatusPaid'), 'statut6').' '.$langs->trans('BillStatusPaid'); |
|
561 | 561 | } |
562 | 562 | } |
563 | 563 | elseif ($mode == 5 || $mode == 6) |
564 | 564 | { |
565 | - $prefix=''; |
|
566 | - if ($mode == 5) $prefix='Short'; |
|
567 | - if (! $paye) |
|
565 | + $prefix = ''; |
|
566 | + if ($mode == 5) $prefix = 'Short'; |
|
567 | + if (!$paye) |
|
568 | 568 | { |
569 | - if ($status == 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'),'statut0'); |
|
570 | - elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'),'statut5'); |
|
571 | - elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); |
|
569 | + if ($status == 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'), 'statut0'); |
|
570 | + elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'), 'statut5'); |
|
571 | + elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'), 'statut9'); |
|
572 | 572 | elseif ($alreadypaid <= 0) |
573 | 573 | { |
574 | - if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'),'statut1'); |
|
575 | - return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotPaid').' </span>'.img_picto($langs->trans('BillStatusNotPaid'),'statut1'); |
|
574 | + if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'), 'statut1'); |
|
575 | + return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotPaid').' </span>'.img_picto($langs->trans('BillStatusNotPaid'), 'statut1'); |
|
576 | 576 | } |
577 | - else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusStarted').' </span>'.img_picto($langs->trans('BillStatusStarted'),'statut3'); |
|
577 | + else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusStarted').' </span>'.img_picto($langs->trans('BillStatusStarted'), 'statut3'); |
|
578 | 578 | } |
579 | 579 | else |
580 | 580 | { |
581 | - if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' </span>'.img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6'); |
|
582 | - elseif ($type == self::TYPE_DEPOSIT) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusConverted').' </span>'.img_picto($langs->trans('BillStatusConverted'),'statut6'); |
|
583 | - else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaid').' </span>'.img_picto($langs->trans('BillStatusPaid'),'statut6'); |
|
581 | + if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' </span>'.img_picto($langs->trans('BillStatusPaidBackOrConverted'), 'statut6'); |
|
582 | + elseif ($type == self::TYPE_DEPOSIT) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusConverted').' </span>'.img_picto($langs->trans('BillStatusConverted'), 'statut6'); |
|
583 | + else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaid').' </span>'.img_picto($langs->trans('BillStatusPaid'), 'statut6'); |
|
584 | 584 | } |
585 | 585 | } |
586 | 586 | } |
@@ -593,26 +593,26 @@ discard block |
||
593 | 593 | * @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition. |
594 | 594 | * @return date Date limite de reglement si ok, <0 si ko |
595 | 595 | */ |
596 | - function calculate_date_lim_reglement($cond_reglement=0) |
|
596 | + function calculate_date_lim_reglement($cond_reglement = 0) |
|
597 | 597 | { |
598 | 598 | // phpcs:enable |
599 | - if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code; |
|
600 | - if (! $cond_reglement) $cond_reglement=$this->cond_reglement_id; |
|
599 | + if (!$cond_reglement) $cond_reglement = $this->cond_reglement_code; |
|
600 | + if (!$cond_reglement) $cond_reglement = $this->cond_reglement_id; |
|
601 | 601 | |
602 | - $cdr_nbjour=0; |
|
603 | - $cdr_type=0; |
|
604 | - $cdr_decalage=0; |
|
602 | + $cdr_nbjour = 0; |
|
603 | + $cdr_type = 0; |
|
604 | + $cdr_decalage = 0; |
|
605 | 605 | |
606 | 606 | $sqltemp = 'SELECT c.type_cdr, c.nbjour, c.decalage'; |
607 | - $sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; |
|
608 | - if (is_numeric($cond_reglement)) $sqltemp.= " WHERE c.rowid=".$cond_reglement; |
|
607 | + $sqltemp .= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; |
|
608 | + if (is_numeric($cond_reglement)) $sqltemp .= " WHERE c.rowid=".$cond_reglement; |
|
609 | 609 | else { |
610 | - $sqltemp.= " WHERE c.entity IN (".getEntity('c_payment_term').")"; |
|
611 | - $sqltemp.= " AND c.code='".$this->db->escape($cond_reglement)."'"; |
|
610 | + $sqltemp .= " WHERE c.entity IN (".getEntity('c_payment_term').")"; |
|
611 | + $sqltemp .= " AND c.code='".$this->db->escape($cond_reglement)."'"; |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | dol_syslog(get_class($this).'::calculate_date_lim_reglement', LOG_DEBUG); |
615 | - $resqltemp=$this->db->query($sqltemp); |
|
615 | + $resqltemp = $this->db->query($sqltemp); |
|
616 | 616 | if ($resqltemp) |
617 | 617 | { |
618 | 618 | if ($this->db->num_rows($resqltemp)) |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | } |
626 | 626 | else |
627 | 627 | { |
628 | - $this->error=$this->db->error(); |
|
628 | + $this->error = $this->db->error(); |
|
629 | 629 | return -1; |
630 | 630 | } |
631 | 631 | $this->db->free($resqltemp); |
@@ -644,8 +644,8 @@ discard block |
||
644 | 644 | { |
645 | 645 | $datelim = $this->date + ($cdr_nbjour * 3600 * 24); |
646 | 646 | |
647 | - $mois=date('m', $datelim); |
|
648 | - $annee=date('Y', $datelim); |
|
647 | + $mois = date('m', $datelim); |
|
648 | + $annee = date('Y', $datelim); |
|
649 | 649 | if ($mois == 12) |
650 | 650 | { |
651 | 651 | $mois = 1; |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | $mois += 1; |
657 | 657 | } |
658 | 658 | // On se deplace au debut du mois suivant, et on retire un jour |
659 | - $datelim=dol_mktime(12,0,0,$mois,1,$annee); |
|
659 | + $datelim = dol_mktime(12, 0, 0, $mois, 1, $annee); |
|
660 | 660 | $datelim -= (3600 * 24); |
661 | 661 | |
662 | 662 | $datelim += ($cdr_decalage * 3600 * 24); |
@@ -666,9 +666,9 @@ discard block |
||
666 | 666 | { |
667 | 667 | $datelim = $this->date + ($cdr_nbjour * 3600 * 24); |
668 | 668 | |
669 | - $date_piece = dol_mktime(0, 0, 0, date('m', $datelim),date('d', $datelim),date('Y', $datelim)); // Sans les heures minutes et secondes |
|
669 | + $date_piece = dol_mktime(0, 0, 0, date('m', $datelim), date('d', $datelim), date('Y', $datelim)); // Sans les heures minutes et secondes |
|
670 | 670 | $date_lim_current = dol_mktime(0, 0, 0, date('m', $datelim), $cdr_decalage, date('Y', $datelim)); // Sans les heures minutes et secondes |
671 | - $date_lim_next = dol_time_plus_duree($date_lim_current, 1, 'm'); // Add 1 month |
|
671 | + $date_lim_next = dol_time_plus_duree($date_lim_current, 1, 'm'); // Add 1 month |
|
672 | 672 | |
673 | 673 | $diff = $date_piece - $date_lim_current; |
674 | 674 | |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | |
684 | 684 | |
685 | 685 | |
686 | -require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php'; |
|
686 | +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; |
|
687 | 687 | |
688 | 688 | /** |
689 | 689 | * Parent class of all other business classes for details of elements (invoices, contracts, proposals, orders, ...) |
@@ -24,17 +24,17 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * @var string ID to identify managed object |
26 | 26 | */ |
27 | - public $element='comment'; |
|
27 | + public $element = 'comment'; |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @var string Name of table without prefix where object is stored |
31 | 31 | */ |
32 | - public $table_element='comment'; |
|
32 | + public $table_element = 'comment'; |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * @var int Field with ID of parent key if this field has a parent |
36 | 36 | */ |
37 | - public $fk_element =''; |
|
37 | + public $fk_element = ''; |
|
38 | 38 | |
39 | 39 | public $element_type; |
40 | 40 | |
@@ -82,30 +82,30 @@ discard block |
||
82 | 82 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
83 | 83 | * @return int <0 if KO, Id of created object if OK |
84 | 84 | */ |
85 | - function create($user, $notrigger=0) |
|
85 | + function create($user, $notrigger = 0) |
|
86 | 86 | { |
87 | 87 | global $conf, $langs; |
88 | 88 | |
89 | - $error=0; |
|
89 | + $error = 0; |
|
90 | 90 | |
91 | 91 | // Insert request |
92 | 92 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."comment ("; |
93 | - $sql.= "description"; |
|
94 | - $sql.= ", datec"; |
|
95 | - $sql.= ", fk_element"; |
|
96 | - $sql.= ", element_type"; |
|
97 | - $sql.= ", fk_user_author"; |
|
98 | - $sql.= ", entity"; |
|
99 | - $sql.= ", import_key"; |
|
100 | - $sql.= ") VALUES ("; |
|
101 | - $sql.= "'".$this->db->escape($this->description)."'"; |
|
102 | - $sql.= ", ".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null'); |
|
103 | - $sql.= ", '".(isset($this->fk_element)?$this->fk_element:"null")."'"; |
|
104 | - $sql.= ", '".$this->db->escape($this->element_type)."'"; |
|
105 | - $sql.= ", '".(isset($this->fk_user_author)?$this->fk_user_author:"null")."'"; |
|
106 | - $sql.= ", ".(!empty($this->entity)?$this->entity:'1'); |
|
107 | - $sql.= ", ".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); |
|
108 | - $sql.= ")"; |
|
93 | + $sql .= "description"; |
|
94 | + $sql .= ", datec"; |
|
95 | + $sql .= ", fk_element"; |
|
96 | + $sql .= ", element_type"; |
|
97 | + $sql .= ", fk_user_author"; |
|
98 | + $sql .= ", entity"; |
|
99 | + $sql .= ", import_key"; |
|
100 | + $sql .= ") VALUES ("; |
|
101 | + $sql .= "'".$this->db->escape($this->description)."'"; |
|
102 | + $sql .= ", ".($this->datec != '' ? "'".$this->db->idate($this->datec)."'" : 'null'); |
|
103 | + $sql .= ", '".(isset($this->fk_element) ? $this->fk_element : "null")."'"; |
|
104 | + $sql .= ", '".$this->db->escape($this->element_type)."'"; |
|
105 | + $sql .= ", '".(isset($this->fk_user_author) ? $this->fk_user_author : "null")."'"; |
|
106 | + $sql .= ", ".(!empty($this->entity) ? $this->entity : '1'); |
|
107 | + $sql .= ", ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); |
|
108 | + $sql .= ")"; |
|
109 | 109 | |
110 | 110 | //var_dump($this->db); |
111 | 111 | //echo $sql; |
@@ -113,17 +113,17 @@ discard block |
||
113 | 113 | $this->db->begin(); |
114 | 114 | |
115 | 115 | dol_syslog(get_class($this)."::create", LOG_DEBUG); |
116 | - $resql=$this->db->query($sql); |
|
117 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
116 | + $resql = $this->db->query($sql); |
|
117 | + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
|
118 | 118 | |
119 | - if (! $error) |
|
119 | + if (!$error) |
|
120 | 120 | { |
121 | 121 | $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_comment"); |
122 | 122 | |
123 | - if (! $notrigger) |
|
123 | + if (!$notrigger) |
|
124 | 124 | { |
125 | 125 | // Call trigger |
126 | - $result=$this->call_trigger('TASK_COMMENT_CREATE',$user); |
|
126 | + $result = $this->call_trigger('TASK_COMMENT_CREATE', $user); |
|
127 | 127 | if ($result < 0) { $error++; } |
128 | 128 | // End call triggers |
129 | 129 | } |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | // Commit or rollback |
133 | 133 | if ($error) |
134 | 134 | { |
135 | - foreach($this->errors as $errmsg) |
|
135 | + foreach ($this->errors as $errmsg) |
|
136 | 136 | { |
137 | 137 | dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); |
138 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
138 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
139 | 139 | } |
140 | 140 | $this->db->rollback(); |
141 | - return -1*$error; |
|
141 | + return -1 * $error; |
|
142 | 142 | } |
143 | 143 | else |
144 | 144 | { |
@@ -155,25 +155,25 @@ discard block |
||
155 | 155 | * @param int $ref ref object |
156 | 156 | * @return int <0 if KO, 0 if not found, >0 if OK |
157 | 157 | */ |
158 | - function fetch($id, $ref='') |
|
158 | + function fetch($id, $ref = '') |
|
159 | 159 | { |
160 | 160 | global $langs; |
161 | 161 | |
162 | 162 | $sql = "SELECT"; |
163 | - $sql.= " c.rowid,"; |
|
164 | - $sql.= " c.description,"; |
|
165 | - $sql.= " c.datec,"; |
|
166 | - $sql.= " c.tms,"; |
|
167 | - $sql.= " c.fk_element,"; |
|
168 | - $sql.= " c.element_type,"; |
|
169 | - $sql.= " c.fk_user_author,"; |
|
170 | - $sql.= " c.entity,"; |
|
171 | - $sql.= " c.import_key"; |
|
172 | - $sql.= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
173 | - $sql.= " WHERE c.rowid = ".$id; |
|
163 | + $sql .= " c.rowid,"; |
|
164 | + $sql .= " c.description,"; |
|
165 | + $sql .= " c.datec,"; |
|
166 | + $sql .= " c.tms,"; |
|
167 | + $sql .= " c.fk_element,"; |
|
168 | + $sql .= " c.element_type,"; |
|
169 | + $sql .= " c.fk_user_author,"; |
|
170 | + $sql .= " c.entity,"; |
|
171 | + $sql .= " c.import_key"; |
|
172 | + $sql .= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
173 | + $sql .= " WHERE c.rowid = ".$id; |
|
174 | 174 | |
175 | 175 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
176 | - $resql=$this->db->query($sql); |
|
176 | + $resql = $this->db->query($sql); |
|
177 | 177 | if ($resql) |
178 | 178 | { |
179 | 179 | $num_rows = $this->db->num_rows($resql); |
@@ -182,14 +182,14 @@ discard block |
||
182 | 182 | { |
183 | 183 | $obj = $this->db->fetch_object($resql); |
184 | 184 | |
185 | - $this->id = $obj->rowid; |
|
186 | - $this->description = $obj->description; |
|
187 | - $this->element_type = $obj->element_type; |
|
188 | - $this->datec = $this->db->jdate($obj->datec); |
|
189 | - $this->tms = $obj->tms; |
|
190 | - $this->fk_user_author = $obj->fk_user_author; |
|
185 | + $this->id = $obj->rowid; |
|
186 | + $this->description = $obj->description; |
|
187 | + $this->element_type = $obj->element_type; |
|
188 | + $this->datec = $this->db->jdate($obj->datec); |
|
189 | + $this->tms = $obj->tms; |
|
190 | + $this->fk_user_author = $obj->fk_user_author; |
|
191 | 191 | $this->fk_element = $obj->fk_element; |
192 | - $this->entity = $obj->entity; |
|
192 | + $this->entity = $obj->entity; |
|
193 | 193 | $this->import_key = $obj->import_key; |
194 | 194 | } |
195 | 195 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | } |
201 | 201 | else |
202 | 202 | { |
203 | - $this->error="Error ".$this->db->lasterror(); |
|
203 | + $this->error = "Error ".$this->db->lasterror(); |
|
204 | 204 | return -1; |
205 | 205 | } |
206 | 206 | } |
@@ -213,40 +213,40 @@ discard block |
||
213 | 213 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
214 | 214 | * @return int <=0 if KO, >0 if OK |
215 | 215 | */ |
216 | - function update(User $user, $notrigger=0) |
|
216 | + function update(User $user, $notrigger = 0) |
|
217 | 217 | { |
218 | 218 | global $conf, $langs; |
219 | - $error=0; |
|
219 | + $error = 0; |
|
220 | 220 | |
221 | 221 | // Clean parameters |
222 | - if (isset($this->fk_element)) $this->fk_project=(int) trim($this->fk_element); |
|
223 | - if (isset($this->fk_user_author)) $this->fk_user_author=(int) trim($this->fk_user_author); |
|
224 | - if (isset($this->description)) $this->description=trim($this->description); |
|
222 | + if (isset($this->fk_element)) $this->fk_project = (int) trim($this->fk_element); |
|
223 | + if (isset($this->fk_user_author)) $this->fk_user_author = (int) trim($this->fk_user_author); |
|
224 | + if (isset($this->description)) $this->description = trim($this->description); |
|
225 | 225 | |
226 | 226 | |
227 | 227 | // Update request |
228 | 228 | $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_comment SET"; |
229 | - $sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").","; |
|
230 | - $sql.= " datec=".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null').","; |
|
231 | - $sql.= " fk_element=".(isset($this->fk_element)?$this->fk_element:"null").","; |
|
232 | - $sql.= " element_type='".$this->db->escape($this->element_type)."',"; |
|
233 | - $sql.= " fk_user_author=".(isset($this->fk_user_author)?$this->fk_user_author:"null").","; |
|
234 | - $sql.= " entity=".(!empty($this->entity)?$this->entity:'1').","; |
|
235 | - $sql.= " import_key=".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); |
|
236 | - $sql.= " WHERE rowid=".$this->id; |
|
229 | + $sql .= " description=".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "null").","; |
|
230 | + $sql .= " datec=".($this->datec != '' ? "'".$this->db->idate($this->datec)."'" : 'null').","; |
|
231 | + $sql .= " fk_element=".(isset($this->fk_element) ? $this->fk_element : "null").","; |
|
232 | + $sql .= " element_type='".$this->db->escape($this->element_type)."',"; |
|
233 | + $sql .= " fk_user_author=".(isset($this->fk_user_author) ? $this->fk_user_author : "null").","; |
|
234 | + $sql .= " entity=".(!empty($this->entity) ? $this->entity : '1').","; |
|
235 | + $sql .= " import_key=".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); |
|
236 | + $sql .= " WHERE rowid=".$this->id; |
|
237 | 237 | |
238 | 238 | $this->db->begin(); |
239 | 239 | |
240 | 240 | dol_syslog(get_class($this)."::update", LOG_DEBUG); |
241 | 241 | $resql = $this->db->query($sql); |
242 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
242 | + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
|
243 | 243 | |
244 | - if (! $error) |
|
244 | + if (!$error) |
|
245 | 245 | { |
246 | - if (! $notrigger) |
|
246 | + if (!$notrigger) |
|
247 | 247 | { |
248 | 248 | // Call trigger |
249 | - $result=$this->call_trigger('TASK_COMMENT_MODIFY',$user); |
|
249 | + $result = $this->call_trigger('TASK_COMMENT_MODIFY', $user); |
|
250 | 250 | if ($result < 0) { $error++; } |
251 | 251 | // End call triggers |
252 | 252 | } |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | // Commit or rollback |
256 | 256 | if ($error) |
257 | 257 | { |
258 | - foreach($this->errors as $errmsg) |
|
258 | + foreach ($this->errors as $errmsg) |
|
259 | 259 | { |
260 | 260 | dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); |
261 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
261 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
262 | 262 | } |
263 | 263 | $this->db->rollback(); |
264 | - return -1*$error; |
|
264 | + return -1 * $error; |
|
265 | 265 | } |
266 | 266 | else |
267 | 267 | { |
@@ -278,27 +278,27 @@ discard block |
||
278 | 278 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
279 | 279 | * @return int <0 if KO, >0 if OK |
280 | 280 | */ |
281 | - function delete($user, $notrigger=0) |
|
281 | + function delete($user, $notrigger = 0) |
|
282 | 282 | { |
283 | 283 | global $conf, $langs; |
284 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
284 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
285 | 285 | |
286 | - $error=0; |
|
286 | + $error = 0; |
|
287 | 287 | |
288 | 288 | $this->db->begin(); |
289 | 289 | |
290 | 290 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."comment"; |
291 | - $sql.= " WHERE rowid=".$this->id; |
|
291 | + $sql .= " WHERE rowid=".$this->id; |
|
292 | 292 | |
293 | 293 | $resql = $this->db->query($sql); |
294 | - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } |
|
294 | + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
|
295 | 295 | |
296 | - if (! $error) |
|
296 | + if (!$error) |
|
297 | 297 | { |
298 | - if (! $notrigger) |
|
298 | + if (!$notrigger) |
|
299 | 299 | { |
300 | 300 | // Call trigger |
301 | - $result=$this->call_trigger('TASK_COMMENT_DELETE',$user); |
|
301 | + $result = $this->call_trigger('TASK_COMMENT_DELETE', $user); |
|
302 | 302 | if ($result < 0) { $error++; } |
303 | 303 | // End call triggers |
304 | 304 | } |
@@ -307,14 +307,14 @@ discard block |
||
307 | 307 | // Commit or rollback |
308 | 308 | if ($error) |
309 | 309 | { |
310 | - foreach($this->errors as $errmsg) |
|
310 | + foreach ($this->errors as $errmsg) |
|
311 | 311 | { |
312 | 312 | dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); |
313 | - $this->error.=($this->error?', '.$errmsg:$errmsg); |
|
313 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
|
314 | 314 | } |
315 | 315 | $this->db->rollback(); |
316 | - return -1*$error; |
|
317 | - }else{ |
|
316 | + return -1 * $error; |
|
317 | + } else { |
|
318 | 318 | $this->db->commit(); |
319 | 319 | return 1; |
320 | 320 | } |
@@ -330,25 +330,25 @@ discard block |
||
330 | 330 | */ |
331 | 331 | public function fetchAllFor($element_type, $fk_element) |
332 | 332 | { |
333 | - global $db,$conf; |
|
333 | + global $db, $conf; |
|
334 | 334 | $this->comments = array(); |
335 | - if(!empty($element_type) && !empty($fk_element)) { |
|
335 | + if (!empty($element_type) && !empty($fk_element)) { |
|
336 | 336 | $sql = "SELECT"; |
337 | - $sql.= " c.rowid"; |
|
338 | - $sql.= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
339 | - $sql.= " WHERE c.fk_element = ".$fk_element; |
|
340 | - $sql.= " AND c.element_type = '".$db->escape($element_type)."'"; |
|
341 | - $sql.= " AND c.entity = ".$conf->entity; |
|
342 | - $sql.= " ORDER BY c.tms DESC"; |
|
337 | + $sql .= " c.rowid"; |
|
338 | + $sql .= " FROM ".MAIN_DB_PREFIX."comment as c"; |
|
339 | + $sql .= " WHERE c.fk_element = ".$fk_element; |
|
340 | + $sql .= " AND c.element_type = '".$db->escape($element_type)."'"; |
|
341 | + $sql .= " AND c.entity = ".$conf->entity; |
|
342 | + $sql .= " ORDER BY c.tms DESC"; |
|
343 | 343 | |
344 | 344 | dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG); |
345 | - $resql=$db->query($sql); |
|
345 | + $resql = $db->query($sql); |
|
346 | 346 | if ($resql) |
347 | 347 | { |
348 | 348 | $num_rows = $db->num_rows($resql); |
349 | 349 | if ($num_rows > 0) |
350 | 350 | { |
351 | - while($obj = $db->fetch_object($resql)) |
|
351 | + while ($obj = $db->fetch_object($resql)) |
|
352 | 352 | { |
353 | 353 | $comment = new self($db); |
354 | 354 | $comment->fetch($obj->rowid); |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | } |
358 | 358 | $db->free($resql); |
359 | 359 | } else { |
360 | - $this->errors[]="Error ".$this->db->lasterror(); |
|
360 | + $this->errors[] = "Error ".$this->db->lasterror(); |
|
361 | 361 | return -1; |
362 | 362 | } |
363 | 363 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | /** |
38 | 38 | * @var string Error code (or message) |
39 | 39 | */ |
40 | - public $error=''; |
|
40 | + public $error = ''; |
|
41 | 41 | |
42 | 42 | |
43 | 43 | /** |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | * @param string $morecss More css on select field |
65 | 65 | * @return void |
66 | 66 | */ |
67 | - function form_select_status_action($formname, $selected, $canedit=1, $htmlname='complete', $showempty=0, $onlyselect=0, $morecss='maxwidth100') |
|
67 | + function form_select_status_action($formname, $selected, $canedit = 1, $htmlname = 'complete', $showempty = 0, $onlyselect = 0, $morecss = 'maxwidth100') |
|
68 | 68 | { |
69 | 69 | // phpcs:enable |
70 | - global $langs,$conf; |
|
70 | + global $langs, $conf; |
|
71 | 71 | |
72 | 72 | $listofstatus = array( |
73 | 73 | '-1' => $langs->trans("ActionNotApplicable"), |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | ); |
78 | 78 | // +ActionUncomplete |
79 | 79 | |
80 | - if (! empty($conf->use_javascript_ajax)) |
|
80 | + if (!empty($conf->use_javascript_ajax)) |
|
81 | 81 | { |
82 | 82 | print "\n"; |
83 | 83 | print "<script type=\"text/javascript\"> |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | function select_status() { |
99 | 99 | var defaultvalue = $('#select' + htmlname).val(); |
100 | 100 | var percentage = $('input[name=percentage]'); |
101 | - var selected = '".(isset($selected)?$selected:'')."'; |
|
101 | + var selected = '".(isset($selected) ? $selected : '')."'; |
|
102 | 102 | var value = (selected>0?selected:(defaultvalue>=0?defaultvalue:'')); |
103 | 103 | |
104 | 104 | percentage.val(value); |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | } |
126 | 126 | </script>\n"; |
127 | 127 | } |
128 | - if (! empty($conf->use_javascript_ajax) || $onlyselect) |
|
128 | + if (!empty($conf->use_javascript_ajax) || $onlyselect) |
|
129 | 129 | { |
130 | 130 | //var_dump($selected); |
131 | - if ($selected == 'done') $selected='100'; |
|
132 | - print '<select '.($canedit?'':'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss?' '.$morecss:'').'">'; |
|
133 | - if ($showempty) print '<option value=""'.($selected == ''?' selected':'').'></option>'; |
|
134 | - foreach($listofstatus as $key => $val) |
|
131 | + if ($selected == 'done') $selected = '100'; |
|
132 | + print '<select '.($canedit ? '' : 'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'">'; |
|
133 | + if ($showempty) print '<option value=""'.($selected == '' ? ' selected' : '').'></option>'; |
|
134 | + foreach ($listofstatus as $key => $val) |
|
135 | 135 | { |
136 | 136 | print '<option value="'.$key.'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected' : '').'>'.$val.'</option>'; |
137 | 137 | if ($key == '50' && $onlyselect == 2) |
@@ -140,17 +140,17 @@ discard block |
||
140 | 140 | } |
141 | 141 | } |
142 | 142 | print '</select>'; |
143 | - if ($selected == 0 || $selected == 100) $canedit=0; |
|
143 | + if ($selected == 0 || $selected == 100) $canedit = 0; |
|
144 | 144 | |
145 | 145 | if (empty($onlyselect)) |
146 | 146 | { |
147 | - print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit&&($selected>=0)?'':' disabled').'>'; |
|
147 | + print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit && ($selected >= 0) ? '' : ' disabled').'>'; |
|
148 | 148 | print '<span class="hideonsmartphone hideifna">%</span>'; |
149 | 149 | } |
150 | 150 | } |
151 | 151 | else |
152 | 152 | { |
153 | - print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit?'':' disabled').'>%'; |
|
153 | + print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit ? '' : ' disabled').'>%'; |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
@@ -168,64 +168,64 @@ discard block |
||
168 | 168 | * @param string $morehtmlright More html text on right of title line |
169 | 169 | * @return int <0 if KO, >=0 if OK |
170 | 170 | */ |
171 | - function showactions($object, $typeelement, $socid=0, $forceshowtitle=0, $morecss='listactions', $max=0, $moreparambacktopage='', $morehtmlright='') |
|
171 | + function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss = 'listactions', $max = 0, $moreparambacktopage = '', $morehtmlright = '') |
|
172 | 172 | { |
173 | - global $langs,$conf,$user; |
|
173 | + global $langs, $conf, $user; |
|
174 | 174 | global $bc; |
175 | 175 | |
176 | 176 | require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
177 | 177 | |
178 | - $sortfield='a.datep,a.id'; |
|
179 | - $sortorder='DESC,DESC'; |
|
178 | + $sortfield = 'a.datep,a.id'; |
|
179 | + $sortorder = 'DESC,DESC'; |
|
180 | 180 | |
181 | - $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max?($max+1):0)); |
|
182 | - if (! is_array($listofactions)) dol_print_error($this->db,'FailedToGetActions'); |
|
181 | + $listofactions = ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max ? ($max + 1) : 0)); |
|
182 | + if (!is_array($listofactions)) dol_print_error($this->db, 'FailedToGetActions'); |
|
183 | 183 | |
184 | 184 | $num = count($listofactions); |
185 | 185 | if ($num || $forceshowtitle) |
186 | 186 | { |
187 | - if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill'); |
|
188 | - elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnBill'); |
|
189 | - elseif ($typeelement == 'propal') $title=$langs->trans('ActionsOnPropal'); |
|
190 | - elseif ($typeelement == 'supplier_proposal') $title=$langs->trans('ActionsOnSupplierProposal'); |
|
191 | - elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); |
|
192 | - elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); |
|
193 | - elseif ($typeelement == 'shipping') $title=$langs->trans('ActionsOnShipping'); |
|
194 | - elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter'); |
|
195 | - elseif ($typeelement == 'project') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
196 | - elseif ($typeelement == 'task') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
197 | - elseif ($typeelement == 'member') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); |
|
198 | - else $title=$langs->trans("LatestLinkedEvents", $max?$max:''); |
|
199 | - |
|
200 | - $urlbacktopage=$_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage?'&'.$moreparambacktopage:''); |
|
187 | + if ($typeelement == 'invoice') $title = $langs->trans('ActionsOnBill'); |
|
188 | + elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title = $langs->trans('ActionsOnBill'); |
|
189 | + elseif ($typeelement == 'propal') $title = $langs->trans('ActionsOnPropal'); |
|
190 | + elseif ($typeelement == 'supplier_proposal') $title = $langs->trans('ActionsOnSupplierProposal'); |
|
191 | + elseif ($typeelement == 'order') $title = $langs->trans('ActionsOnOrder'); |
|
192 | + elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title = $langs->trans('ActionsOnOrder'); |
|
193 | + elseif ($typeelement == 'shipping') $title = $langs->trans('ActionsOnShipping'); |
|
194 | + elseif ($typeelement == 'fichinter') $title = $langs->trans('ActionsOnFicheInter'); |
|
195 | + elseif ($typeelement == 'project') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); |
|
196 | + elseif ($typeelement == 'task') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); |
|
197 | + elseif ($typeelement == 'member') $title = $langs->trans('LatestLinkedEvents', $max ? $max : ''); |
|
198 | + else $title = $langs->trans("LatestLinkedEvents", $max ? $max : ''); |
|
199 | + |
|
200 | + $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage ? '&'.$moreparambacktopage : ''); |
|
201 | 201 | |
202 | 202 | $projectid = $object->fk_project; |
203 | 203 | if ($typeelement == 'project') $projectid = $object->id; |
204 | 204 | |
205 | - $newcardbutton=''; |
|
206 | - if (! empty($conf->agenda->enabled)) |
|
205 | + $newcardbutton = ''; |
|
206 | + if (!empty($conf->agenda->enabled)) |
|
207 | 207 | { |
208 | - $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(),'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid>0?'&socid='.$object->socid:($socid>0?'&socid='.$socid:'')).($projectid>0?'&projectid='.$projectid:'').'&backtopage='.urlencode($urlbacktopage).'"><span class="valignmiddle">'.$langs->trans("AddEvent").'</span>'; |
|
209 | - $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>'; |
|
210 | - $newcardbutton.= '</a>'; |
|
208 | + $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(), 'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid > 0 ? '&socid='.$object->socid : ($socid > 0 ? '&socid='.$socid : '')).($projectid > 0 ? '&projectid='.$projectid : '').'&backtopage='.urlencode($urlbacktopage).'"><span class="valignmiddle">'.$langs->trans("AddEvent").'</span>'; |
|
209 | + $newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>'; |
|
210 | + $newcardbutton .= '</a>'; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | print '<!-- formactions->showactions -->'."\n"; |
214 | 214 | print load_fiche_titre($title, $newcardbutton, '', 0, 0, '', $morehtmlright); |
215 | 215 | |
216 | - $page=0; $param=''; |
|
216 | + $page = 0; $param = ''; |
|
217 | 217 | |
218 | 218 | $total = 0; |
219 | 219 | |
220 | 220 | print '<div class="div-table-responsive-no-min">'; |
221 | - print '<table class="noborder'.($morecss?' '.$morecss:'').'" width="100%">'; |
|
221 | + print '<table class="noborder'.($morecss ? ' '.$morecss : '').'" width="100%">'; |
|
222 | 222 | print '<tr class="liste_titre">'; |
223 | - print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
224 | - print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
225 | - print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
223 | + print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
224 | + print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
225 | + print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
|
226 | 226 | print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1); |
227 | - print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, 'align="center"', $sortfield, $sortorder, '', 1); |
|
228 | - print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"', $sortfield, $sortorder, '', 1); |
|
227 | + print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, 'align="center"', $sortfield, $sortorder, '', 1); |
|
228 | + print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"', $sortfield, $sortorder, '', 1); |
|
229 | 229 | print '</tr>'; |
230 | 230 | print "\n"; |
231 | 231 | |
@@ -234,37 +234,37 @@ discard block |
||
234 | 234 | if (count($listofactions)) |
235 | 235 | { |
236 | 236 | $cursorevent = 0; |
237 | - foreach($listofactions as $action) |
|
237 | + foreach ($listofactions as $action) |
|
238 | 238 | { |
239 | 239 | if ($max && $cursorevent >= $max) break; |
240 | 240 | |
241 | - $ref=$action->getNomUrl(1,-1); |
|
242 | - $label=$action->getNomUrl(0,38); |
|
241 | + $ref = $action->getNomUrl(1, -1); |
|
242 | + $label = $action->getNomUrl(0, 38); |
|
243 | 243 | |
244 | 244 | print '<tr class="oddeven">'; |
245 | 245 | // Ref |
246 | 246 | print '<td>'.$ref.'</td>'; |
247 | 247 | // Onwer |
248 | 248 | print '<td>'; |
249 | - if (! empty($action->userownerid)) |
|
249 | + if (!empty($action->userownerid)) |
|
250 | 250 | { |
251 | - $userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched |
|
251 | + $userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched |
|
252 | 252 | print $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, '', ''); |
253 | 253 | } |
254 | 254 | print '</td>'; |
255 | 255 | // Type |
256 | 256 | print '<td>'; |
257 | - $imgpicto=''; |
|
258 | - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
|
257 | + $imgpicto = ''; |
|
258 | + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) |
|
259 | 259 | { |
260 | - if ($action->type_picto) $imgpicto=img_picto('', $action->type_picto); |
|
260 | + if ($action->type_picto) $imgpicto = img_picto('', $action->type_picto); |
|
261 | 261 | else { |
262 | - if ($action->type_code == 'AC_RDV') $imgpicto=img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; |
|
263 | - elseif ($action->type_code == 'AC_TEL') $imgpicto=img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; |
|
264 | - elseif ($action->type_code == 'AC_FAX') $imgpicto=img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; |
|
265 | - elseif ($action->type_code == 'AC_EMAIL') $imgpicto=img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; |
|
266 | - elseif ($action->type_code == 'AC_INT') $imgpicto=img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; |
|
267 | - elseif (! preg_match('/_AUTO/', $action->type_code)) $imgpicto=img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; |
|
262 | + if ($action->type_code == 'AC_RDV') $imgpicto = img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; |
|
263 | + elseif ($action->type_code == 'AC_TEL') $imgpicto = img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; |
|
264 | + elseif ($action->type_code == 'AC_FAX') $imgpicto = img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; |
|
265 | + elseif ($action->type_code == 'AC_EMAIL') $imgpicto = img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; |
|
266 | + elseif ($action->type_code == 'AC_INT') $imgpicto = img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; |
|
267 | + elseif (!preg_match('/_AUTO/', $action->type_code)) $imgpicto = img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' '; |
|
268 | 268 | } |
269 | 269 | } |
270 | 270 | print $imgpicto; |
@@ -276,8 +276,8 @@ discard block |
||
276 | 276 | print '<td align="center">'.dol_print_date($action->datep, 'dayhour', 'tzuserrel'); |
277 | 277 | if ($action->datef) |
278 | 278 | { |
279 | - $tmpa=dol_getdate($action->datep); |
|
280 | - $tmpb=dol_getdate($action->datef); |
|
279 | + $tmpa = dol_getdate($action->datep); |
|
280 | + $tmpb = dol_getdate($action->datef); |
|
281 | 281 | if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) |
282 | 282 | { |
283 | 283 | if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($action->datef, 'hour', 'tzuserrel'); |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | } |
287 | 287 | print '</td>'; |
288 | 288 | print '<td align="right">'; |
289 | - if (! empty($action->author->id)) |
|
289 | + if (!empty($action->author->id)) |
|
290 | 290 | { |
291 | 291 | print $action->getLibStatut(3); |
292 | 292 | } |
@@ -327,42 +327,42 @@ discard block |
||
327 | 327 | * @param int $nooutput 1=No output |
328 | 328 | * @return string |
329 | 329 | */ |
330 | - function select_type_actions($selected='', $htmlname='actioncode', $excludetype='', $onlyautoornot=0, $hideinfohelp=0, $multiselect=0, $nooutput=0) |
|
330 | + function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0) |
|
331 | 331 | { |
332 | 332 | // phpcs:enable |
333 | - global $langs,$user,$form,$conf; |
|
333 | + global $langs, $user, $form, $conf; |
|
334 | 334 | |
335 | - if (! is_object($form)) $form=new Form($this->db); |
|
335 | + if (!is_object($form)) $form = new Form($this->db); |
|
336 | 336 | |
337 | 337 | require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; |
338 | 338 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
339 | - $caction=new CActionComm($this->db); |
|
339 | + $caction = new CActionComm($this->db); |
|
340 | 340 | |
341 | 341 | // Suggest a list with manual events or all auto events |
342 | - $arraylist=$caction->liste_array(1, 'code', $excludetype, $onlyautoornot); |
|
343 | - array_unshift($arraylist,' '); // Add empty line at start |
|
342 | + $arraylist = $caction->liste_array(1, 'code', $excludetype, $onlyautoornot); |
|
343 | + array_unshift($arraylist, ' '); // Add empty line at start |
|
344 | 344 | //asort($arraylist); |
345 | 345 | |
346 | - if ($selected == 'manual') $selected='AC_OTH'; |
|
347 | - if ($selected == 'auto') $selected='AC_OTH_AUTO'; |
|
346 | + if ($selected == 'manual') $selected = 'AC_OTH'; |
|
347 | + if ($selected == 'auto') $selected = 'AC_OTH_AUTO'; |
|
348 | 348 | |
349 | - if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); |
|
349 | + if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); |
|
350 | 350 | |
351 | - $out=''; |
|
351 | + $out = ''; |
|
352 | 352 | |
353 | - if (! empty($multiselect)) |
|
353 | + if (!empty($multiselect)) |
|
354 | 354 | { |
355 | 355 | if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); |
356 | - $out.=$form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); |
|
356 | + $out .= $form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); |
|
357 | 357 | } |
358 | 358 | else |
359 | 359 | { |
360 | - $out.=$form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); |
|
360 | + $out .= $form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) |
364 | 364 | { |
365 | - $out.=info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''),1); |
|
365 | + $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''), 1); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | if ($nooutput) return $out; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | /** |
37 | 37 | * @var string Error code (or message) |
38 | 38 | */ |
39 | - public $error=''; |
|
39 | + public $error = ''; |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Constructor |
@@ -58,43 +58,43 @@ discard block |
||
58 | 58 | * @param integer $readonly Select is read only or not |
59 | 59 | * @return string HTML select field |
60 | 60 | */ |
61 | - function select_typejob($htmlname,$selected=0,$readonly=0) |
|
61 | + function select_typejob($htmlname, $selected = 0, $readonly = 0) |
|
62 | 62 | { |
63 | 63 | // phpcs:enable |
64 | 64 | global $langs; |
65 | 65 | |
66 | 66 | $langs->load('cron@cron'); |
67 | 67 | if (!empty($readonly)) { |
68 | - if ($selected=='command') { |
|
69 | - $out= $langs->trans('CronType_command'); |
|
70 | - $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
71 | - $out.= '<OPTION value="command" selected>'.$langs->trans('CronType_command').'</OPTION>'; |
|
72 | - $out.='</SELECT>'; |
|
73 | - } elseif ($selected=='method') { |
|
74 | - $out= $langs->trans('CronType_method'); |
|
75 | - $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
76 | - $out.= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>'; |
|
77 | - $out.='</SELECT>'; |
|
68 | + if ($selected == 'command') { |
|
69 | + $out = $langs->trans('CronType_command'); |
|
70 | + $out .= '<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
71 | + $out .= '<OPTION value="command" selected>'.$langs->trans('CronType_command').'</OPTION>'; |
|
72 | + $out .= '</SELECT>'; |
|
73 | + } elseif ($selected == 'method') { |
|
74 | + $out = $langs->trans('CronType_method'); |
|
75 | + $out .= '<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>'; |
|
76 | + $out .= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>'; |
|
77 | + $out .= '</SELECT>'; |
|
78 | 78 | } |
79 | - }else { |
|
79 | + } else { |
|
80 | 80 | |
81 | - $out='<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />'; |
|
81 | + $out = '<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />'; |
|
82 | 82 | |
83 | - if ($selected=='command') { |
|
84 | - $selected_attr=' selected '; |
|
83 | + if ($selected == 'command') { |
|
84 | + $selected_attr = ' selected '; |
|
85 | 85 | } else { |
86 | - $selected_attr=''; |
|
86 | + $selected_attr = ''; |
|
87 | 87 | } |
88 | - $out.= '<OPTION value="command" '.$selected_attr.'>'.$langs->trans('CronType_command').'</OPTION>'; |
|
88 | + $out .= '<OPTION value="command" '.$selected_attr.'>'.$langs->trans('CronType_command').'</OPTION>'; |
|
89 | 89 | |
90 | - if ($selected=='method') { |
|
91 | - $selected_attr=' selected '; |
|
90 | + if ($selected == 'method') { |
|
91 | + $selected_attr = ' selected '; |
|
92 | 92 | } else { |
93 | - $selected_attr=''; |
|
93 | + $selected_attr = ''; |
|
94 | 94 | } |
95 | - $out.= '<OPTION value="method" '.$selected_attr.'>'.$langs->trans('CronType_method').'</OPTION>'; |
|
95 | + $out .= '<OPTION value="method" '.$selected_attr.'>'.$langs->trans('CronType_method').'</OPTION>'; |
|
96 | 96 | |
97 | - $out.='</SELECT>'; |
|
97 | + $out .= '</SELECT>'; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | return $out; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * \ingroup core |
21 | 21 | * \brief File of predefined functions for HTML forms for mailing module |
22 | 22 | */ |
23 | -require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; |
|
23 | +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Class to offer components to list and upload files |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param integer $show_empty Show empty option |
41 | 41 | * @return string HTML select |
42 | 42 | */ |
43 | - public function selectDestinariesStatus($selectedid='', $htmlname='dest_status', $show_empty=0) |
|
43 | + public function selectDestinariesStatus($selectedid = '', $htmlname = 'dest_status', $show_empty = 0) |
|
44 | 44 | { |
45 | 45 | |
46 | 46 | global $langs; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $options = array(); |
53 | 53 | |
54 | 54 | if ($show_empty) { |
55 | - $options[-2] = ''; // Note -1 is used for error |
|
55 | + $options[-2] = ''; // Note -1 is used for error |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | $options = $options + $mailing->statut_dest; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | /** |
40 | 40 | * @var string Error code (or message) |
41 | 41 | */ |
42 | - public $error=''; |
|
42 | + public $error = ''; |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * Constructor |
@@ -60,20 +60,20 @@ discard block |
||
60 | 60 | * @param string $filter Add a SQL filter to select |
61 | 61 | * @return array Array of types |
62 | 62 | */ |
63 | - function typent_array($mode=0, $filter='') |
|
63 | + function typent_array($mode = 0, $filter = '') |
|
64 | 64 | { |
65 | 65 | // phpcs:enable |
66 | - global $langs,$mysoc; |
|
66 | + global $langs, $mysoc; |
|
67 | 67 | |
68 | 68 | $effs = array(); |
69 | 69 | |
70 | 70 | $sql = "SELECT id, code, libelle"; |
71 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_typent"; |
|
72 | - $sql.= " WHERE active = 1 AND (fk_country IS NULL OR fk_country = ".(empty($mysoc->country_id)?'0':$mysoc->country_id).")"; |
|
73 | - if ($filter) $sql.=" ".$filter; |
|
74 | - $sql.= " ORDER by position, id"; |
|
71 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_typent"; |
|
72 | + $sql .= " WHERE active = 1 AND (fk_country IS NULL OR fk_country = ".(empty($mysoc->country_id) ? '0' : $mysoc->country_id).")"; |
|
73 | + if ($filter) $sql .= " ".$filter; |
|
74 | + $sql .= " ORDER by position, id"; |
|
75 | 75 | dol_syslog(get_class($this).'::typent_array', LOG_DEBUG); |
76 | - $resql=$this->db->query($sql); |
|
76 | + $resql = $this->db->query($sql); |
|
77 | 77 | if ($resql) |
78 | 78 | { |
79 | 79 | $num = $this->db->num_rows($resql); |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | while ($i < $num) |
83 | 83 | { |
84 | 84 | $objp = $this->db->fetch_object($resql); |
85 | - if (! $mode) $key=$objp->id; |
|
86 | - else $key=$objp->code; |
|
85 | + if (!$mode) $key = $objp->id; |
|
86 | + else $key = $objp->code; |
|
87 | 87 | if ($langs->trans($objp->code) != $objp->code) $effs[$key] = $langs->trans($objp->code); |
88 | 88 | else $effs[$key] = $objp->libelle; |
89 | - if ($effs[$key]=='-') $effs[$key]=''; |
|
89 | + if ($effs[$key] == '-') $effs[$key] = ''; |
|
90 | 90 | $i++; |
91 | 91 | } |
92 | 92 | $this->db->free($resql); |
@@ -103,18 +103,18 @@ discard block |
||
103 | 103 | * @param string $filter Add a SQL filter to select |
104 | 104 | * @return array Array of types d'effectifs |
105 | 105 | */ |
106 | - function effectif_array($mode=0, $filter='') |
|
106 | + function effectif_array($mode = 0, $filter = '') |
|
107 | 107 | { |
108 | 108 | // phpcs:enable |
109 | 109 | $effs = array(); |
110 | 110 | |
111 | 111 | $sql = "SELECT id, code, libelle"; |
112 | 112 | $sql .= " FROM ".MAIN_DB_PREFIX."c_effectif"; |
113 | - $sql.= " WHERE active = 1"; |
|
114 | - if ($filter) $sql.=" ".$filter; |
|
113 | + $sql .= " WHERE active = 1"; |
|
114 | + if ($filter) $sql .= " ".$filter; |
|
115 | 115 | $sql .= " ORDER BY id ASC"; |
116 | 116 | dol_syslog(get_class($this).'::effectif_array', LOG_DEBUG); |
117 | - $resql=$this->db->query($sql); |
|
117 | + $resql = $this->db->query($sql); |
|
118 | 118 | if ($resql) |
119 | 119 | { |
120 | 120 | $num = $this->db->num_rows($resql); |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | while ($i < $num) |
124 | 124 | { |
125 | 125 | $objp = $this->db->fetch_object($resql); |
126 | - if (! $mode) $key=$objp->id; |
|
127 | - else $key=$objp->code; |
|
126 | + if (!$mode) $key = $objp->id; |
|
127 | + else $key = $objp->code; |
|
128 | 128 | |
129 | - $effs[$key] = $objp->libelle!='-'?$objp->libelle:''; |
|
129 | + $effs[$key] = $objp->libelle != '-' ? $objp->libelle : ''; |
|
130 | 130 | $i++; |
131 | 131 | } |
132 | 132 | $this->db->free($resql); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @param int $empty Add empty value in list |
146 | 146 | * @return void |
147 | 147 | */ |
148 | - function form_prospect_level($page, $selected='', $htmlname='prospect_level_id', $empty=0) |
|
148 | + function form_prospect_level($page, $selected = '', $htmlname = 'prospect_level_id', $empty = 0) |
|
149 | 149 | { |
150 | 150 | // phpcs:enable |
151 | 151 | global $user, $langs; |
@@ -154,11 +154,11 @@ discard block |
||
154 | 154 | print '<input type="hidden" name="action" value="setprospectlevel">'; |
155 | 155 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
156 | 156 | |
157 | - dol_syslog(get_class($this).'::form_prospect_level',LOG_DEBUG); |
|
157 | + dol_syslog(get_class($this).'::form_prospect_level', LOG_DEBUG); |
|
158 | 158 | $sql = "SELECT code, label"; |
159 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; |
|
160 | - $sql.= " WHERE active > 0"; |
|
161 | - $sql.= " ORDER BY sortorder"; |
|
159 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; |
|
160 | + $sql .= " WHERE active > 0"; |
|
161 | + $sql .= " ORDER BY sortorder"; |
|
162 | 162 | $resql = $this->db->query($sql); |
163 | 163 | if ($resql) |
164 | 164 | { |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | print Form::selectarray($htmlname, $options, $selected); |
182 | 182 | } |
183 | 183 | else dol_print_error($this->db); |
184 | - if (! empty($htmlname) && $user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
184 | + if (!empty($htmlname) && $user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
185 | 185 | print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
186 | 186 | print '</form>'; |
187 | 187 | } |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | * @param string $htmlname Id of department |
200 | 200 | * @return void |
201 | 201 | */ |
202 | - function select_departement($selected='',$country_codeid=0, $htmlname='state_id') |
|
202 | + function select_departement($selected = '', $country_codeid = 0, $htmlname = 'state_id') |
|
203 | 203 | { |
204 | 204 | // phpcs:enable |
205 | - print $this->select_state($selected,$country_codeid, $htmlname); |
|
205 | + print $this->select_state($selected, $country_codeid, $htmlname); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -219,91 +219,91 @@ discard block |
||
219 | 219 | * @return string String with HTML select |
220 | 220 | * @see select_country |
221 | 221 | */ |
222 | - function select_state($selected='',$country_codeid=0, $htmlname='state_id') |
|
222 | + function select_state($selected = '', $country_codeid = 0, $htmlname = 'state_id') |
|
223 | 223 | { |
224 | 224 | // phpcs:enable |
225 | - global $conf,$langs,$user; |
|
225 | + global $conf, $langs, $user; |
|
226 | 226 | |
227 | - dol_syslog(get_class($this)."::select_departement selected=".$selected.", country_codeid=".$country_codeid,LOG_DEBUG); |
|
227 | + dol_syslog(get_class($this)."::select_departement selected=".$selected.", country_codeid=".$country_codeid, LOG_DEBUG); |
|
228 | 228 | |
229 | 229 | $langs->load("dict"); |
230 | 230 | |
231 | - $out=''; |
|
231 | + $out = ''; |
|
232 | 232 | |
233 | 233 | // Serch departements/cantons/province active d'une region et pays actif |
234 | 234 | $sql = "SELECT d.rowid, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.nom as region_name FROM"; |
235 | - $sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; |
|
235 | + $sql .= " ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; |
|
236 | 236 | $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid"; |
237 | 237 | $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1"; |
238 | 238 | if ($country_codeid && is_numeric($country_codeid)) $sql .= " AND c.rowid = '".$this->db->escape($country_codeid)."'"; |
239 | - if ($country_codeid && ! is_numeric($country_codeid)) $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; |
|
239 | + if ($country_codeid && !is_numeric($country_codeid)) $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; |
|
240 | 240 | $sql .= " ORDER BY c.code, d.code_departement"; |
241 | 241 | |
242 | - $result=$this->db->query($sql); |
|
242 | + $result = $this->db->query($sql); |
|
243 | 243 | if ($result) |
244 | 244 | { |
245 | - if (!empty($htmlname)) $out.= '<select id="'.$htmlname.'" class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.'">'; |
|
246 | - if ($country_codeid) $out.= '<option value="0"> </option>'; |
|
245 | + if (!empty($htmlname)) $out .= '<select id="'.$htmlname.'" class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.'">'; |
|
246 | + if ($country_codeid) $out .= '<option value="0"> </option>'; |
|
247 | 247 | $num = $this->db->num_rows($result); |
248 | 248 | $i = 0; |
249 | - dol_syslog(get_class($this)."::select_departement num=".$num,LOG_DEBUG); |
|
249 | + dol_syslog(get_class($this)."::select_departement num=".$num, LOG_DEBUG); |
|
250 | 250 | if ($num) |
251 | 251 | { |
252 | - $country=''; |
|
252 | + $country = ''; |
|
253 | 253 | while ($i < $num) |
254 | 254 | { |
255 | 255 | $obj = $this->db->fetch_object($result); |
256 | 256 | if ($obj->code == '0') // Le code peut etre une chaine |
257 | 257 | { |
258 | - $out.= '<option value="0"> </option>'; |
|
258 | + $out .= '<option value="0"> </option>'; |
|
259 | 259 | } |
260 | 260 | else { |
261 | - if (! $country || $country != $obj->country) |
|
261 | + if (!$country || $country != $obj->country) |
|
262 | 262 | { |
263 | 263 | // Affiche la rupture si on est en mode liste multipays |
264 | - if (! $country_codeid && $obj->country_code) |
|
264 | + if (!$country_codeid && $obj->country_code) |
|
265 | 265 | { |
266 | - $out.= '<option value="-1" disabled>----- '.$obj->country." -----</option>\n"; |
|
267 | - $country=$obj->country; |
|
266 | + $out .= '<option value="-1" disabled>----- '.$obj->country." -----</option>\n"; |
|
267 | + $country = $obj->country; |
|
268 | 268 | } |
269 | 269 | } |
270 | 270 | |
271 | - if ((! empty($selected) && $selected == $obj->rowid) |
|
272 | - || (empty($selected) && ! empty($conf->global->MAIN_FORCE_DEFAULT_STATE_ID) && $conf->global->MAIN_FORCE_DEFAULT_STATE_ID == $obj->rowid)) |
|
271 | + if ((!empty($selected) && $selected == $obj->rowid) |
|
272 | + || (empty($selected) && !empty($conf->global->MAIN_FORCE_DEFAULT_STATE_ID) && $conf->global->MAIN_FORCE_DEFAULT_STATE_ID == $obj->rowid)) |
|
273 | 273 | { |
274 | - $out.= '<option value="'.$obj->rowid.'" selected>'; |
|
274 | + $out .= '<option value="'.$obj->rowid.'" selected>'; |
|
275 | 275 | } |
276 | 276 | else |
277 | 277 | { |
278 | - $out.= '<option value="'.$obj->rowid.'">'; |
|
278 | + $out .= '<option value="'.$obj->rowid.'">'; |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut |
282 | 282 | if (!empty($conf->global->MAIN_SHOW_STATE_CODE) && |
283 | 283 | ($conf->global->MAIN_SHOW_STATE_CODE == 1 || $conf->global->MAIN_SHOW_STATE_CODE == 2 || $conf->global->MAIN_SHOW_STATE_CODE === 'all')) { |
284 | - if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
|
285 | - $out.= $obj->region_name . ' - ' . $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
|
284 | + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
|
285 | + $out .= $obj->region_name.' - '.$obj->code.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); |
|
286 | 286 | } |
287 | 287 | else { |
288 | - $out.= $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
|
288 | + $out .= $obj->code.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); |
|
289 | 289 | } |
290 | 290 | } |
291 | 291 | else { |
292 | - if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
|
293 | - $out.= $obj->region_name . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
|
292 | + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
|
293 | + $out .= $obj->region_name.' - '.($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); |
|
294 | 294 | } |
295 | 295 | else { |
296 | - $out.= ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
|
296 | + $out .= ($langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : ($obj->name != '-' ? $obj->name : '')); |
|
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
300 | - $out.= '</option>'; |
|
300 | + $out .= '</option>'; |
|
301 | 301 | } |
302 | 302 | $i++; |
303 | 303 | } |
304 | 304 | } |
305 | - if (! empty($htmlname)) $out.= '</select>'; |
|
306 | - if (! empty($htmlname) && $user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
305 | + if (!empty($htmlname)) $out .= '</select>'; |
|
306 | + if (!empty($htmlname) && $user->admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
307 | 307 | } |
308 | 308 | else |
309 | 309 | { |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | } |
312 | 312 | |
313 | 313 | // Make select dynamic |
314 | - if (! empty($htmlname)) |
|
314 | + if (!empty($htmlname)) |
|
315 | 315 | { |
316 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
|
316 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; |
|
317 | 317 | $out .= ajax_combobox($htmlname); |
318 | 318 | } |
319 | 319 | |
@@ -332,19 +332,19 @@ discard block |
||
332 | 332 | * @param string $htmlname Name of HTML select field |
333 | 333 | * @return void |
334 | 334 | */ |
335 | - function select_region($selected='',$htmlname='region_id') |
|
335 | + function select_region($selected = '', $htmlname = 'region_id') |
|
336 | 336 | { |
337 | 337 | // phpcs:enable |
338 | - global $conf,$langs; |
|
338 | + global $conf, $langs; |
|
339 | 339 | $langs->load("dict"); |
340 | 340 | |
341 | 341 | $sql = "SELECT r.rowid, r.code_region as code, r.nom as label, r.active, c.code as country_code, c.label as country"; |
342 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c"; |
|
343 | - $sql.= " WHERE r.fk_pays=c.rowid AND r.active = 1 and c.active = 1"; |
|
344 | - $sql.= " ORDER BY c.code, c.label ASC"; |
|
342 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c"; |
|
343 | + $sql .= " WHERE r.fk_pays=c.rowid AND r.active = 1 and c.active = 1"; |
|
344 | + $sql .= " ORDER BY c.code, c.label ASC"; |
|
345 | 345 | |
346 | 346 | dol_syslog(get_class($this)."::select_region", LOG_DEBUG); |
347 | - $resql=$this->db->query($sql); |
|
347 | + $resql = $this->db->query($sql); |
|
348 | 348 | if ($resql) |
349 | 349 | { |
350 | 350 | print '<select class="flat" name="'.$htmlname.'">'; |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | $i = 0; |
353 | 353 | if ($num) |
354 | 354 | { |
355 | - $country=''; |
|
355 | + $country = ''; |
|
356 | 356 | while ($i < $num) |
357 | 357 | { |
358 | 358 | $obj = $this->db->fetch_object($resql); |
@@ -363,10 +363,10 @@ discard block |
||
363 | 363 | if ($country == '' || $country != $obj->country) |
364 | 364 | { |
365 | 365 | // Show break |
366 | - $key=$langs->trans("Country".strtoupper($obj->country_code)); |
|
367 | - $valuetoshow=($key != "Country".strtoupper($obj->country_code))?$obj->country_code." - ".$key:$obj->country; |
|
366 | + $key = $langs->trans("Country".strtoupper($obj->country_code)); |
|
367 | + $valuetoshow = ($key != "Country".strtoupper($obj->country_code)) ? $obj->country_code." - ".$key : $obj->country; |
|
368 | 368 | print '<option value="-1" disabled>----- '.$valuetoshow." -----</option>\n"; |
369 | - $country=$obj->country; |
|
369 | + $country = $obj->country; |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | if ($selected > 0 && $selected == $obj->code) |
@@ -398,23 +398,23 @@ discard block |
||
398 | 398 | * @param string $morecss Add more css on SELECT element |
399 | 399 | * @return string String with HTML select |
400 | 400 | */ |
401 | - function select_civility($selected='',$htmlname='civility_id',$morecss='maxwidth100') |
|
401 | + function select_civility($selected = '', $htmlname = 'civility_id', $morecss = 'maxwidth100') |
|
402 | 402 | { |
403 | 403 | // phpcs:enable |
404 | - global $conf,$langs,$user; |
|
404 | + global $conf, $langs, $user; |
|
405 | 405 | $langs->load("dict"); |
406 | 406 | |
407 | - $out=''; |
|
407 | + $out = ''; |
|
408 | 408 | |
409 | 409 | $sql = "SELECT rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_civility"; |
410 | - $sql.= " WHERE active = 1"; |
|
410 | + $sql .= " WHERE active = 1"; |
|
411 | 411 | |
412 | 412 | dol_syslog("Form::select_civility", LOG_DEBUG); |
413 | - $resql=$this->db->query($sql); |
|
413 | + $resql = $this->db->query($sql); |
|
414 | 414 | if ($resql) |
415 | 415 | { |
416 | - $out.= '<select class="flat'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
417 | - $out.= '<option value=""> </option>'; |
|
416 | + $out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
417 | + $out .= '<option value=""> </option>'; |
|
418 | 418 | $num = $this->db->num_rows($resql); |
419 | 419 | $i = 0; |
420 | 420 | if ($num) |
@@ -424,20 +424,20 @@ discard block |
||
424 | 424 | $obj = $this->db->fetch_object($resql); |
425 | 425 | if ($selected == $obj->code) |
426 | 426 | { |
427 | - $out.= '<option value="'.$obj->code.'" selected>'; |
|
427 | + $out .= '<option value="'.$obj->code.'" selected>'; |
|
428 | 428 | } |
429 | 429 | else |
430 | 430 | { |
431 | - $out.= '<option value="'.$obj->code.'">'; |
|
431 | + $out .= '<option value="'.$obj->code.'">'; |
|
432 | 432 | } |
433 | 433 | // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut |
434 | - $out.= ($langs->trans("Civility".$obj->code)!="Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->label!='-'?$obj->label:'')); |
|
435 | - $out.= '</option>'; |
|
434 | + $out .= ($langs->trans("Civility".$obj->code) != "Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->label != '-' ? $obj->label : '')); |
|
435 | + $out .= '</option>'; |
|
436 | 436 | $i++; |
437 | 437 | } |
438 | 438 | } |
439 | - $out.= '</select>'; |
|
440 | - if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
439 | + $out .= '</select>'; |
|
440 | + if ($user->admin) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
441 | 441 | } |
442 | 442 | else |
443 | 443 | { |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | * @deprecated Use print xxx->select_juridicalstatus instead |
460 | 460 | * @see select_juridicalstatus() |
461 | 461 | */ |
462 | - function select_forme_juridique($selected='', $country_codeid=0, $filter='') |
|
462 | + function select_forme_juridique($selected = '', $country_codeid = 0, $filter = '') |
|
463 | 463 | { |
464 | 464 | // phpcs:enable |
465 | 465 | print $this->select_juridicalstatus($selected, $country_codeid, $filter); |
@@ -476,13 +476,13 @@ discard block |
||
476 | 476 | * @param string $htmlname HTML name of select |
477 | 477 | * @return string String with HTML select |
478 | 478 | */ |
479 | - function select_juridicalstatus($selected='', $country_codeid=0, $filter='', $htmlname='forme_juridique_code') |
|
479 | + function select_juridicalstatus($selected = '', $country_codeid = 0, $filter = '', $htmlname = 'forme_juridique_code') |
|
480 | 480 | { |
481 | 481 | // phpcs:enable |
482 | - global $conf,$langs,$user; |
|
482 | + global $conf, $langs, $user; |
|
483 | 483 | $langs->load("dict"); |
484 | 484 | |
485 | - $out=''; |
|
485 | + $out = ''; |
|
486 | 486 | |
487 | 487 | // On recherche les formes juridiques actives des pays actifs |
488 | 488 | $sql = "SELECT f.rowid, f.code as code , f.libelle as label, f.active, c.label as country, c.code as country_code"; |
@@ -494,70 +494,70 @@ discard block |
||
494 | 494 | $sql .= " ORDER BY c.code"; |
495 | 495 | |
496 | 496 | dol_syslog(get_class($this)."::select_juridicalstatus", LOG_DEBUG); |
497 | - $resql=$this->db->query($sql); |
|
497 | + $resql = $this->db->query($sql); |
|
498 | 498 | if ($resql) |
499 | 499 | { |
500 | - $out.= '<div id="particulier2" class="visible">'; |
|
501 | - $out.= '<select class="flat minwidth200" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
502 | - if ($country_codeid) $out.= '<option value="0"> </option>'; // When country_codeid is set, we force to add an empty line because it does not appears from select. When not set, we already get the empty line from select. |
|
500 | + $out .= '<div id="particulier2" class="visible">'; |
|
501 | + $out .= '<select class="flat minwidth200" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
502 | + if ($country_codeid) $out .= '<option value="0"> </option>'; // When country_codeid is set, we force to add an empty line because it does not appears from select. When not set, we already get the empty line from select. |
|
503 | 503 | |
504 | 504 | $num = $this->db->num_rows($resql); |
505 | 505 | if ($num) |
506 | 506 | { |
507 | 507 | $i = 0; |
508 | - $country=''; $arraydata=array(); |
|
508 | + $country = ''; $arraydata = array(); |
|
509 | 509 | while ($i < $num) |
510 | 510 | { |
511 | 511 | $obj = $this->db->fetch_object($resql); |
512 | 512 | |
513 | 513 | if ($obj->code) // We exclude empty line, we will add it later |
514 | 514 | { |
515 | - $labelcountry=(($langs->trans("Country".$obj->country_code)!="Country".$obj->country_code) ? $langs->trans("Country".$obj->country_code) : $obj->country); |
|
516 | - $labeljs=(($langs->trans("JuridicalStatus".$obj->code)!="JuridicalStatus".$obj->code) ? $langs->trans("JuridicalStatus".$obj->code) : ($obj->label!='-'?$obj->label:'')); // $obj->label is already in output charset (converted by database driver) |
|
517 | - $arraydata[$obj->code]=array('code'=>$obj->code, 'label'=>$labeljs, 'label_sort'=>$labelcountry.'_'.$labeljs, 'country_code'=>$obj->country_code, 'country'=>$labelcountry); |
|
515 | + $labelcountry = (($langs->trans("Country".$obj->country_code) != "Country".$obj->country_code) ? $langs->trans("Country".$obj->country_code) : $obj->country); |
|
516 | + $labeljs = (($langs->trans("JuridicalStatus".$obj->code) != "JuridicalStatus".$obj->code) ? $langs->trans("JuridicalStatus".$obj->code) : ($obj->label != '-' ? $obj->label : '')); // $obj->label is already in output charset (converted by database driver) |
|
517 | + $arraydata[$obj->code] = array('code'=>$obj->code, 'label'=>$labeljs, 'label_sort'=>$labelcountry.'_'.$labeljs, 'country_code'=>$obj->country_code, 'country'=>$labelcountry); |
|
518 | 518 | } |
519 | 519 | $i++; |
520 | 520 | } |
521 | 521 | |
522 | - $arraydata=dol_sort_array($arraydata, 'label_sort', 'ASC'); |
|
522 | + $arraydata = dol_sort_array($arraydata, 'label_sort', 'ASC'); |
|
523 | 523 | if (empty($country_codeid)) // Introduce empty value (if $country_codeid not empty, empty value was already added) |
524 | 524 | { |
525 | - $arraydata[0]=array('code'=>0, 'label'=>'', 'label_sort'=>'_', 'country_code'=>'', 'country'=>''); |
|
525 | + $arraydata[0] = array('code'=>0, 'label'=>'', 'label_sort'=>'_', 'country_code'=>'', 'country'=>''); |
|
526 | 526 | } |
527 | 527 | |
528 | - foreach($arraydata as $key => $val) |
|
528 | + foreach ($arraydata as $key => $val) |
|
529 | 529 | { |
530 | - if (! $country || $country != $val['country']) |
|
530 | + if (!$country || $country != $val['country']) |
|
531 | 531 | { |
532 | 532 | // Show break when we are in multi country mode |
533 | 533 | if (empty($country_codeid) && $val['country_code']) |
534 | 534 | { |
535 | - $out.= '<option value="0" disabled class="selectoptiondisabledwhite">----- '.$val['country']." -----</option>\n"; |
|
536 | - $country=$val['country']; |
|
535 | + $out .= '<option value="0" disabled class="selectoptiondisabledwhite">----- '.$val['country']." -----</option>\n"; |
|
536 | + $country = $val['country']; |
|
537 | 537 | } |
538 | 538 | } |
539 | 539 | |
540 | 540 | if ($selected > 0 && $selected == $val['code']) |
541 | 541 | { |
542 | - $out.= '<option value="'.$val['code'].'" selected>'; |
|
542 | + $out .= '<option value="'.$val['code'].'" selected>'; |
|
543 | 543 | } |
544 | 544 | else |
545 | 545 | { |
546 | - $out.= '<option value="'.$val['code'].'">'; |
|
546 | + $out .= '<option value="'.$val['code'].'">'; |
|
547 | 547 | } |
548 | 548 | // If translation exists, we use it, otherwise we use default label in database |
549 | - $out.= $val['label']; |
|
550 | - $out.= '</option>'; |
|
549 | + $out .= $val['label']; |
|
550 | + $out .= '</option>'; |
|
551 | 551 | } |
552 | 552 | } |
553 | - $out.= '</select>'; |
|
554 | - if ($user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
553 | + $out .= '</select>'; |
|
554 | + if ($user->admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
555 | 555 | |
556 | 556 | // Make select dynamic |
557 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
|
557 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; |
|
558 | 558 | $out .= ajax_combobox($htmlname); |
559 | 559 | |
560 | - $out.= '</div>'; |
|
560 | + $out .= '</div>'; |
|
561 | 561 | } |
562 | 562 | else |
563 | 563 | { |
@@ -581,19 +581,19 @@ discard block |
||
581 | 581 | * @param string $morecss More CSS on select component |
582 | 582 | * @return int The selected third party ID |
583 | 583 | */ |
584 | - function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname='newcompany', $limitto='', $forceid=0, $moreparam='', $morecss='') |
|
584 | + function selectCompaniesForNewContact($object, $var_id, $selected = '', $htmlname = 'newcompany', $limitto = '', $forceid = 0, $moreparam = '', $morecss = '') |
|
585 | 585 | { |
586 | 586 | global $conf, $langs; |
587 | 587 | |
588 | - if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) |
|
588 | + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) |
|
589 | 589 | { |
590 | 590 | // Use Ajax search |
591 | - $minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:2); |
|
591 | + $minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT) ? $conf->global->COMPANY_USE_SEARCH_TO_SELECT : 2); |
|
592 | 592 | |
593 | - $socid=0; $name=''; |
|
593 | + $socid = 0; $name = ''; |
|
594 | 594 | if ($selected > 0) |
595 | 595 | { |
596 | - $tmpthirdparty=new Societe($this->db); |
|
596 | + $tmpthirdparty = new Societe($this->db); |
|
597 | 597 | $result = $tmpthirdparty->fetch($selected); |
598 | 598 | if ($result > 0) |
599 | 599 | { |
@@ -603,13 +603,13 @@ discard block |
||
603 | 603 | } |
604 | 604 | |
605 | 605 | |
606 | - $events=array(); |
|
606 | + $events = array(); |
|
607 | 607 | // Add an entry 'method' to say 'yes, we must execute url with param action = method'; |
608 | 608 | // Add an entry 'url' to say which url to execute |
609 | 609 | // Add an entry htmlname to say which element we must change once url is called |
610 | 610 | // Add entry params => array('cssid' => 'attr') to say to remov or add attribute attr if answer of url return 0 or >0 lines |
611 | 611 | // To refresh contacts list on thirdparty list change |
612 | - $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); |
|
612 | + $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); |
|
613 | 613 | |
614 | 614 | if (count($events)) // If there is some ajax events to run once selection is done, we add code here to run events |
615 | 615 | { |
@@ -665,29 +665,29 @@ discard block |
||
665 | 665 | |
666 | 666 | print "\n".'<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->'."\n"; |
667 | 667 | print '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="'.$name.'" />'; |
668 | - print ajax_autocompleter(($socid?$socid:-1), $htmlname, DOL_URL_ROOT.'/societe/ajaxcompanies.php', '', $minLength, 0); |
|
668 | + print ajax_autocompleter(($socid ? $socid : -1), $htmlname, DOL_URL_ROOT.'/societe/ajaxcompanies.php', '', $minLength, 0); |
|
669 | 669 | return $socid; |
670 | 670 | } |
671 | 671 | else |
672 | 672 | { |
673 | 673 | // Search to list thirdparties |
674 | 674 | $sql = "SELECT s.rowid, s.nom as name FROM"; |
675 | - $sql.= " ".MAIN_DB_PREFIX."societe as s"; |
|
676 | - $sql.= " WHERE s.entity IN (".getEntity('societe').")"; |
|
675 | + $sql .= " ".MAIN_DB_PREFIX."societe as s"; |
|
676 | + $sql .= " WHERE s.entity IN (".getEntity('societe').")"; |
|
677 | 677 | // For ajax search we limit here. For combo list, we limit later |
678 | 678 | if (is_array($limitto) && count($limitto)) |
679 | 679 | { |
680 | - $sql.= " AND s.rowid IN (".join(',',$limitto).")"; |
|
680 | + $sql .= " AND s.rowid IN (".join(',', $limitto).")"; |
|
681 | 681 | } |
682 | - $sql.= " ORDER BY s.nom ASC"; |
|
682 | + $sql .= " ORDER BY s.nom ASC"; |
|
683 | 683 | |
684 | 684 | $resql = $this->db->query($sql); |
685 | 685 | if ($resql) |
686 | 686 | { |
687 | - print '<select class="flat'.($morecss?' '.$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.'"'; |
|
687 | + print '<select class="flat'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'"'; |
|
688 | 688 | if ($conf->use_javascript_ajax) |
689 | 689 | { |
690 | - $javaScript = "window.location='".$_SERVER['PHP_SELF']."?".$var_id."=".($forceid>0?$forceid:$object->id).$moreparam."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;"; |
|
690 | + $javaScript = "window.location='".$_SERVER['PHP_SELF']."?".$var_id."=".($forceid > 0 ? $forceid : $object->id).$moreparam."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;"; |
|
691 | 691 | print ' onChange="'.$javaScript.'"'; |
692 | 692 | } |
693 | 693 | print '>'; |
@@ -699,22 +699,22 @@ discard block |
||
699 | 699 | { |
700 | 700 | $obj = $this->db->fetch_object($resql); |
701 | 701 | if ($i == 0) $firstCompany = $obj->rowid; |
702 | - $disabled=0; |
|
703 | - if (is_array($limitto) && count($limitto) && ! in_array($obj->rowid,$limitto)) $disabled=1; |
|
702 | + $disabled = 0; |
|
703 | + if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) $disabled = 1; |
|
704 | 704 | if ($selected > 0 && $selected == $obj->rowid) |
705 | 705 | { |
706 | 706 | print '<option value="'.$obj->rowid.'"'; |
707 | 707 | if ($disabled) print ' disabled'; |
708 | - print ' selected>'.dol_trunc($obj->name,24).'</option>'; |
|
708 | + print ' selected>'.dol_trunc($obj->name, 24).'</option>'; |
|
709 | 709 | $firstCompany = $obj->rowid; |
710 | 710 | } |
711 | 711 | else |
712 | 712 | { |
713 | 713 | print '<option value="'.$obj->rowid.'"'; |
714 | 714 | if ($disabled) print ' disabled'; |
715 | - print '>'.dol_trunc($obj->name,24).'</option>'; |
|
715 | + print '>'.dol_trunc($obj->name, 24).'</option>'; |
|
716 | 716 | } |
717 | - $i ++; |
|
717 | + $i++; |
|
718 | 718 | } |
719 | 719 | } |
720 | 720 | print "</select>\n"; |
@@ -740,23 +740,23 @@ discard block |
||
740 | 740 | * @param string $morecss Add more css to select component |
741 | 741 | * @return void |
742 | 742 | */ |
743 | - function selectTypeContact($object, $selected, $htmlname = 'type', $source='internal', $sortorder='position', $showempty=0, $morecss='') |
|
743 | + function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '') |
|
744 | 744 | { |
745 | 745 | global $user, $langs; |
746 | 746 | |
747 | 747 | if (is_object($object) && method_exists($object, 'liste_type_contact')) |
748 | 748 | { |
749 | 749 | $lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1); |
750 | - print '<select class="flat valignmiddle'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
750 | + print '<select class="flat valignmiddle'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
|
751 | 751 | if ($showempty) print '<option value="0"></option>'; |
752 | - foreach($lesTypes as $key=>$value) |
|
752 | + foreach ($lesTypes as $key=>$value) |
|
753 | 753 | { |
754 | 754 | print '<option value="'.$key.'"'; |
755 | 755 | if ($key == $selected) print ' selected'; |
756 | 756 | print '>'.$value.'</option>'; |
757 | 757 | } |
758 | 758 | print "</select>"; |
759 | - if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
759 | + if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
760 | 760 | print "\n"; |
761 | 761 | } |
762 | 762 | } |
@@ -774,22 +774,22 @@ discard block |
||
774 | 774 | * @param string $morecss More css |
775 | 775 | * @return string |
776 | 776 | */ |
777 | - function select_ziptown($selected='', $htmlname='zipcode', $fields='', $fieldsize=0, $disableautocomplete=0, $moreattrib='',$morecss='') |
|
777 | + function select_ziptown($selected = '', $htmlname = 'zipcode', $fields = '', $fieldsize = 0, $disableautocomplete = 0, $moreattrib = '', $morecss = '') |
|
778 | 778 | { |
779 | 779 | // phpcs:enable |
780 | 780 | global $conf; |
781 | 781 | |
782 | - $out=''; |
|
782 | + $out = ''; |
|
783 | 783 | |
784 | - $size=''; |
|
785 | - if (!empty($fieldsize)) $size='size="'.$fieldsize.'"'; |
|
784 | + $size = ''; |
|
785 | + if (!empty($fieldsize)) $size = 'size="'.$fieldsize.'"'; |
|
786 | 786 | |
787 | 787 | if ($conf->use_javascript_ajax && empty($disableautocomplete)) |
788 | 788 | { |
789 | - $out.= ajax_multiautocompleter($htmlname,$fields,DOL_URL_ROOT.'/core/ajax/ziptown.php')."\n"; |
|
790 | - $moreattrib.=' autocomplete="off"'; |
|
789 | + $out .= ajax_multiautocompleter($htmlname, $fields, DOL_URL_ROOT.'/core/ajax/ziptown.php')."\n"; |
|
790 | + $moreattrib .= ' autocomplete="off"'; |
|
791 | 791 | } |
792 | - $out.= '<input id="'.$htmlname.'" class="maxwidthonsmartphone'.($morecss?' '.$morecss:'').'" type="text"'.($moreattrib?' '.$moreattrib:'').' name="'.$htmlname.'" '.$size.' value="'.$selected.'">'."\n"; |
|
792 | + $out .= '<input id="'.$htmlname.'" class="maxwidthonsmartphone'.($morecss ? ' '.$morecss : '').'" type="text"'.($moreattrib ? ' '.$moreattrib : '').' name="'.$htmlname.'" '.$size.' value="'.$selected.'">'."\n"; |
|
793 | 793 | |
794 | 794 | return $out; |
795 | 795 | } |
@@ -805,43 +805,43 @@ discard block |
||
805 | 805 | * @param string $morecss More css |
806 | 806 | * @return string HTML string with prof id |
807 | 807 | */ |
808 | - function get_input_id_prof($idprof,$htmlname,$preselected,$country_code,$morecss='maxwidth100onsmartphone quatrevingtpercent') |
|
808 | + function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth100onsmartphone quatrevingtpercent') |
|
809 | 809 | { |
810 | 810 | // phpcs:enable |
811 | - global $conf,$langs; |
|
811 | + global $conf, $langs; |
|
812 | 812 | |
813 | - $formlength=0; |
|
813 | + $formlength = 0; |
|
814 | 814 | if (empty($conf->global->MAIN_DISABLEPROFIDRULES)) { |
815 | 815 | if ($country_code == 'FR') |
816 | 816 | { |
817 | 817 | if (isset($idprof)) { |
818 | - if ($idprof==1) $formlength=9; |
|
819 | - else if ($idprof==2) $formlength=14; |
|
820 | - else if ($idprof==3) $formlength=5; // 4 chiffres et 1 lettre depuis janvier |
|
821 | - else if ($idprof==4) $formlength=32; // No maximum as we need to include a town name in this id |
|
818 | + if ($idprof == 1) $formlength = 9; |
|
819 | + else if ($idprof == 2) $formlength = 14; |
|
820 | + else if ($idprof == 3) $formlength = 5; // 4 chiffres et 1 lettre depuis janvier |
|
821 | + else if ($idprof == 4) $formlength = 32; // No maximum as we need to include a town name in this id |
|
822 | 822 | } |
823 | 823 | } |
824 | 824 | else if ($country_code == 'ES') |
825 | 825 | { |
826 | - if ($idprof==1) $formlength=9; //CIF/NIF/NIE 9 digits |
|
827 | - if ($idprof==2) $formlength=12; //NASS 12 digits without / |
|
828 | - if ($idprof==3) $formlength=5; //CNAE 5 digits |
|
829 | - if ($idprof==4) $formlength=32; //depend of college |
|
826 | + if ($idprof == 1) $formlength = 9; //CIF/NIF/NIE 9 digits |
|
827 | + if ($idprof == 2) $formlength = 12; //NASS 12 digits without / |
|
828 | + if ($idprof == 3) $formlength = 5; //CNAE 5 digits |
|
829 | + if ($idprof == 4) $formlength = 32; //depend of college |
|
830 | 830 | } |
831 | 831 | } |
832 | 832 | |
833 | - $selected=$preselected; |
|
834 | - if (! $selected && isset($idprof)) { |
|
835 | - if ($idprof==1 && ! empty($this->idprof1)) $selected=$this->idprof1; |
|
836 | - else if ($idprof==2 && ! empty($this->idprof2)) $selected=$this->idprof2; |
|
837 | - else if ($idprof==3 && ! empty($this->idprof3)) $selected=$this->idprof3; |
|
838 | - else if ($idprof==4 && ! empty($this->idprof4)) $selected=$this->idprof4; |
|
833 | + $selected = $preselected; |
|
834 | + if (!$selected && isset($idprof)) { |
|
835 | + if ($idprof == 1 && !empty($this->idprof1)) $selected = $this->idprof1; |
|
836 | + else if ($idprof == 2 && !empty($this->idprof2)) $selected = $this->idprof2; |
|
837 | + else if ($idprof == 3 && !empty($this->idprof3)) $selected = $this->idprof3; |
|
838 | + else if ($idprof == 4 && !empty($this->idprof4)) $selected = $this->idprof4; |
|
839 | 839 | } |
840 | 840 | |
841 | - $maxlength=$formlength; |
|
842 | - if (empty($formlength)) { $formlength=24; $maxlength=128; } |
|
841 | + $maxlength = $formlength; |
|
842 | + if (empty($formlength)) { $formlength = 24; $maxlength = 128; } |
|
843 | 843 | |
844 | - $out = '<input type="text" '.($morecss?'class="'.$morecss.'" ':'').'name="'.$htmlname.'" id="'.$htmlname.'" maxlength="'.$maxlength.'" value="'.$selected.'">'; |
|
844 | + $out = '<input type="text" '.($morecss ? 'class="'.$morecss.'" ' : '').'name="'.$htmlname.'" id="'.$htmlname.'" maxlength="'.$maxlength.'" value="'.$selected.'">'; |
|
845 | 845 | |
846 | 846 | return $out; |
847 | 847 | } |
@@ -858,19 +858,19 @@ discard block |
||
858 | 858 | function select_localtax($local, $selected, $htmlname) |
859 | 859 | { |
860 | 860 | // phpcs:enable |
861 | - $tax=get_localtax_by_third($local); |
|
861 | + $tax = get_localtax_by_third($local); |
|
862 | 862 | |
863 | 863 | $num = $this->db->num_rows($tax); |
864 | 864 | $i = 0; |
865 | 865 | if ($num) |
866 | 866 | { |
867 | - $valors=explode(":", $tax); |
|
867 | + $valors = explode(":", $tax); |
|
868 | 868 | |
869 | 869 | if (count($valors) > 1) |
870 | 870 | { |
871 | 871 | //montar select |
872 | 872 | print '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">'; |
873 | - while ($i <= (count($valors))-1) |
|
873 | + while ($i <= (count($valors)) - 1) |
|
874 | 874 | { |
875 | 875 | if ($selected == $valors[$i]) |
876 | 876 | { |
@@ -117,10 +117,10 @@ discard block |
||
117 | 117 | /** |
118 | 118 | * Message Sensitivity |
119 | 119 | */ |
120 | - var $_arySensitivity = array ( false, |
|
120 | + var $_arySensitivity = array(false, |
|
121 | 121 | 'Personal', |
122 | 122 | 'Private', |
123 | - 'Company Confidential' ); |
|
123 | + 'Company Confidential'); |
|
124 | 124 | |
125 | 125 | /** |
126 | 126 | * Message Sensitivity |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | /** |
132 | 132 | * Message Priority |
133 | 133 | */ |
134 | - var $_aryPriority = array ( 'Bulk', |
|
134 | + var $_aryPriority = array('Bulk', |
|
135 | 135 | 'Highest', |
136 | 136 | 'High', |
137 | 137 | 'Normal', |
138 | 138 | 'Low', |
139 | - 'Lowest' ); |
|
139 | + 'Lowest'); |
|
140 | 140 | |
141 | 141 | /** |
142 | 142 | * Content-Transfer-Encoding |
@@ -147,13 +147,13 @@ discard block |
||
147 | 147 | /** |
148 | 148 | * Content-Transfer-Encoding |
149 | 149 | */ |
150 | - var $_smtpsTransEncodeTypes = array( '7bit', // Simple 7-bit ASCII |
|
151 | - '8bit', // 8-bit coding with line termination characters |
|
152 | - 'base64', // 3 octets encoded into 4 sextets with offset |
|
153 | - 'binary', // Arbitrary binary stream |
|
154 | - 'mac-binhex40', // Macintosh binary to hex encoding |
|
155 | - 'quoted-printable', // Mostly 7-bit, with 8-bit characters encoded as "=HH" |
|
156 | - 'uuencode' ); // UUENCODE encoding |
|
150 | + var $_smtpsTransEncodeTypes = array('7bit', // Simple 7-bit ASCII |
|
151 | + '8bit', // 8-bit coding with line termination characters |
|
152 | + 'base64', // 3 octets encoded into 4 sextets with offset |
|
153 | + 'binary', // Arbitrary binary stream |
|
154 | + 'mac-binhex40', // Macintosh binary to hex encoding |
|
155 | + 'quoted-printable', // Mostly 7-bit, with 8-bit characters encoded as "=HH" |
|
156 | + 'uuencode'); // UUENCODE encoding |
|
157 | 157 | |
158 | 158 | /** |
159 | 159 | * Content-Transfer-Encoding |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | */ |
301 | 301 | function setErrorsTo($_strErrorsTo) |
302 | 302 | { |
303 | - if ( $_strErrorsTo ) |
|
303 | + if ($_strErrorsTo) |
|
304 | 304 | $this->_errorsTo = $this->_strip_email($_strErrorsTo); |
305 | 305 | } |
306 | 306 | |
@@ -310,11 +310,11 @@ discard block |
||
310 | 310 | * @param boolean $_part Variant |
311 | 311 | * @return string Errors to |
312 | 312 | */ |
313 | - function getErrorsTo($_part = true ) |
|
313 | + function getErrorsTo($_part = true) |
|
314 | 314 | { |
315 | 315 | $_retValue = ''; |
316 | 316 | |
317 | - if ( $_part === true ) |
|
317 | + if ($_part === true) |
|
318 | 318 | $_retValue = $this->_errorsTo; |
319 | 319 | else |
320 | 320 | $_retValue = $this->_errorsTo[$_part]; |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @param boolean $_vDebug Value for debug |
329 | 329 | * @return void |
330 | 330 | */ |
331 | - function setDebug($_vDebug = false ) |
|
331 | + function setDebug($_vDebug = false) |
|
332 | 332 | { |
333 | 333 | $this->_debug = $_vDebug; |
334 | 334 | } |
@@ -359,29 +359,29 @@ discard block |
||
359 | 359 | // We have to make sure the HOST given is valid |
360 | 360 | // This is done here because '@fsockopen' will not give me this |
361 | 361 | // information if it failes to connect because it can't find the HOST |
362 | - $host=$this->getHost(); |
|
363 | - $usetls = preg_match('@tls://@i',$host); |
|
362 | + $host = $this->getHost(); |
|
363 | + $usetls = preg_match('@tls://@i', $host); |
|
364 | 364 | |
365 | - $host=preg_replace('@tcp://@i','',$host); // Remove prefix |
|
366 | - $host=preg_replace('@ssl://@i','',$host); // Remove prefix |
|
367 | - $host=preg_replace('@tls://@i','',$host); // Remove prefix |
|
365 | + $host = preg_replace('@tcp://@i', '', $host); // Remove prefix |
|
366 | + $host = preg_replace('@ssl://@i', '', $host); // Remove prefix |
|
367 | + $host = preg_replace('@tls://@i', '', $host); // Remove prefix |
|
368 | 368 | |
369 | 369 | // @CHANGE LDR |
370 | 370 | include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
371 | 371 | |
372 | - if ( (! is_ip($host)) && ((gethostbyname($host)) == $host)) |
|
372 | + if ((!is_ip($host)) && ((gethostbyname($host)) == $host)) |
|
373 | 373 | { |
374 | - $this->_setErr(99, $host . ' is either offline or is an invalid host name.'); |
|
374 | + $this->_setErr(99, $host.' is either offline or is an invalid host name.'); |
|
375 | 375 | $_retVal = false; |
376 | 376 | } |
377 | 377 | else |
378 | 378 | { |
379 | 379 | //See if we can connect to the SMTP server |
380 | 380 | if ($this->socket = @fsockopen( |
381 | - preg_replace('@tls://@i','',$this->getHost()), // Host to 'hit', IP or domain |
|
382 | - $this->getPort(), // which Port number to use |
|
383 | - $this->errno, // actual system level error |
|
384 | - $this->errstr, // and any text that goes with the error |
|
381 | + preg_replace('@tls://@i', '', $this->getHost()), // Host to 'hit', IP or domain |
|
382 | + $this->getPort(), // which Port number to use |
|
383 | + $this->errno, // actual system level error |
|
384 | + $this->errstr, // and any text that goes with the error |
|
385 | 385 | $this->_smtpTimeout |
386 | 386 | )) // timeout for reading/writing data over the socket |
387 | 387 | { |
@@ -392,14 +392,14 @@ discard block |
||
392 | 392 | if (function_exists('stream_set_timeout')) stream_set_timeout($this->socket, $this->_smtpTimeout, 0); |
393 | 393 | |
394 | 394 | // Check response from Server |
395 | - if ( $_retVal = $this->server_parse($this->socket, "220") ) |
|
395 | + if ($_retVal = $this->server_parse($this->socket, "220")) |
|
396 | 396 | $_retVal = $this->socket; |
397 | 397 | } |
398 | 398 | // This connection attempt failed. |
399 | 399 | else |
400 | 400 | { |
401 | 401 | // @CHANGE LDR |
402 | - if (empty($this->errstr)) $this->errstr='Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort(); |
|
402 | + if (empty($this->errstr)) $this->errstr = 'Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort(); |
|
403 | 403 | $this->_setErr($this->errno, $this->errstr); |
404 | 404 | $_retVal = false; |
405 | 405 | } |
@@ -422,18 +422,18 @@ discard block |
||
422 | 422 | // Send the RFC2554 specified EHLO. |
423 | 423 | // This improvment as provided by 'SirSir' to |
424 | 424 | // accomodate both SMTP AND ESMTP capable servers |
425 | - $host=$this->getHost(); |
|
426 | - $usetls = preg_match('@tls://@i',$host); |
|
425 | + $host = $this->getHost(); |
|
426 | + $usetls = preg_match('@tls://@i', $host); |
|
427 | 427 | |
428 | - $host=preg_replace('@tcp://@i','',$host); // Remove prefix |
|
429 | - $host=preg_replace('@ssl://@i','',$host); // Remove prefix |
|
430 | - $host=preg_replace('@tls://@i','',$host); // Remove prefix |
|
428 | + $host = preg_replace('@tcp://@i', '', $host); // Remove prefix |
|
429 | + $host = preg_replace('@ssl://@i', '', $host); // Remove prefix |
|
430 | + $host = preg_replace('@tls://@i', '', $host); // Remove prefix |
|
431 | 431 | |
432 | - if ($usetls) $host='tls://'.$host; |
|
432 | + if ($usetls) $host = 'tls://'.$host; |
|
433 | 433 | |
434 | 434 | $hosth = $host; |
435 | 435 | |
436 | - if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) |
|
436 | + if (!empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) |
|
437 | 437 | { |
438 | 438 | // If the from to is 'aaa <[email protected]>', we will keep 'ccc.com' |
439 | 439 | $hosth = $this->getFrom('addr'); |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | $hosth = preg_replace('/.*@/', '', $hosth); |
443 | 443 | } |
444 | 444 | |
445 | - if ( $_retVal = $this->socket_send_str('EHLO ' . $hosth, '250') ) |
|
445 | + if ($_retVal = $this->socket_send_str('EHLO '.$hosth, '250')) |
|
446 | 446 | { |
447 | 447 | if ($usetls) |
448 | 448 | { |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | // the answer with list of supported AUTH methods. They may differs between non STARTTLS and with STARTTLS. |
494 | 494 | if (!$_retVal = $this->socket_send_str('EHLO '.$host, '250')) |
495 | 495 | { |
496 | - $this->_setErr(126, '"' . $host . '" does not support authenticated connections.'); |
|
496 | + $this->_setErr(126, '"'.$host.'" does not support authenticated connections.'); |
|
497 | 497 | return $_retVal; |
498 | 498 | } |
499 | 499 | } |
@@ -506,12 +506,12 @@ discard block |
||
506 | 506 | |
507 | 507 | // The error here just means the ID/password combo doesn't work. |
508 | 508 | // There is not a method to determine which is the problem, ID or password |
509 | - if ( ! $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235') ) |
|
509 | + if (!$_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235')) |
|
510 | 510 | $this->_setErr(130, 'Invalid Authentication Credentials.'); |
511 | 511 | } |
512 | 512 | else |
513 | 513 | { |
514 | - $this->_setErr(126, '"' . $host . '" does not support authenticated connections.'); |
|
514 | + $this->_setErr(126, '"'.$host.'" does not support authenticated connections.'); |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | return $_retVal; |
@@ -535,10 +535,10 @@ discard block |
||
535 | 535 | $_retVal = false; |
536 | 536 | |
537 | 537 | // Connect to Server |
538 | - if ( $this->socket = $this->_server_connect() ) |
|
538 | + if ($this->socket = $this->_server_connect()) |
|
539 | 539 | { |
540 | 540 | // If a User ID *and* a password is given, assume Authentication is desired |
541 | - if( !empty($this->_smtpsID) && !empty($this->_smtpsPW) ) |
|
541 | + if (!empty($this->_smtpsID) && !empty($this->_smtpsPW)) |
|
542 | 542 | { |
543 | 543 | // Send the RFC2554 specified EHLO. |
544 | 544 | $_retVal = $this->_server_authenticate(); |
@@ -548,16 +548,16 @@ discard block |
||
548 | 548 | else |
549 | 549 | { |
550 | 550 | // Send the RFC821 specified HELO. |
551 | - $host=$this->getHost(); |
|
552 | - $usetls = preg_match('@tls://@i',$host); |
|
551 | + $host = $this->getHost(); |
|
552 | + $usetls = preg_match('@tls://@i', $host); |
|
553 | 553 | |
554 | - $host=preg_replace('@tcp://@i','',$host); // Remove prefix |
|
555 | - $host=preg_replace('@ssl://@i','',$host); // Remove prefix |
|
556 | - $host=preg_replace('@tls://@i','',$host); // Remove prefix |
|
554 | + $host = preg_replace('@tcp://@i', '', $host); // Remove prefix |
|
555 | + $host = preg_replace('@ssl://@i', '', $host); // Remove prefix |
|
556 | + $host = preg_replace('@tls://@i', '', $host); // Remove prefix |
|
557 | 557 | |
558 | 558 | $hosth = $host; |
559 | 559 | |
560 | - if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) |
|
560 | + if (!empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) |
|
561 | 561 | { |
562 | 562 | // If the from to is 'aaa <[email protected]>', we will keep 'ccc.com' |
563 | 563 | $hosth = $this->getFrom('addr'); |
@@ -566,21 +566,21 @@ discard block |
||
566 | 566 | $hosth = preg_replace('/.*@/', '', $hosth); |
567 | 567 | } |
568 | 568 | |
569 | - $_retVal = $this->socket_send_str('HELO ' . $hosth, '250'); |
|
569 | + $_retVal = $this->socket_send_str('HELO '.$hosth, '250'); |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | // Well, did we get to the server? |
573 | - if ( $_retVal ) |
|
573 | + if ($_retVal) |
|
574 | 574 | { |
575 | 575 | // From this point onward most server response codes should be 250 |
576 | 576 | // Specify who the mail is from.... |
577 | 577 | // This has to be the raw email address, strip the "name" off |
578 | - $this->socket_send_str('MAIL FROM: ' . $this->getFrom('addr'), '250'); |
|
578 | + $this->socket_send_str('MAIL FROM: '.$this->getFrom('addr'), '250'); |
|
579 | 579 | |
580 | 580 | // 'RCPT TO:' must be given a single address, so this has to loop |
581 | 581 | // through the list of addresses, regardless of TO, CC or BCC |
582 | 582 | // and send it out "single file" |
583 | - foreach ( $this->get_RCPT_list() as $_address ) |
|
583 | + foreach ($this->get_RCPT_list() as $_address) |
|
584 | 584 | { |
585 | 585 | /* Note: |
586 | 586 | * BCC email addresses must be listed in the RCPT TO command list, |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | * mark the last address as "bad" and start the address loop over again. |
597 | 597 | * If any address fails, the entire message fails. |
598 | 598 | */ |
599 | - $this->socket_send_str('RCPT TO: <' . $_address . '>', '250'); |
|
599 | + $this->socket_send_str('RCPT TO: <'.$_address.'>', '250'); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | // Tell the server we are ready to start sending data |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | |
607 | 607 | // Now we are ready for the message... |
608 | 608 | // Ok, all the ingredients are mixed in let's cook this puppy... |
609 | - $this->socket_send_str($this->getHeader().$this->getBodyContent() . "\r\n" . '.', '250'); |
|
609 | + $this->socket_send_str($this->getHeader().$this->getBodyContent()."\r\n".'.', '250'); |
|
610 | 610 | |
611 | 611 | // Now tell the server we are done and close the socket... |
612 | 612 | fputs($this->socket, 'QUIT'); |
@@ -656,13 +656,13 @@ discard block |
||
656 | 656 | $_retVal = true; |
657 | 657 | |
658 | 658 | // if we have a path... |
659 | - if ( ! empty ($_strConfigPath) ) |
|
659 | + if (!empty ($_strConfigPath)) |
|
660 | 660 | { |
661 | 661 | // If the path is not valid, this will NOT generate an error, |
662 | 662 | // it will simply return false. |
663 | - if ( ! @include $_strConfigPath) |
|
663 | + if (!@include $_strConfigPath) |
|
664 | 664 | { |
665 | - $this->_setErr(110, '"' . $_strConfigPath . '" is not a valid path.'); |
|
665 | + $this->_setErr(110, '"'.$_strConfigPath.'" is not a valid path.'); |
|
666 | 666 | $_retVal = false; |
667 | 667 | } |
668 | 668 | } |
@@ -672,13 +672,13 @@ discard block |
||
672 | 672 | { |
673 | 673 | // Set these properties ONLY if they are set in the php.ini file. |
674 | 674 | // Otherwise the default values will be used. |
675 | - if ( $_host = ini_get('SMTPs') ) |
|
675 | + if ($_host = ini_get('SMTPs')) |
|
676 | 676 | $this->setHost($_host); |
677 | 677 | |
678 | - if ( $_port = ini_get('smtp_port') ) |
|
678 | + if ($_port = ini_get('smtp_port')) |
|
679 | 679 | $this->setPort($_port); |
680 | 680 | |
681 | - if ( $_from = ini_get('sendmail_from') ) |
|
681 | + if ($_from = ini_get('sendmail_from')) |
|
682 | 682 | $this->setFrom($_from); |
683 | 683 | } |
684 | 684 | |
@@ -697,8 +697,8 @@ discard block |
||
697 | 697 | */ |
698 | 698 | function setTransportType($_type = 0) |
699 | 699 | { |
700 | - if ( ( is_numeric($_type) ) && |
|
701 | - ( ( $_type >= 0 ) && ( $_type <= 3 ) ) ) |
|
700 | + if ((is_numeric($_type)) && |
|
701 | + (($_type >= 0) && ($_type <= 3))) |
|
702 | 702 | $this->_transportType = $_type; |
703 | 703 | } |
704 | 704 | |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | */ |
741 | 741 | function setHost($_strHost) |
742 | 742 | { |
743 | - if ( $_strHost ) |
|
743 | + if ($_strHost) |
|
744 | 744 | $this->_smtpsHost = $_strHost; |
745 | 745 | } |
746 | 746 | |
@@ -765,8 +765,8 @@ discard block |
||
765 | 765 | */ |
766 | 766 | function setPort($_intPort) |
767 | 767 | { |
768 | - if ( ( is_numeric($_intPort) ) && |
|
769 | - ( ( $_intPort >= 1 ) && ( $_intPort <= 65536 ) ) ) |
|
768 | + if ((is_numeric($_intPort)) && |
|
769 | + (($_intPort >= 1) && ($_intPort <= 65536))) |
|
770 | 770 | $this->_smtpsPort = $_intPort; |
771 | 771 | } |
772 | 772 | |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | */ |
833 | 833 | function setCharSet($_strCharSet) |
834 | 834 | { |
835 | - if ( $_strCharSet ) |
|
835 | + if ($_strCharSet) |
|
836 | 836 | $this->_smtpsCharSet = $_strCharSet; |
837 | 837 | } |
838 | 838 | |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | */ |
921 | 921 | function setFrom($_strFrom) |
922 | 922 | { |
923 | - if ( $_strFrom ) |
|
923 | + if ($_strFrom) |
|
924 | 924 | $this->_msgFrom = $this->_strip_email($_strFrom); |
925 | 925 | } |
926 | 926 | |
@@ -934,7 +934,7 @@ discard block |
||
934 | 934 | { |
935 | 935 | $_retValue = ''; |
936 | 936 | |
937 | - if ( $_part === true ) |
|
937 | + if ($_part === true) |
|
938 | 938 | $_retValue = $this->_msgFrom; |
939 | 939 | else |
940 | 940 | $_retValue = $this->_msgFrom[$_part]; |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | */ |
951 | 951 | function setReplyTo($_strReplyTo) |
952 | 952 | { |
953 | - if ( $_strReplyTo ) |
|
953 | + if ($_strReplyTo) |
|
954 | 954 | $this->_msgReplyTo = $this->_strip_email($_strReplyTo); |
955 | 955 | } |
956 | 956 | |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | { |
965 | 965 | $_retValue = ''; |
966 | 966 | |
967 | - if ( $_part === true ) |
|
967 | + if ($_part === true) |
|
968 | 968 | $_retValue = $this->_msgReplyTo; |
969 | 969 | else |
970 | 970 | $_retValue = $this->_msgReplyTo[$_part]; |
@@ -990,13 +990,13 @@ discard block |
||
990 | 990 | $aryHost = $this->_msgRecipients; |
991 | 991 | |
992 | 992 | // Only run this if we have something |
993 | - if ( !empty ($_addrList )) |
|
993 | + if (!empty ($_addrList)) |
|
994 | 994 | { |
995 | 995 | // $_addrList can be a STRING or an array |
996 | - if ( is_string($_addrList) ) |
|
996 | + if (is_string($_addrList)) |
|
997 | 997 | { |
998 | 998 | // This could be a COMMA delimited string |
999 | - if ( strstr($_addrList, ',') ) |
|
999 | + if (strstr($_addrList, ',')) |
|
1000 | 1000 | // "explode "list" into an array |
1001 | 1001 | $_addrList = explode(',', $_addrList); |
1002 | 1002 | |
@@ -1006,7 +1006,7 @@ discard block |
||
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | // take the array of addresses and split them further |
1009 | - foreach ( $_addrList as $_strAddr ) |
|
1009 | + foreach ($_addrList as $_strAddr) |
|
1010 | 1010 | { |
1011 | 1011 | // Strip off the end '>' |
1012 | 1012 | $_strAddr = str_replace('>', '', $_strAddr); |
@@ -1016,7 +1016,7 @@ discard block |
||
1016 | 1016 | $_tmpaddr = explode('<', $_strAddr); |
1017 | 1017 | |
1018 | 1018 | // We have a "Real Name" and eMail address |
1019 | - if ( count($_tmpaddr) == 2 ) |
|
1019 | + if (count($_tmpaddr) == 2) |
|
1020 | 1020 | { |
1021 | 1021 | $_tmpHost = explode('@', $_tmpaddr[1]); |
1022 | 1022 | $_tmpaddr[0] = trim($_tmpaddr[0], ' ">'); |
@@ -1073,10 +1073,10 @@ discard block |
||
1073 | 1073 | $_tmpAry = explode('<', $_strAddr); |
1074 | 1074 | |
1075 | 1075 | // Do we have a "Real name" |
1076 | - if ( count($_tmpAry) == 2 ) |
|
1076 | + if (count($_tmpAry) == 2) |
|
1077 | 1077 | { |
1078 | 1078 | // We may not really have a "Real Name" |
1079 | - if ( $_tmpAry[0]) |
|
1079 | + if ($_tmpAry[0]) |
|
1080 | 1080 | $_aryEmail['real'] = trim($_tmpAry[0], ' ">'); |
1081 | 1081 | |
1082 | 1082 | $_aryEmail['addr'] = $_tmpAry[1]; |
@@ -1085,10 +1085,10 @@ discard block |
||
1085 | 1085 | $_aryEmail['addr'] = $_tmpAry[0]; |
1086 | 1086 | |
1087 | 1087 | // Pull User Name and Host.tld apart |
1088 | - list($_aryEmail['user'], $_aryEmail['host'] ) = explode('@', $_aryEmail['addr']); |
|
1088 | + list($_aryEmail['user'], $_aryEmail['host']) = explode('@', $_aryEmail['addr']); |
|
1089 | 1089 | |
1090 | 1090 | // Put the brackets back around the address |
1091 | - $_aryEmail['addr'] = '<' . $_aryEmail['addr'] . '>'; |
|
1091 | + $_aryEmail['addr'] = '<'.$_aryEmail['addr'].'>'; |
|
1092 | 1092 | |
1093 | 1093 | return $_aryEmail; |
1094 | 1094 | } |
@@ -1107,17 +1107,17 @@ discard block |
||
1107 | 1107 | /** |
1108 | 1108 | * An array of bares addresses for use with 'RCPT TO:' |
1109 | 1109 | */ |
1110 | - $_RCPT_list=array(); |
|
1110 | + $_RCPT_list = array(); |
|
1111 | 1111 | |
1112 | 1112 | // walk down Recipients array and pull just email addresses |
1113 | - foreach ( $this->_msgRecipients as $_host => $_list ) |
|
1113 | + foreach ($this->_msgRecipients as $_host => $_list) |
|
1114 | 1114 | { |
1115 | - foreach ( $_list as $_subList ) |
|
1115 | + foreach ($_list as $_subList) |
|
1116 | 1116 | { |
1117 | - foreach ( $_subList as $_name => $_addr ) |
|
1117 | + foreach ($_subList as $_name => $_addr) |
|
1118 | 1118 | { |
1119 | 1119 | // build RCPT list |
1120 | - $_RCPT_list[] = $_name . '@' . $_host; |
|
1120 | + $_RCPT_list[] = $_name.'@'.$_host; |
|
1121 | 1121 | } |
1122 | 1122 | } |
1123 | 1123 | } |
@@ -1136,27 +1136,27 @@ discard block |
||
1136 | 1136 | { |
1137 | 1137 | // phpcs:enable |
1138 | 1138 | // We need to know which address segment to pull |
1139 | - if ( $_which ) |
|
1139 | + if ($_which) |
|
1140 | 1140 | { |
1141 | 1141 | // Make sure we have addresses to process |
1142 | - if ( $this->_msgRecipients ) |
|
1142 | + if ($this->_msgRecipients) |
|
1143 | 1143 | { |
1144 | - $_RCPT_list=array(); |
|
1144 | + $_RCPT_list = array(); |
|
1145 | 1145 | // walk down Recipients array and pull just email addresses |
1146 | - foreach ( $this->_msgRecipients as $_host => $_list ) |
|
1146 | + foreach ($this->_msgRecipients as $_host => $_list) |
|
1147 | 1147 | { |
1148 | - if ( $this->_msgRecipients[$_host][$_which] ) |
|
1148 | + if ($this->_msgRecipients[$_host][$_which]) |
|
1149 | 1149 | { |
1150 | - foreach ( $this->_msgRecipients[$_host][$_which] as $_addr => $_realName ) |
|
1150 | + foreach ($this->_msgRecipients[$_host][$_which] as $_addr => $_realName) |
|
1151 | 1151 | { |
1152 | - if ( $_realName ) // @CHANGE LDR |
|
1152 | + if ($_realName) // @CHANGE LDR |
|
1153 | 1153 | { |
1154 | - $_realName = '"' . $_realName . '"'; |
|
1155 | - $_RCPT_list[] = $_realName . ' <' . $_addr . '@' . $_host . '>'; |
|
1154 | + $_realName = '"'.$_realName.'"'; |
|
1155 | + $_RCPT_list[] = $_realName.' <'.$_addr.'@'.$_host.'>'; |
|
1156 | 1156 | } |
1157 | 1157 | else |
1158 | 1158 | { |
1159 | - $_RCPT_list[] = $_addr . '@' . $_host; |
|
1159 | + $_RCPT_list[] = $_addr.'@'.$_host; |
|
1160 | 1160 | } |
1161 | 1161 | } |
1162 | 1162 | } |
@@ -1185,7 +1185,7 @@ discard block |
||
1185 | 1185 | */ |
1186 | 1186 | function setTO($_addrTo) |
1187 | 1187 | { |
1188 | - if ( $_addrTo ) |
|
1188 | + if ($_addrTo) |
|
1189 | 1189 | $this->_buildAddrList('to', $_addrTo); |
1190 | 1190 | } |
1191 | 1191 | |
@@ -1207,7 +1207,7 @@ discard block |
||
1207 | 1207 | */ |
1208 | 1208 | function setCC($_strCC) |
1209 | 1209 | { |
1210 | - if ( $_strCC ) |
|
1210 | + if ($_strCC) |
|
1211 | 1211 | $this->_buildAddrList('cc', $_strCC); |
1212 | 1212 | } |
1213 | 1213 | |
@@ -1229,7 +1229,7 @@ discard block |
||
1229 | 1229 | */ |
1230 | 1230 | function setBCC($_strBCC) |
1231 | 1231 | { |
1232 | - if ( $_strBCC ) |
|
1232 | + if ($_strBCC) |
|
1233 | 1233 | $this->_buildAddrList('bcc', $_strBCC); |
1234 | 1234 | } |
1235 | 1235 | |
@@ -1251,7 +1251,7 @@ discard block |
||
1251 | 1251 | */ |
1252 | 1252 | function setSubject($_strSubject = '') |
1253 | 1253 | { |
1254 | - if ( $_strSubject ) |
|
1254 | + if ($_strSubject) |
|
1255 | 1255 | $this->_msgSubject = $_strSubject; |
1256 | 1256 | } |
1257 | 1257 | |
@@ -1274,11 +1274,11 @@ discard block |
||
1274 | 1274 | { |
1275 | 1275 | global $conf; |
1276 | 1276 | |
1277 | - $_header = 'From: ' . $this->getFrom('org') . "\r\n" |
|
1278 | - . 'To: ' . $this->getTO() . "\r\n"; |
|
1277 | + $_header = 'From: '.$this->getFrom('org')."\r\n" |
|
1278 | + . 'To: '.$this->getTO()."\r\n"; |
|
1279 | 1279 | |
1280 | - if ( $this->getCC() ) |
|
1281 | - $_header .= 'Cc: ' . $this->getCC() . "\r\n"; |
|
1280 | + if ($this->getCC()) |
|
1281 | + $_header .= 'Cc: '.$this->getCC()."\r\n"; |
|
1282 | 1282 | |
1283 | 1283 | /* Note: |
1284 | 1284 | * BCC email addresses must be listed in the RCPT TO command list, |
@@ -1291,57 +1291,57 @@ discard block |
||
1291 | 1291 | $_header .= 'Bcc: ' . $this->getBCC() . "\r\n"; |
1292 | 1292 | */ |
1293 | 1293 | |
1294 | - $host=$this->getHost(); |
|
1295 | - $usetls = preg_match('@tls://@i',$host); |
|
1294 | + $host = $this->getHost(); |
|
1295 | + $usetls = preg_match('@tls://@i', $host); |
|
1296 | 1296 | |
1297 | - $host=preg_replace('@tcp://@i','',$host); // Remove prefix |
|
1298 | - $host=preg_replace('@ssl://@i','',$host); // Remove prefix |
|
1299 | - $host=preg_replace('@tls://@i','',$host); // Remove prefix |
|
1297 | + $host = preg_replace('@tcp://@i', '', $host); // Remove prefix |
|
1298 | + $host = preg_replace('@ssl://@i', '', $host); // Remove prefix |
|
1299 | + $host = preg_replace('@tls://@i', '', $host); // Remove prefix |
|
1300 | 1300 | |
1301 | - $host=dol_getprefix('email'); |
|
1301 | + $host = dol_getprefix('email'); |
|
1302 | 1302 | |
1303 | 1303 | //NOTE: Message-ID should probably contain the username of the user who sent the msg |
1304 | - $_header .= 'Subject: ' . $this->getSubject() . "\r\n"; |
|
1305 | - $_header .= 'Date: ' . date("r") . "\r\n"; |
|
1304 | + $_header .= 'Subject: '.$this->getSubject()."\r\n"; |
|
1305 | + $_header .= 'Date: '.date("r")."\r\n"; |
|
1306 | 1306 | |
1307 | 1307 | $trackid = $this->getTrackId(); |
1308 | 1308 | if ($trackid) |
1309 | 1309 | { |
1310 | 1310 | // References is kept in response and Message-ID is returned into In-Reply-To: |
1311 | - $_header .= 'Message-ID: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n"; |
|
1312 | - $_header .= 'References: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n"; |
|
1313 | - $_header .= 'X-Dolibarr-TRACKID: ' . $trackid . '@' . $host . "\r\n"; |
|
1311 | + $_header .= 'Message-ID: <'.time().'.SMTPs-dolibarr-'.$trackid.'@'.$host.">\r\n"; |
|
1312 | + $_header .= 'References: <'.time().'.SMTPs-dolibarr-'.$trackid.'@'.$host.">\r\n"; |
|
1313 | + $_header .= 'X-Dolibarr-TRACKID: '.$trackid.'@'.$host."\r\n"; |
|
1314 | 1314 | } |
1315 | 1315 | else |
1316 | 1316 | { |
1317 | - $_header .= 'Message-ID: <' . time() . '.SMTPs@' . $host . ">\r\n"; |
|
1317 | + $_header .= 'Message-ID: <'.time().'.SMTPs@'.$host.">\r\n"; |
|
1318 | 1318 | } |
1319 | - if (! empty($_SERVER['REMOTE_ADDR'])) $_header .= "X-RemoteAddr: " . $_SERVER['REMOTE_ADDR']. "\r\n"; |
|
1320 | - if ( $this->getMoreInHeader() ) |
|
1321 | - $_header .= $this->getMoreInHeader(); // Value must include the "\r\n"; |
|
1319 | + if (!empty($_SERVER['REMOTE_ADDR'])) $_header .= "X-RemoteAddr: ".$_SERVER['REMOTE_ADDR']."\r\n"; |
|
1320 | + if ($this->getMoreInHeader()) |
|
1321 | + $_header .= $this->getMoreInHeader(); // Value must include the "\r\n"; |
|
1322 | 1322 | |
1323 | 1323 | //$_header .= |
1324 | 1324 | // 'Read-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n" |
1325 | 1325 | // 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n"; |
1326 | 1326 | |
1327 | - if ( $this->getSensitivity() ) |
|
1328 | - $_header .= 'Sensitivity: ' . $this->getSensitivity() . "\r\n"; |
|
1327 | + if ($this->getSensitivity()) |
|
1328 | + $_header .= 'Sensitivity: '.$this->getSensitivity()."\r\n"; |
|
1329 | 1329 | |
1330 | - if ( $this->_msgPriority != 3 ) |
|
1330 | + if ($this->_msgPriority != 3) |
|
1331 | 1331 | $_header .= $this->getPriority(); |
1332 | 1332 | |
1333 | 1333 | |
1334 | 1334 | // @CHANGE LDR |
1335 | - if ( $this->getDeliveryReceipt() ) |
|
1336 | - $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr') . "\r\n"; |
|
1337 | - if ( $this->getErrorsTo() ) |
|
1338 | - $_header .= 'Errors-To: '.$this->getErrorsTo('addr') . "\r\n"; |
|
1339 | - if ( $this->getReplyTo() ) |
|
1340 | - $_header .= "Reply-To: ".$this->getReplyTo('addr') ."\r\n"; |
|
1335 | + if ($this->getDeliveryReceipt()) |
|
1336 | + $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr')."\r\n"; |
|
1337 | + if ($this->getErrorsTo()) |
|
1338 | + $_header .= 'Errors-To: '.$this->getErrorsTo('addr')."\r\n"; |
|
1339 | + if ($this->getReplyTo()) |
|
1340 | + $_header .= "Reply-To: ".$this->getReplyTo('addr')."\r\n"; |
|
1341 | 1341 | |
1342 | - $_header .= 'X-Mailer: Dolibarr version ' . DOL_VERSION .' (using SMTPs Mailer)' . "\r\n"; |
|
1343 | - $_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART?'MAIN_MAIL_USE_MULTI_PART':'No MAIN_MAIL_USE_MULTI_PART') . "\r\n"; |
|
1344 | - $_header .= 'Mime-Version: 1.0' . "\r\n"; |
|
1342 | + $_header .= 'X-Mailer: Dolibarr version '.DOL_VERSION.' (using SMTPs Mailer)'."\r\n"; |
|
1343 | + $_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART ? 'MAIN_MAIL_USE_MULTI_PART' : 'No MAIN_MAIL_USE_MULTI_PART')."\r\n"; |
|
1344 | + $_header .= 'Mime-Version: 1.0'."\r\n"; |
|
1345 | 1345 | |
1346 | 1346 | |
1347 | 1347 | return $_header; |
@@ -1358,7 +1358,7 @@ discard block |
||
1358 | 1358 | { |
1359 | 1359 | //if ( $strContent ) |
1360 | 1360 | //{ |
1361 | - if ( $strType == 'html' ) |
|
1361 | + if ($strType == 'html') |
|
1362 | 1362 | $strMimeType = 'text/html'; |
1363 | 1363 | else |
1364 | 1364 | $strMimeType = 'text/plain'; |
@@ -1370,14 +1370,14 @@ discard block |
||
1370 | 1370 | if ($strType == 'html') |
1371 | 1371 | { |
1372 | 1372 | // Similar code to forge a text from html is also in CMailFile.class.php |
1373 | - $strContentAltText = preg_replace("/<br\s*[^>]*>/"," ", $strContent); |
|
1373 | + $strContentAltText = preg_replace("/<br\s*[^>]*>/", " ", $strContent); |
|
1374 | 1374 | $strContentAltText = html_entity_decode(strip_tags($strContentAltText)); |
1375 | 1375 | $strContentAltText = rtrim(wordwrap($strContentAltText, 75, "\r\n")); |
1376 | 1376 | } |
1377 | 1377 | |
1378 | 1378 | // Make RFC2045 Compliant |
1379 | 1379 | //$strContent = rtrim(chunk_split($strContent)); // Function chunck_split seems ko if not used on a base64 content |
1380 | - $strContent = rtrim(wordwrap($strContent, 75, "\r\n")); // TODO Using this method creates unexpected line break on text/plain content. |
|
1380 | + $strContent = rtrim(wordwrap($strContent, 75, "\r\n")); // TODO Using this method creates unexpected line break on text/plain content. |
|
1381 | 1381 | |
1382 | 1382 | $this->_msgContent[$strType] = array(); |
1383 | 1383 | |
@@ -1385,7 +1385,7 @@ discard block |
||
1385 | 1385 | $this->_msgContent[$strType]['data'] = $strContent; |
1386 | 1386 | $this->_msgContent[$strType]['dataText'] = $strContentAltText; |
1387 | 1387 | |
1388 | - if ( $this->getMD5flag() ) |
|
1388 | + if ($this->getMD5flag()) |
|
1389 | 1389 | $this->_msgContent[$strType]['md5'] = dol_hash($strContent, 3); |
1390 | 1390 | //} |
1391 | 1391 | } |
@@ -1409,49 +1409,49 @@ discard block |
||
1409 | 1409 | $keyCount = count($_types); |
1410 | 1410 | |
1411 | 1411 | // If we have ZERO, we have a problem |
1412 | - if( $keyCount === 0 ) |
|
1412 | + if ($keyCount === 0) |
|
1413 | 1413 | die ("Sorry, no content"); |
1414 | 1414 | |
1415 | 1415 | // If we have ONE, we can use the simple format |
1416 | - else if( $keyCount === 1 && empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) |
|
1416 | + else if ($keyCount === 1 && empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) |
|
1417 | 1417 | { |
1418 | 1418 | $_msgData = $this->_msgContent; |
1419 | 1419 | $_msgData = $_msgData[$_types[0]]; |
1420 | 1420 | |
1421 | - $content = 'Content-Type: ' . $_msgData['mimeType'] . '; charset="' . $this->getCharSet() . '"' . "\r\n" |
|
1422 | - . 'Content-Transfer-Encoding: ' . $this->getTransEncodeType() . "\r\n" |
|
1423 | - . 'Content-Disposition: inline' . "\r\n" |
|
1424 | - . 'Content-Description: Message' . "\r\n"; |
|
1421 | + $content = 'Content-Type: '.$_msgData['mimeType'].'; charset="'.$this->getCharSet().'"'."\r\n" |
|
1422 | + . 'Content-Transfer-Encoding: '.$this->getTransEncodeType()."\r\n" |
|
1423 | + . 'Content-Disposition: inline'."\r\n" |
|
1424 | + . 'Content-Description: Message'."\r\n"; |
|
1425 | 1425 | |
1426 | - if ( $this->getMD5flag() ) |
|
1427 | - $content .= 'Content-MD5: ' . $_msgData['md5'] . "\r\n"; |
|
1426 | + if ($this->getMD5flag()) |
|
1427 | + $content .= 'Content-MD5: '.$_msgData['md5']."\r\n"; |
|
1428 | 1428 | |
1429 | 1429 | $content .= "\r\n" |
1430 | - . $_msgData['data'] . "\r\n"; |
|
1430 | + . $_msgData['data']."\r\n"; |
|
1431 | 1431 | } |
1432 | 1432 | |
1433 | 1433 | // If we have more than ONE, we use the multi-part format |
1434 | - else if( $keyCount >= 1 || ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) |
|
1434 | + else if ($keyCount >= 1 || !empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) |
|
1435 | 1435 | { |
1436 | 1436 | // Since this is an actual multi-part message |
1437 | 1437 | // We need to define a content message Boundary |
1438 | 1438 | // NOTE: This was 'multipart/alternative', but Windows based mail servers have issues with this. |
1439 | 1439 | |
1440 | 1440 | //$content = 'Content-Type: multipart/related; boundary="' . $this->_getBoundary() . '"' . "\r\n"; |
1441 | - $content = 'Content-Type: multipart/mixed; boundary="' . $this->_getBoundary('mixed') . '"' . "\r\n"; |
|
1441 | + $content = 'Content-Type: multipart/mixed; boundary="'.$this->_getBoundary('mixed').'"'."\r\n"; |
|
1442 | 1442 | |
1443 | 1443 | // . "\r\n" |
1444 | 1444 | // . 'This is a multi-part message in MIME format.' . "\r\n"; |
1445 | 1445 | $content .= "Content-Transfer-Encoding: 8bit\r\n"; |
1446 | 1446 | $content .= "\r\n"; |
1447 | 1447 | |
1448 | - $content .= "--" . $this->_getBoundary('mixed') . "\r\n"; |
|
1448 | + $content .= "--".$this->_getBoundary('mixed')."\r\n"; |
|
1449 | 1449 | |
1450 | 1450 | if (key_exists('image', $this->_msgContent)) // If inline image found |
1451 | 1451 | { |
1452 | - $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; |
|
1452 | + $content .= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"'."\r\n"; |
|
1453 | 1453 | $content .= "\r\n"; |
1454 | - $content .= "--" . $this->_getBoundary('alternative') . "\r\n"; |
|
1454 | + $content .= "--".$this->_getBoundary('alternative')."\r\n"; |
|
1455 | 1455 | } |
1456 | 1456 | |
1457 | 1457 | |
@@ -1459,93 +1459,93 @@ discard block |
||
1459 | 1459 | |
1460 | 1460 | |
1461 | 1461 | // Loop through message content array |
1462 | - foreach ($this->_msgContent as $type => $_content ) |
|
1462 | + foreach ($this->_msgContent as $type => $_content) |
|
1463 | 1463 | { |
1464 | - if ( $type == 'attachment' ) |
|
1464 | + if ($type == 'attachment') |
|
1465 | 1465 | { |
1466 | 1466 | // loop through all attachments |
1467 | - foreach ( $_content as $_file => $_data ) |
|
1467 | + foreach ($_content as $_file => $_data) |
|
1468 | 1468 | { |
1469 | - $content .= "--" . $this->_getBoundary('mixed') . "\r\n" |
|
1470 | - . 'Content-Disposition: attachment; filename="' . $_data['fileName'] . '"' . "\r\n" |
|
1471 | - . 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['fileName'] . '"' . "\r\n" |
|
1472 | - . 'Content-Transfer-Encoding: base64' . "\r\n" |
|
1473 | - . 'Content-Description: ' . $_data['fileName'] ."\r\n"; |
|
1469 | + $content .= "--".$this->_getBoundary('mixed')."\r\n" |
|
1470 | + . 'Content-Disposition: attachment; filename="'.$_data['fileName'].'"'."\r\n" |
|
1471 | + . 'Content-Type: '.$_data['mimeType'].'; name="'.$_data['fileName'].'"'."\r\n" |
|
1472 | + . 'Content-Transfer-Encoding: base64'."\r\n" |
|
1473 | + . 'Content-Description: '.$_data['fileName']."\r\n"; |
|
1474 | 1474 | |
1475 | - if ( $this->getMD5flag() ) |
|
1476 | - $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; |
|
1475 | + if ($this->getMD5flag()) |
|
1476 | + $content .= 'Content-MD5: '.$_data['md5']."\r\n"; |
|
1477 | 1477 | |
1478 | - $content .= "\r\n" . $_data['data'] . "\r\n\r\n"; |
|
1478 | + $content .= "\r\n".$_data['data']."\r\n\r\n"; |
|
1479 | 1479 | } |
1480 | 1480 | } |
1481 | 1481 | // @CHANGE LDR |
1482 | - else if ( $type == 'image' ) |
|
1482 | + else if ($type == 'image') |
|
1483 | 1483 | { |
1484 | 1484 | // loop through all images |
1485 | - foreach ( $_content as $_image => $_data ) |
|
1485 | + foreach ($_content as $_image => $_data) |
|
1486 | 1486 | { |
1487 | - $content .= "--" . $this->_getBoundary('related') . "\r\n"; // always related for an inline image |
|
1487 | + $content .= "--".$this->_getBoundary('related')."\r\n"; // always related for an inline image |
|
1488 | 1488 | |
1489 | - $content .= 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['imageName'] . '"' . "\r\n" |
|
1490 | - . 'Content-Transfer-Encoding: base64' . "\r\n" |
|
1491 | - . 'Content-Disposition: inline; filename="' . $_data['imageName'] . '"' . "\r\n" |
|
1492 | - . 'Content-ID: <' . $_data['cid'] . '> ' . "\r\n"; |
|
1489 | + $content .= 'Content-Type: '.$_data['mimeType'].'; name="'.$_data['imageName'].'"'."\r\n" |
|
1490 | + . 'Content-Transfer-Encoding: base64'."\r\n" |
|
1491 | + . 'Content-Disposition: inline; filename="'.$_data['imageName'].'"'."\r\n" |
|
1492 | + . 'Content-ID: <'.$_data['cid'].'> '."\r\n"; |
|
1493 | 1493 | |
1494 | - if ( $this->getMD5flag() ) |
|
1495 | - $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; |
|
1494 | + if ($this->getMD5flag()) |
|
1495 | + $content .= 'Content-MD5: '.$_data['md5']."\r\n"; |
|
1496 | 1496 | |
1497 | 1497 | $content .= "\r\n" |
1498 | - . $_data['data'] . "\r\n"; |
|
1498 | + . $_data['data']."\r\n"; |
|
1499 | 1499 | } |
1500 | 1500 | |
1501 | 1501 | // always end related and end alternative after inline images |
1502 | - $content.= "--" . $this->_getBoundary('related') . "--" . "\r\n"; |
|
1503 | - $content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n"; |
|
1504 | - $content.= "\r\n"; |
|
1502 | + $content .= "--".$this->_getBoundary('related')."--"."\r\n"; |
|
1503 | + $content .= "\r\n"."--".$this->_getBoundary('alternative')."--"."\r\n"; |
|
1504 | + $content .= "\r\n"; |
|
1505 | 1505 | } |
1506 | 1506 | else |
1507 | 1507 | { |
1508 | 1508 | if (key_exists('image', $this->_msgContent)) |
1509 | 1509 | { |
1510 | - $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n"; |
|
1511 | - $content.= "\r\n" . ($_content['dataText']?$_content['dataText']:strip_tags($_content['data'])) . "\r\n"; // Add plain text message |
|
1512 | - $content.= "--" . $this->_getBoundary('alternative') . "\r\n"; |
|
1513 | - $content.= 'Content-Type: multipart/related; boundary="' . $this->_getBoundary('related') . '"' . "\r\n"; |
|
1514 | - $content.= "\r\n"; |
|
1515 | - $content.= "--" . $this->_getBoundary('related') . "\r\n"; |
|
1510 | + $content .= "Content-Type: text/plain; charset=".$this->getCharSet()."\r\n"; |
|
1511 | + $content .= "\r\n".($_content['dataText'] ? $_content['dataText'] : strip_tags($_content['data']))."\r\n"; // Add plain text message |
|
1512 | + $content .= "--".$this->_getBoundary('alternative')."\r\n"; |
|
1513 | + $content .= 'Content-Type: multipart/related; boundary="'.$this->_getBoundary('related').'"'."\r\n"; |
|
1514 | + $content .= "\r\n"; |
|
1515 | + $content .= "--".$this->_getBoundary('related')."\r\n"; |
|
1516 | 1516 | } |
1517 | 1517 | |
1518 | - if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part |
|
1518 | + if (!key_exists('image', $this->_msgContent) && $_content['dataText'] && !empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part |
|
1519 | 1519 | { |
1520 | - $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; |
|
1520 | + $content .= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"'."\r\n"; |
|
1521 | 1521 | $content .= "\r\n"; |
1522 | - $content .= "--" . $this->_getBoundary('alternative') . "\r\n"; |
|
1522 | + $content .= "--".$this->_getBoundary('alternative')."\r\n"; |
|
1523 | 1523 | |
1524 | - $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n"; |
|
1525 | - $content.= "\r\n". $_content['dataText'] . "\r\n"; |
|
1526 | - $content.= "--" . $this->_getBoundary('alternative') . "\r\n"; |
|
1524 | + $content .= "Content-Type: text/plain; charset=".$this->getCharSet()."\r\n"; |
|
1525 | + $content .= "\r\n".$_content['dataText']."\r\n"; |
|
1526 | + $content .= "--".$this->_getBoundary('alternative')."\r\n"; |
|
1527 | 1527 | } |
1528 | 1528 | |
1529 | - $content .= 'Content-Type: ' . $_content['mimeType'] . '; ' |
|
1529 | + $content .= 'Content-Type: '.$_content['mimeType'].'; ' |
|
1530 | 1530 | // . 'charset="' . $this->getCharSet() . '"'; |
1531 | - . 'charset=' . $this->getCharSet() . ''; |
|
1531 | + . 'charset='.$this->getCharSet().''; |
|
1532 | 1532 | |
1533 | 1533 | // $content .= ( $type == 'html') ? '; name="HTML Part"' : ''; |
1534 | - $content .= "\r\n"; |
|
1534 | + $content .= "\r\n"; |
|
1535 | 1535 | // $content .= 'Content-Transfer-Encoding: '; |
1536 | 1536 | // $content .= ($type == 'html') ? 'quoted-printable' : $this->getTransEncodeType(); |
1537 | 1537 | // $content .= "\r\n" |
1538 | 1538 | // . 'Content-Disposition: inline' . "\r\n" |
1539 | 1539 | // . 'Content-Description: ' . $type . ' message' . "\r\n"; |
1540 | 1540 | |
1541 | - if ( $this->getMD5flag() ) |
|
1542 | - $content .= 'Content-MD5: ' . $_content['md5'] . "\r\n"; |
|
1541 | + if ($this->getMD5flag()) |
|
1542 | + $content .= 'Content-MD5: '.$_content['md5']."\r\n"; |
|
1543 | 1543 | |
1544 | - $content .= "\r\n" . $_content['data'] . "\r\n"; |
|
1544 | + $content .= "\r\n".$_content['data']."\r\n"; |
|
1545 | 1545 | |
1546 | - if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part after html part |
|
1546 | + if (!key_exists('image', $this->_msgContent) && $_content['dataText'] && !empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part after html part |
|
1547 | 1547 | { |
1548 | - $content.= "--" . $this->_getBoundary('alternative') . "--". "\r\n"; |
|
1548 | + $content .= "--".$this->_getBoundary('alternative')."--"."\r\n"; |
|
1549 | 1549 | } |
1550 | 1550 | |
1551 | 1551 | $content .= "\r\n"; |
@@ -1554,7 +1554,7 @@ discard block |
||
1554 | 1554 | |
1555 | 1555 | // Close message boundries |
1556 | 1556 | // $content .= "\r\n--" . $this->_getBoundary() . '--' . "\r\n" ; |
1557 | - $content .= "--" . $this->_getBoundary('mixed') . '--' . "\r\n" ; |
|
1557 | + $content .= "--".$this->_getBoundary('mixed').'--'."\r\n"; |
|
1558 | 1558 | } |
1559 | 1559 | |
1560 | 1560 | return $content; |
@@ -1571,15 +1571,15 @@ discard block |
||
1571 | 1571 | */ |
1572 | 1572 | function setAttachment($strContent, $strFileName = 'unknown', $strMimeType = 'unknown') |
1573 | 1573 | { |
1574 | - if ( $strContent ) |
|
1574 | + if ($strContent) |
|
1575 | 1575 | { |
1576 | - $strContent = rtrim(chunk_split(base64_encode($strContent), 76, "\r\n")); // 76 max is defined into http://tools.ietf.org/html/rfc2047 |
|
1576 | + $strContent = rtrim(chunk_split(base64_encode($strContent), 76, "\r\n")); // 76 max is defined into http://tools.ietf.org/html/rfc2047 |
|
1577 | 1577 | |
1578 | 1578 | $this->_msgContent['attachment'][$strFileName]['mimeType'] = $strMimeType; |
1579 | 1579 | $this->_msgContent['attachment'][$strFileName]['fileName'] = $strFileName; |
1580 | 1580 | $this->_msgContent['attachment'][$strFileName]['data'] = $strContent; |
1581 | 1581 | |
1582 | - if ( $this->getMD5flag() ) |
|
1582 | + if ($this->getMD5flag()) |
|
1583 | 1583 | $this->_msgContent['attachment'][$strFileName]['md5'] = dol_hash($strContent, 3); |
1584 | 1584 | } |
1585 | 1585 | } |
@@ -1606,7 +1606,7 @@ discard block |
||
1606 | 1606 | $this->_msgContent['image'][$strImageName]['cid'] = $strImageCid; |
1607 | 1607 | $this->_msgContent['image'][$strImageName]['data'] = $strContent; |
1608 | 1608 | |
1609 | - if ( $this->getMD5flag() ) |
|
1609 | + if ($this->getMD5flag()) |
|
1610 | 1610 | $this->_msgContent['image'][$strImageName]['md5'] = dol_hash($strContent, 3); |
1611 | 1611 | } |
1612 | 1612 | } |
@@ -1626,8 +1626,8 @@ discard block |
||
1626 | 1626 | */ |
1627 | 1627 | function setSensitivity($_value = 0) |
1628 | 1628 | { |
1629 | - if ( ( is_numeric($_value) ) && |
|
1630 | - ( ( $_value >= 0 ) && ( $_value <= 3 ) ) ) |
|
1629 | + if ((is_numeric($_value)) && |
|
1630 | + (($_value >= 0) && ($_value <= 3))) |
|
1631 | 1631 | $this->_msgSensitivity = $_value; |
1632 | 1632 | } |
1633 | 1633 | |
@@ -1659,10 +1659,10 @@ discard block |
||
1659 | 1659 | * @param integer $_value Message Priority |
1660 | 1660 | * @return void |
1661 | 1661 | */ |
1662 | - function setPriority( $_value = 3 ) |
|
1662 | + function setPriority($_value = 3) |
|
1663 | 1663 | { |
1664 | - if ( ( is_numeric($_value) ) && |
|
1665 | - ( ( $_value >= 0 ) && ( $_value <= 5 ) ) ) |
|
1664 | + if ((is_numeric($_value)) && |
|
1665 | + (($_value >= 0) && ($_value <= 5))) |
|
1666 | 1666 | $this->_msgPriority = $_value; |
1667 | 1667 | } |
1668 | 1668 | |
@@ -1680,9 +1680,9 @@ discard block |
||
1680 | 1680 | */ |
1681 | 1681 | function getPriority() |
1682 | 1682 | { |
1683 | - return 'Importance: ' . $this->_aryPriority[$this->_msgPriority] . "\r\n" |
|
1684 | - . 'Priority: ' . $this->_aryPriority[$this->_msgPriority] . "\r\n" |
|
1685 | - . 'X-Priority: ' . $this->_msgPriority . ' (' . $this->_aryPriority[$this->_msgPriority] . ')' . "\r\n"; |
|
1683 | + return 'Importance: '.$this->_aryPriority[$this->_msgPriority]."\r\n" |
|
1684 | + . 'Priority: '.$this->_aryPriority[$this->_msgPriority]."\r\n" |
|
1685 | + . 'X-Priority: '.$this->_msgPriority.' ('.$this->_aryPriority[$this->_msgPriority].')'."\r\n"; |
|
1686 | 1686 | } |
1687 | 1687 | |
1688 | 1688 | /** |
@@ -1716,7 +1716,7 @@ discard block |
||
1716 | 1716 | */ |
1717 | 1717 | function setXheader($strXdata) |
1718 | 1718 | { |
1719 | - if ( $strXdata ) |
|
1719 | + if ($strXdata) |
|
1720 | 1720 | $this->_msgXheader[] = $strXdata; |
1721 | 1721 | } |
1722 | 1722 | |
@@ -1737,7 +1737,7 @@ discard block |
||
1737 | 1737 | */ |
1738 | 1738 | function _setBoundary() |
1739 | 1739 | { |
1740 | - $this->_smtpsBoundary = "multipart_x." . time() . ".x_boundary"; |
|
1740 | + $this->_smtpsBoundary = "multipart_x.".time().".x_boundary"; |
|
1741 | 1741 | $this->_smtpsRelatedBoundary = 'mul_'.dol_hash(uniqid("dolibarr2"), 3); |
1742 | 1742 | $this->_smtpsAlternativeBoundary = 'mul_'.dol_hash(uniqid("dolibarr3"), 3); |
1743 | 1743 | } |
@@ -1748,7 +1748,7 @@ discard block |
||
1748 | 1748 | * @param string $type Type of boundary |
1749 | 1749 | * @return string $_smtpsBoundary MIME message Boundary |
1750 | 1750 | */ |
1751 | - function _getBoundary($type='mixed') |
|
1751 | + function _getBoundary($type = 'mixed') |
|
1752 | 1752 | { |
1753 | 1753 | if ($type == 'mixed') return $this->_smtpsBoundary; |
1754 | 1754 | else if ($type == 'related') return $this->_smtpsRelatedBoundary; |
@@ -1776,11 +1776,11 @@ discard block |
||
1776 | 1776 | $server_response = ''; |
1777 | 1777 | |
1778 | 1778 | // avoid infinite loop |
1779 | - $limit=0; |
|
1779 | + $limit = 0; |
|
1780 | 1780 | |
1781 | - while (substr($server_response,3,1) != ' ' && $limit<100) |
|
1781 | + while (substr($server_response, 3, 1) != ' ' && $limit < 100) |
|
1782 | 1782 | { |
1783 | - if (! ($server_response = fgets($socket, 256))) |
|
1783 | + if (!($server_response = fgets($socket, 256))) |
|
1784 | 1784 | { |
1785 | 1785 | $this->_setErr(121, "Couldn't get mail server response codes"); |
1786 | 1786 | $_retVal = false; |
@@ -1789,7 +1789,7 @@ discard block |
||
1789 | 1789 | $limit++; |
1790 | 1790 | } |
1791 | 1791 | |
1792 | - if (! (substr($server_response, 0, 3) == $response)) |
|
1792 | + if (!(substr($server_response, 0, 3) == $response)) |
|
1793 | 1793 | { |
1794 | 1794 | $this->_setErr(120, "Ran into problems sending Mail.\r\nResponse: $server_response"); |
1795 | 1795 | $_retVal = false; |
@@ -1807,14 +1807,14 @@ discard block |
||
1807 | 1807 | * @param string $CRLF CRLF |
1808 | 1808 | * @return boolean|null True or false |
1809 | 1809 | */ |
1810 | - function socket_send_str( $_strSend, $_returnCode = null, $CRLF = "\r\n" ) |
|
1810 | + function socket_send_str($_strSend, $_returnCode = null, $CRLF = "\r\n") |
|
1811 | 1811 | { |
1812 | 1812 | // phpcs:enable |
1813 | - if ($this->_debug) $this->log.=$_strSend; // @CHANGE LDR for log |
|
1814 | - fputs($this->socket, $_strSend . $CRLF); |
|
1815 | - if ($this->_debug) $this->log.=' ('.$_returnCode.')' . $CRLF; |
|
1813 | + if ($this->_debug) $this->log .= $_strSend; // @CHANGE LDR for log |
|
1814 | + fputs($this->socket, $_strSend.$CRLF); |
|
1815 | + if ($this->_debug) $this->log .= ' ('.$_returnCode.')'.$CRLF; |
|
1816 | 1816 | |
1817 | - if ( $_returnCode ) |
|
1817 | + if ($_returnCode) |
|
1818 | 1818 | return $this->server_parse($this->socket, $_returnCode); |
1819 | 1819 | } |
1820 | 1820 | |
@@ -1828,7 +1828,7 @@ discard block |
||
1828 | 1828 | * @param string $_errMsg Error Message |
1829 | 1829 | * @return void |
1830 | 1830 | */ |
1831 | - function _setErr( $_errNum, $_errMsg ) |
|
1831 | + function _setErr($_errNum, $_errMsg) |
|
1832 | 1832 | { |
1833 | 1833 | $this->_smtpsErrors[] = array( |
1834 | 1834 | 'num' => $_errNum, |
@@ -1847,9 +1847,9 @@ discard block |
||
1847 | 1847 | |
1848 | 1848 | if (is_array($this->_smtpsErrors)) |
1849 | 1849 | { |
1850 | - foreach ( $this->_smtpsErrors as $_err => $_info ) |
|
1850 | + foreach ($this->_smtpsErrors as $_err => $_info) |
|
1851 | 1851 | { |
1852 | - $_errMsg[] = 'Error [' . $_info['num'] .']: '. $_info['msg']; |
|
1852 | + $_errMsg[] = 'Error ['.$_info['num'].']: '.$_info['msg']; |
|
1853 | 1853 | } |
1854 | 1854 | } |
1855 | 1855 |