Passed
Push — master ( 853f8f...c34860 )
by Alxarafe
25:12
created
dolibarr/htdocs/core/class/CSMSFile.class.php 1 patch
Braces   +38 added lines, -24 removed lines patch added patch discarded remove patch
@@ -65,8 +65,12 @@  discard block
 block discarded – undo
65 65
 
66 66
 		// On definit fin de ligne
67 67
 		$this->eol="\n";
68
-		if (preg_match('/^win/i',PHP_OS)) $this->eol="\r\n";
69
-		if (preg_match('/^mac/i',PHP_OS)) $this->eol="\r";
68
+		if (preg_match('/^win/i',PHP_OS)) {
69
+		    $this->eol="\r\n";
70
+		}
71
+		if (preg_match('/^mac/i',PHP_OS)) {
72
+		    $this->eol="\r";
73
+		}
70 74
 
71 75
 		// If ending method not defined
72 76
 		if (empty($conf->global->MAIN_SMS_SENDMODE))
@@ -108,15 +112,19 @@  discard block
 block discarded – undo
108 112
 
109 113
         $this->message=stripslashes($this->message);
110 114
 
111
-        if (! empty($conf->global->MAIN_SMS_DEBUG)) $this->dump_sms();
115
+        if (! empty($conf->global->MAIN_SMS_DEBUG)) {
116
+            $this->dump_sms();
117
+        }
112 118
 
113 119
 		if (empty($conf->global->MAIN_DISABLE_ALL_SMS))
114 120
 		{
115 121
 
116 122
 		    // Action according to choosed sending method
117
-		    if ($conf->global->MAIN_SMS_SENDMODE == 'ovh')    // Backward compatibility    @deprecated
123
+		    if ($conf->global->MAIN_SMS_SENDMODE == 'ovh') {
124
+		        // Backward compatibility    @deprecated
118 125
 			{
119 126
 				dol_include_once('/ovh/class/ovhsms.class.php');
127
+		    }
120 128
 				$sms=new OvhSms($this->db);
121 129
 				$sms->expe=$this->addr_from;
122 130
 				$sms->dest=$this->addr_to;
@@ -131,17 +139,19 @@  discard block
 block discarded – undo
131 139
 				{
132 140
 					$this->error=$sms->error;
133 141
 					dol_syslog("CSMSFile::sendfile: sms send error=".$this->error, LOG_ERR);
134
-				}
135
-				else
142
+				} else
136 143
 				{
137 144
 					dol_syslog("CSMSFile::sendfile: sms send success with id=".$res, LOG_DEBUG);
138 145
 					//var_dump($res);        // 1973128
139
-					if (! empty($conf->global->MAIN_SMS_DEBUG)) $this->dump_sms_result($res);
146
+					if (! empty($conf->global->MAIN_SMS_DEBUG)) {
147
+					    $this->dump_sms_result($res);
148
+					}
140 149
 				}
141
-			}
142
-		    else if (! empty($conf->global->MAIN_SMS_SENDMODE))    // $conf->global->MAIN_SMS_SENDMODE looks like a value 'class@module'
150
+			} else if (! empty($conf->global->MAIN_SMS_SENDMODE)) {
151
+		        // $conf->global->MAIN_SMS_SENDMODE looks like a value 'class@module'
143 152
 		    {
144 153
 		        $tmp=explode('@',$conf->global->MAIN_SMS_SENDMODE);
154
+		    }
145 155
 		        $classfile=$tmp[0]; $module=(empty($tmp[1])?$tmp[0]:$tmp[1]);
146 156
 		        dol_include_once('/'.$module.'/class/'.$classfile.'.class.php');
147 157
 		        try
@@ -162,28 +172,26 @@  discard block
 block discarded – undo
162 172
     				if ($res <= 0)
163 173
     				{
164 174
     					dol_syslog("CSMSFile::sendfile: sms send error=".$this->error, LOG_ERR);
165
-    				}
166
-    				else
175
+    				} else
167 176
     				{
168 177
     					dol_syslog("CSMSFile::sendfile: sms send success with id=".$res, LOG_DEBUG);
169 178
     					//var_dump($res);        // 1973128
170
-    					if (! empty($conf->global->MAIN_SMS_DEBUG)) $this->dump_sms_result($res);
179
+    					if (! empty($conf->global->MAIN_SMS_DEBUG)) {
180
+    					    $this->dump_sms_result($res);
181
+    					}
171 182
     				}
172
-		        }
173
-		        catch(Exception $e)
183
+		        } catch(Exception $e)
174 184
 		        {
175 185
 		            dol_print_error('','Error to get list of senders: '.$e->getMessage());
176 186
 		        }
177
-		    }
178
-			else
187
+		    } else
179 188
 			{
180 189
 				// Send sms method not correctly defined
181 190
 				// --------------------------------------
182 191
 
183 192
 				return 'Bad value for MAIN_SMS_SENDMODE constant';
184 193
 			}
185
-		}
186
-		else
194
+		} else
187 195
 		{
188 196
 			$this->error='No sms sent. Feature is disabled by option MAIN_DISABLE_ALL_SMS';
189 197
 			dol_syslog("CSMSFile::sendfile: ".$this->error, LOG_WARNING);
@@ -207,9 +215,11 @@  discard block
 block discarded – undo
207 215
         // phpcs:enable
208 216
 		global $conf,$dolibarr_main_data_root;
209 217
 
210
-		if (@is_writeable($dolibarr_main_data_root))	// Avoid fatal error on fopen with open_basedir
218
+		if (@is_writeable($dolibarr_main_data_root)) {
219
+		    // Avoid fatal error on fopen with open_basedir
211 220
 		{
212 221
 			$outputfile=$dolibarr_main_data_root."/dolibarr_sms.log";
222
+		}
213 223
 			$fp = fopen($outputfile,"w");
214 224
 
215 225
 			fputs($fp, "From: ".$this->addr_from."\n");
@@ -221,8 +231,9 @@  discard block
 block discarded – undo
221 231
 			fputs($fp, "Message:\n".$this->message);
222 232
 
223 233
 			fclose($fp);
224
-			if (! empty($conf->global->MAIN_UMASK))
225
-			@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
234
+			if (! empty($conf->global->MAIN_UMASK)) {
235
+						@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
236
+			}
226 237
 		}
227 238
 	}
228 239
 
@@ -239,16 +250,19 @@  discard block
 block discarded – undo
239 250
         // phpcs:enable
240 251
         global $conf,$dolibarr_main_data_root;
241 252
 
242
-        if (@is_writeable($dolibarr_main_data_root))    // Avoid fatal error on fopen with open_basedir
253
+        if (@is_writeable($dolibarr_main_data_root)) {
254
+            // Avoid fatal error on fopen with open_basedir
243 255
         {
244 256
         	$outputfile=$dolibarr_main_data_root."/dolibarr_sms.log";
257
+        }
245 258
             $fp = fopen($outputfile,"a+");
246 259
 
247 260
             fputs($fp, "\nResult id=".$result);
248 261
 
249 262
             fclose($fp);
250
-            if (! empty($conf->global->MAIN_UMASK))
251
-            @chmod($outputfile, octdec($conf->global->MAIN_UMASK));
263
+            if (! empty($conf->global->MAIN_UMASK)) {
264
+                        @chmod($outputfile, octdec($conf->global->MAIN_UMASK));
265
+            }
252 266
         }
253 267
     }
254 268
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/class/fileupload.class.php 1 patch
Braces   +17 added lines, -29 removed lines patch added patch discarded remove patch
@@ -62,46 +62,36 @@  discard block
 block discarded – undo
62 62
 		if ($element == 'propal') {
63 63
 			$pathname = 'comm/propal';
64 64
 			$dir_output=$conf->$element->dir_output;
65
-		}
66
-		elseif ($element == 'facture') {
65
+		} elseif ($element == 'facture') {
67 66
 			$pathname = 'compta/facture';
68 67
 			$dir_output=$conf->$element->dir_output;
69
-		}
70
-		elseif ($element == 'project') {
68
+		} elseif ($element == 'project') {
71 69
 			$element = $pathname = 'projet';
72 70
 			$dir_output=$conf->$element->dir_output;
73
-		}
74
-		elseif ($element == 'project_task') {
71
+		} elseif ($element == 'project_task') {
75 72
 			$pathname = 'projet'; $filename='task';
76 73
 			$dir_output=$conf->projet->dir_output;
77 74
 			$parentForeignKey = 'fk_project';
78 75
 			$parentClass = 'Project';
79 76
 			$parentElement = 'projet';
80 77
 			$parentObject = 'project';
81
-		}
82
-		elseif ($element == 'fichinter') {
78
+		} elseif ($element == 'fichinter') {
83 79
 			$element='ficheinter';
84 80
 			$dir_output=$conf->$element->dir_output;
85
-		}
86
-		elseif ($element == 'order_supplier') {
81
+		} elseif ($element == 'order_supplier') {
87 82
 			$pathname = 'fourn'; $filename='fournisseur.commande';
88 83
 			$dir_output=$conf->fournisseur->commande->dir_output;
89
-		}
90
-		elseif ($element == 'invoice_supplier') {
84
+		} elseif ($element == 'invoice_supplier') {
91 85
 			$pathname = 'fourn'; $filename='fournisseur.facture';
92 86
 			$dir_output=$conf->fournisseur->facture->dir_output;
93
-		}
94
-		elseif ($element == 'product') {
87
+		} elseif ($element == 'product') {
95 88
 			$dir_output = $conf->product->multidir_output[$conf->entity];
96
-		}
97
-		elseif ($element == 'productbatch') {
89
+		} elseif ($element == 'productbatch') {
98 90
 			$dir_output = $conf->productbatch->multidir_output[$conf->entity];
99
-		}
100
-		elseif ($element == 'action') {
91
+		} elseif ($element == 'action') {
101 92
 			$pathname = 'comm/action'; $filename='actioncomm';
102 93
 			$dir_output=$conf->agenda->dir_output;
103
-		}
104
-		elseif ($element == 'chargesociales') {
94
+		} elseif ($element == 'chargesociales') {
105 95
 			$pathname = 'compta/sociales'; $filename='chargesociales';
106 96
 			$dir_output=$conf->tax->dir_output;
107 97
 		} else {
@@ -282,10 +272,11 @@  discard block
 block discarded – undo
282 272
 
283 273
 			$res=vignette($file_path,$maxwidthmini,$maxheightmini,'_mini');  // We don't use ->addThumbs here because there is no object and we don't need all thumbs, only the "mini".
284 274
 
285
-			if (preg_match('/error/i',$res)) return false;
275
+			if (preg_match('/error/i',$res)) {
276
+			    return false;
277
+			}
286 278
 			return true;
287
-		}
288
-		else
279
+		} else
289 280
 		{
290 281
 			return false;
291 282
 		}
@@ -437,8 +428,7 @@  discard block
 block discarded – undo
437 428
 				} else {
438 429
 					dol_move_uploaded_file($uploaded_file, $file_path, 1, 0, 0, 0, 'userfile');
439 430
 				}
440
-			}
441
-			else
431
+			} else
442 432
 			{
443 433
 				// Non-multipart uploads (PUT method support)
444 434
 				file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0);
@@ -455,8 +445,7 @@  discard block
 block discarded – undo
455 445
 						$file->{$version.'_url'} = $options['upload_url'].rawurlencode($tmp[0].'_mini.'.$tmp[1]);
456 446
 					}
457 447
 				}
458
-			}
459
-			else if ($this->options['discard_aborted_uploads'])
448
+			} else if ($this->options['discard_aborted_uploads'])
460 449
 			{
461 450
 				unlink($file_path);
462 451
 				$file->error = 'abort';
@@ -479,8 +468,7 @@  discard block
 block discarded – undo
479 468
 		if ($file_name)
480 469
 		{
481 470
 			$info = $this->getFileObject($file_name);
482
-		}
483
-		else
471
+		} else
484 472
 		{
485 473
 			$info = $this->getFileObjects();
486 474
 		}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/class/html.formprojet.class.php 1 patch
Braces   +123 added lines, -69 removed lines patch added patch discarded remove patch
@@ -97,8 +97,7 @@  discard block
 block discarded – undo
97 97
 			));
98 98
 
99 99
 			$out.='<input type="text" class="minwidth200'.($morecss?' '.$morecss:'').'" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' />';
100
-		}
101
-		else
100
+		} else
102 101
 		{
103 102
 			$out.=$this->select_projects_list($socid, $selected, $htmlname, $maxlength, $option_only, $show_empty, $discard_closed, $forcefocus, $disabled, 0, $filterkey, 1, $forceaddid, $htmlid, $morecss);
104 103
 		}
@@ -106,7 +105,9 @@  discard block
 block discarded – undo
106 105
 		{
107 106
 			if (class_exists('Form'))
108 107
 			{
109
-				if (empty($form)) $form=new Form($this->db);
108
+				if (empty($form)) {
109
+				    $form=new Form($this->db);
110
+				}
110 111
 				$out.=$form->textwithpicto('', $langs->trans("ClosedProjectsAreHidden"));
111 112
 			}
112 113
 		}
@@ -115,8 +116,9 @@  discard block
 block discarded – undo
115 116
 		{
116 117
 		    print $out;
117 118
 		    return '';
119
+		} else {
120
+		    return $out;
118 121
 		}
119
-		else return $out;
120 122
 	}
121 123
 
122 124
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -147,13 +149,17 @@  discard block
 block discarded – undo
147 149
 
148 150
 		require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
149 151
 
150
-		if (empty($htmlid)) $htmlid = $htmlname;
152
+		if (empty($htmlid)) {
153
+		    $htmlid = $htmlname;
154
+		}
151 155
 
152 156
 		$out='';
153 157
 		$outarray=array();
154 158
 
155 159
 		$hideunselectables = false;
156
-		if (! empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) $hideunselectables = true;
160
+		if (! empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) {
161
+		    $hideunselectables = true;
162
+		}
157 163
 
158 164
 		$projectsListId = false;
159 165
 		if (empty($user->rights->projet->all->lire))
@@ -166,17 +172,26 @@  discard block
 block discarded – undo
166 172
 		$sql = 'SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public, s.nom as name, s.name_alias';
167 173
 		$sql.= ' FROM '.MAIN_DB_PREFIX .'projet as p LEFT JOIN '.MAIN_DB_PREFIX .'societe as s ON s.rowid = p.fk_soc';
168 174
 		$sql.= " WHERE p.entity IN (".getEntity('project').")";
169
-		if ($projectsListId !== false) $sql.= " AND p.rowid IN (".$projectsListId.")";
170
-		if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
175
+		if ($projectsListId !== false) {
176
+		    $sql.= " AND p.rowid IN (".$projectsListId.")";
177
+		}
178
+		if ($socid == 0) {
179
+		    $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
180
+		}
171 181
 		if ($socid > 0)
172 182
 		{
173
-		    if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY))  $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)";
174
-		    else if ($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all')    // PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma.
183
+		    if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) {
184
+		        $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)";
185
+		    } else if ($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') {
186
+		        // PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma.
175 187
 		    {
176 188
 		        $sql.= " AND (p.fk_soc IN (".$socid.", ".$conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") OR p.fk_soc IS NULL)";
177 189
 		    }
190
+		    }
191
+		}
192
+		if (!empty($filterkey)) {
193
+		    $sql .= natural_search(array('p.title', 'p.ref'), $filterkey);
178 194
 		}
179
-		if (!empty($filterkey)) $sql .= natural_search(array('p.title', 'p.ref'), $filterkey);
180 195
 		$sql.= " ORDER BY p.ref ASC";
181 196
 
182 197
 		$resql=$this->db->query($sql);
@@ -208,12 +223,13 @@  discard block
 block discarded – undo
208 223
 					if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire)
209 224
 					{
210 225
 						// Do nothing
211
-					}
212
-					else
226
+					} else
213 227
 					{
214
-						if ($discard_closed == 1 && $obj->fk_statut == 2 && $obj->rowid != $selected) // We discard closed except if selected
228
+						if ($discard_closed == 1 && $obj->fk_statut == 2 && $obj->rowid != $selected) {
229
+						    // We discard closed except if selected
215 230
 						{
216 231
 							$i++;
232
+						}
217 233
 							continue;
218 234
 						}
219 235
 
@@ -224,7 +240,9 @@  discard block
 block discarded – undo
224 240
 						if ($obj->name)
225 241
 						{
226 242
 						    $labeltoshow.=' - '.$obj->name;
227
-						    if ($obj->name_alias) $labeltoshow.=' ('.$obj->name_alias.')';
243
+						    if ($obj->name_alias) {
244
+						        $labeltoshow.=' ('.$obj->name_alias.')';
245
+						    }
228 246
 						}
229 247
 
230 248
 						$disabled=0;
@@ -232,13 +250,13 @@  discard block
 block discarded – undo
232 250
 						{
233 251
 							$disabled=1;
234 252
 							$labeltoshow.=' - '.$langs->trans("Draft");
235
-						}
236
-						else if ($obj->fk_statut == 2)
253
+						} else if ($obj->fk_statut == 2)
237 254
 						{
238
-							if ($discard_closed == 2) $disabled=1;
255
+							if ($discard_closed == 2) {
256
+							    $disabled=1;
257
+							}
239 258
 							$labeltoshow.=' - '.$langs->trans("Closed");
240
-						}
241
-						else if ( empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY) &&  $socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid))
259
+						} else if ( empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY) &&  $socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid))
242 260
 						{
243 261
 							$disabled=1;
244 262
 							$labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany");
@@ -249,17 +267,17 @@  discard block
 block discarded – undo
249 267
 							$out.= '<option value="'.$obj->rowid.'" selected';
250 268
 							//if ($disabled) $out.=' disabled';						// with select2, field can't be preselected if disabled
251 269
 							$out.= '>'.$labeltoshow.'</option>';
252
-						}
253
-						else
270
+						} else
254 271
 						{
255 272
 							if ($hideunselectables && $disabled && ($selected != $obj->rowid))
256 273
 							{
257 274
 								$resultat='';
258
-							}
259
-							else
275
+							} else
260 276
 							{
261 277
 								$resultat='<option value="'.$obj->rowid.'"';
262
-								if ($disabled) $resultat.=' disabled';
278
+								if ($disabled) {
279
+								    $resultat.=' disabled';
280
+								}
263 281
 								//if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
264 282
 								//else $labeltoshow.=' ('.$langs->trans("Private").')';
265 283
 								$resultat.='>';
@@ -284,18 +302,20 @@  discard block
 block discarded – undo
284 302
 			$this->db->free($resql);
285 303
 
286 304
 			if (!$mode) {
287
-				if (empty($option_only)) $out.= '</select>';
305
+				if (empty($option_only)) {
306
+				    $out.= '</select>';
307
+				}
288 308
 				if (empty($nooutput))
289 309
 				{
290 310
 				    print $out;
291 311
 				    return '';
312
+				} else {
313
+				    return $out;
292 314
 				}
293
-				else return $out;
294 315
 			} else {
295 316
 				return $outarray;
296 317
 			}
297
-		}
298
-		else
318
+		} else
299 319
 		{
300 320
 			dol_print_error($this->db);
301 321
 			return -1;
@@ -334,7 +354,9 @@  discard block
 block discarded – undo
334 354
 		$out='';
335 355
 
336 356
 		$hideunselectables = false;
337
-		if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;
357
+		if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) {
358
+		    $hideunselectables = true;
359
+		}
338 360
 
339 361
 		if (empty($projectsListId))
340 362
 		{
@@ -353,9 +375,15 @@  discard block
 block discarded – undo
353 375
 		$sql.= ' '.MAIN_DB_PREFIX.'projet_task as t';
354 376
 		$sql.= " WHERE p.entity IN (".getEntity('project').")";
355 377
 		$sql.= " AND t.fk_projet = p.rowid";
356
-		if ($projectsListId) $sql.= " AND p.rowid IN (".$projectsListId.")";
357
-		if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
358
-		if ($socid > 0)  $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)";
378
+		if ($projectsListId) {
379
+		    $sql.= " AND p.rowid IN (".$projectsListId.")";
380
+		}
381
+		if ($socid == 0) {
382
+		    $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
383
+		}
384
+		if ($socid > 0) {
385
+		    $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)";
386
+		}
359 387
 		$sql.= " ORDER BY p.ref, t.ref ASC";
360 388
 
361 389
 		$resql=$this->db->query($sql);
@@ -375,8 +403,11 @@  discard block
 block discarded – undo
375 403
 			}
376 404
 			if (! empty($show_empty)) {
377 405
 				$out.= '<option value="0" class="optiongrey">';
378
-				if (! is_numeric($show_empty)) $out.=$show_empty;
379
-				else $out.='&nbsp;';
406
+				if (! is_numeric($show_empty)) {
407
+				    $out.=$show_empty;
408
+				} else {
409
+				    $out.='&nbsp;';
410
+				}
380 411
 				$out.= '</option>';
381 412
 			}
382 413
 			$num = $this->db->num_rows($resql);
@@ -390,8 +421,7 @@  discard block
 block discarded – undo
390 421
 					if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($usertofilter->rights->societe->lire))
391 422
 					{
392 423
 						// Do nothing
393
-					}
394
-					else
424
+					} else
395 425
 					{
396 426
 						if ($discard_closed == 1 && $obj->fk_statut == Project::STATUS_CLOSED)
397 427
 						{
@@ -408,20 +438,22 @@  discard block
 block discarded – undo
408 438
 							//else $labeltoshow.=' ('.$langs->trans("Private").')';
409 439
 							$labeltoshow.=' '.dol_trunc($obj->title,$maxlength);
410 440
 
411
-							if ($obj->name) $labeltoshow.=' ('.$obj->name.')';
441
+							if ($obj->name) {
442
+							    $labeltoshow.=' ('.$obj->name.')';
443
+							}
412 444
 
413 445
 							$disabled=0;
414 446
 							if ($obj->fk_statut == Project::STATUS_DRAFT)
415 447
 							{
416 448
 								$disabled=1;
417 449
 								$labeltoshow.=' - '.$langs->trans("Draft");
418
-							}
419
-							else if ($obj->fk_statut == Project::STATUS_CLOSED)
450
+							} else if ($obj->fk_statut == Project::STATUS_CLOSED)
420 451
 							{
421
-								if ($discard_closed == 2) $disabled=1;
452
+								if ($discard_closed == 2) {
453
+								    $disabled=1;
454
+								}
422 455
 								$labeltoshow.=' - '.$langs->trans("Closed");
423
-							}
424
-							else if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid))
456
+							} else if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid))
425 457
 							{
426 458
 								$disabled=1;
427 459
 								$labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany");
@@ -437,17 +469,17 @@  discard block
 block discarded – undo
437 469
 							$out.= '<option value="'.$obj->rowid.'" selected';
438 470
 							//if ($disabled) $out.=' disabled';						// with select2, field can't be preselected if disabled
439 471
 							$out.= '>'.$labeltoshow.'</option>';
440
-						}
441
-						else
472
+						} else
442 473
 						{
443 474
 							if ($hideunselectables && $disabled && ($selected != $obj->rowid))
444 475
 							{
445 476
 								$resultat='';
446
-							}
447
-							else
477
+							} else
448 478
 							{
449 479
 								$resultat='<option value="'.$obj->rowid.'"';
450
-								if ($disabled) $resultat.=' disabled';
480
+								if ($disabled) {
481
+								    $resultat.=' disabled';
482
+								}
451 483
 								//if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
452 484
 								//else $labeltoshow.=' ('.$langs->trans("Private").')';
453 485
 								$resultat.='>';
@@ -468,8 +500,7 @@  discard block
 block discarded – undo
468 500
 
469 501
 			$this->db->free($resql);
470 502
 			return $num;
471
-		}
472
-		else
503
+		} else
473 504
 		{
474 505
 			dol_print_error($this->db);
475 506
 			return -1;
@@ -493,10 +524,15 @@  discard block
 block discarded – undo
493 524
         // phpcs:enable
494 525
 		global $conf, $langs;
495 526
 
496
-		if ($table_element == 'projet_task') return '';		// Special cas of element we never link to a project (already always done)
527
+		if ($table_element == 'projet_task') {
528
+		    return '';
529
+		}
530
+		// Special cas of element we never link to a project (already always done)
497 531
 
498 532
 		$linkedtothirdparty=false;
499
-		if (! in_array($table_element, array('don','expensereport_det','expensereport','loan','stock_mouvement','payment_salary','payment_various','chargesociales'))) $linkedtothirdparty=true;
533
+		if (! in_array($table_element, array('don','expensereport_det','expensereport','loan','stock_mouvement','payment_salary','payment_various','chargesociales'))) {
534
+		    $linkedtothirdparty=true;
535
+		}
500 536
 
501 537
 		$sqlfilter='';
502 538
 
@@ -550,18 +586,31 @@  discard block
 block discarded – undo
550 586
 				$sql = "SELECT t.rowid, t.ref";
551 587
 				break;
552 588
 		}
553
-		if ($linkedtothirdparty) $sql.=", s.nom as name";
589
+		if ($linkedtothirdparty) {
590
+		    $sql.=", s.nom as name";
591
+		}
554 592
 		$sql.= " FROM ".MAIN_DB_PREFIX.$table_element." as t";
555
-		if ($linkedtothirdparty) $sql.=", ".MAIN_DB_PREFIX."societe as s";
593
+		if ($linkedtothirdparty) {
594
+		    $sql.=", ".MAIN_DB_PREFIX."societe as s";
595
+		}
556 596
 		$sql.= " WHERE ".$projectkey." is null";
557 597
 		if (! empty($socid) && $linkedtothirdparty)
558 598
 		{
559
-		    if (is_numeric($socid)) $sql.= " AND t.fk_soc=".$socid;
560
-		    else $sql.= " AND t.fk_soc IN (".$socid.")";
599
+		    if (is_numeric($socid)) {
600
+		        $sql.= " AND t.fk_soc=".$socid;
601
+		    } else {
602
+		        $sql.= " AND t.fk_soc IN (".$socid.")";
603
+		    }
604
+		}
605
+		if (! in_array($table_element, array('expensereport_det','stock_mouvement'))) {
606
+		    $sql.= ' AND t.entity IN ('.getEntity('project').')';
607
+		}
608
+		if ($linkedtothirdparty) {
609
+		    $sql.=" AND s.rowid = t.fk_soc";
610
+		}
611
+		if ($sqlfilter) {
612
+		    $sql.= " AND ".$sqlfilter;
561 613
 		}
562
-		if (! in_array($table_element, array('expensereport_det','stock_mouvement'))) $sql.= ' AND t.entity IN ('.getEntity('project').')';
563
-		if ($linkedtothirdparty) $sql.=" AND s.rowid = t.fk_soc";
564
-		if ($sqlfilter) $sql.= " AND ".$sqlfilter;
565 614
 		$sql.= " ORDER BY ref DESC";
566 615
 
567 616
 		dol_syslog(get_class($this).'::select_element', LOG_DEBUG);
@@ -578,8 +627,12 @@  discard block
 block discarded – undo
578 627
 				{
579 628
 					$obj = $this->db->fetch_object($resql);
580 629
 					$ref=$obj->ref?$obj->ref:$obj->rowid;
581
-					if (! empty($obj->ref_supplier)) $ref.=' ('.$obj->ref_supplier.')';
582
-					if (! empty($obj->name)) $ref.=' - '.$obj->name;
630
+					if (! empty($obj->ref_supplier)) {
631
+					    $ref.=' ('.$obj->ref_supplier.')';
632
+					}
633
+					if (! empty($obj->name)) {
634
+					    $ref.=' - '.$obj->name;
635
+					}
583 636
 					$sellist .='<option value="'.$obj->rowid.'">'.$ref.'</option>';
584 637
 					$i++;
585 638
 				}
@@ -594,8 +647,7 @@  discard block
 block discarded – undo
594 647
 			$this->db->free($resql);
595 648
 
596 649
 			return $sellist;
597
-		}
598
-		else
650
+		} else
599 651
 		{
600 652
 			dol_print_error($this->db);
601 653
 			$this->error=$this->db->lasterror();
@@ -650,16 +702,19 @@  discard block
 block discarded – undo
650 702
 					$obj = $this->db->fetch_object($resql);
651 703
 
652 704
 					$sellist .='<option value="'.$obj->rowid.'" defaultpercent="'.$obj->percent.'" elemcode="'.$obj->code.'"';
653
-					if ($obj->rowid == $preselected) $sellist .= ' selected="selected"';
705
+					if ($obj->rowid == $preselected) {
706
+					    $sellist .= ' selected="selected"';
707
+					}
654 708
 					$sellist .= '>';
655 709
 					if ($useshortlabel)
656 710
 					{
657 711
 						$finallabel = ($langs->transnoentitiesnoconv("OppStatus".$obj->code) != "OppStatus".$obj->code ? $langs->transnoentitiesnoconv("OppStatus".$obj->code) : $obj->label);
658
-					}
659
-					else
712
+					} else
660 713
 					{
661 714
 						$finallabel = ($langs->transnoentitiesnoconv("OppStatus".$obj->code) != "OppStatus".$obj->code ? $langs->transnoentitiesnoconv("OppStatus".$obj->code) : $obj->label);
662
-						if ($showpercent) $finallabel.= ' ('.$obj->percent.'%)';
715
+						if ($showpercent) {
716
+						    $finallabel.= ' ('.$obj->percent.'%)';
717
+						}
663 718
 					}
664 719
 					$sellist .= $finallabel;
665 720
 					$sellist .='</option>';
@@ -676,8 +731,7 @@  discard block
 block discarded – undo
676 731
 			$this->db->free($resql);
677 732
 
678 733
 			return $sellist;
679
-		}
680
-		else
734
+		} else
681 735
 		{
682 736
 			$this->error=$this->db->lasterror();
683 737
 			$this->errors[]=$this->db->lasterror();
Please login to merge, or discard this patch.
dolibarr/htdocs/core/class/html.formother.class.php 1 patch
Braces   +145 added lines, -83 removed lines patch added patch discarded remove patch
@@ -73,7 +73,9 @@  discard block
 block discarded – undo
73 73
         $sql = "SELECT rowid, label";
74 74
         $sql.= " FROM ".MAIN_DB_PREFIX."export_model";
75 75
         $sql.= " WHERE type = '".$type."'";
76
-		if (!empty($fk_user)) $sql.=" AND fk_user=".$fk_user;
76
+		if (!empty($fk_user)) {
77
+		    $sql.=" AND fk_user=".$fk_user;
78
+		}
77 79
         $sql.= " ORDER BY rowid";
78 80
         $result = $this->db->query($sql);
79 81
         if ($result)
@@ -92,8 +94,7 @@  discard block
 block discarded – undo
92 94
                 if ($selected == $obj->rowid)
93 95
                 {
94 96
                     print '<option value="'.$obj->rowid.'" selected>';
95
-                }
96
-                else
97
+                } else
97 98
                 {
98 99
                     print '<option value="'.$obj->rowid.'">';
99 100
                 }
@@ -102,8 +103,7 @@  discard block
 block discarded – undo
102 103
                 $i++;
103 104
             }
104 105
             print "</select>";
105
-        }
106
-        else {
106
+        } else {
107 107
             dol_print_error($this->db);
108 108
         }
109 109
     }
@@ -143,8 +143,7 @@  discard block
 block discarded – undo
143 143
                 if ($selected == $obj->rowid)
144 144
                 {
145 145
                     print '<option value="'.$obj->rowid.'" selected>';
146
-                }
147
-                else
146
+                } else
148 147
                 {
149 148
                     print '<option value="'.$obj->rowid.'">';
150 149
                 }
@@ -153,8 +152,7 @@  discard block
 block discarded – undo
153 152
                 $i++;
154 153
             }
155 154
             print "</select>";
156
-        }
157
-        else {
155
+        } else {
158 156
             dol_print_error($this->db);
159 157
         }
160 158
     }
@@ -195,8 +193,7 @@  discard block
 block discarded – undo
195 193
                     if ($selected && $selected == $obj->rowid)
196 194
                     {
197 195
                         print '<option value="'.$obj->rowid.'" selected>';
198
-                    }
199
-                    else
196
+                    } else
200 197
                     {
201 198
                         print '<option value="'.$obj->rowid.'">';
202 199
                         //print '<option onmouseover="showtip(\''.$obj->label.'\')" onMouseout="hidetip()" value="'.$obj->rowid.'">';
@@ -209,8 +206,7 @@  discard block
 block discarded – undo
209 206
             }
210 207
             print '</select>';
211 208
             return 0;
212
-        }
213
-        else
209
+        } else
214 210
         {
215 211
             dol_print_error($this->db);
216 212
             return 1;
@@ -255,8 +251,7 @@  discard block
 block discarded – undo
255 251
     				if (($selected && $selected == $obj->taux) || $num == 1)
256 252
     				{
257 253
     					$out.='<option value="'.$obj->taux.($obj->revenuestamp_type == 'percent' ? '%' : '').'"'.($obj->revenuestamp_type == 'percent' ? ' data-type="percent"' : '').' selected>';
258
-    				}
259
-    				else
254
+    				} else
260 255
     				{
261 256
     					$out.='<option value="'.$obj->taux.($obj->revenuestamp_type == 'percent' ? '%' : '').'"'.($obj->revenuestamp_type == 'percent' ? ' data-type="percent"' : '').'>';
262 257
     					//print '<option onmouseover="showtip(\''.$obj->libelle.'\')" onMouseout="hidetip()" value="'.$obj->rowid.'">';
@@ -268,8 +263,7 @@  discard block
 block discarded – undo
268 263
     		}
269 264
     		$out.='</select>';
270 265
     		return $out;
271
-    	}
272
-    	else
266
+    	} else
273 267
     	{
274 268
     		dol_print_error($this->db);
275 269
     		return '';
@@ -294,15 +288,16 @@  discard block
 block discarded – undo
294 288
     {
295 289
         // phpcs:enable
296 290
         $return = '<select class="flat" name="'.$htmlname.'" '.($disabled?'disabled':'').'>';
297
-        if ($showempty) $return.='<option value="-1"'.(($selected == -1 || $selected == '')?' selected':'').'>&nbsp;</option>';
291
+        if ($showempty) {
292
+            $return.='<option value="-1"'.(($selected == -1 || $selected == '')?' selected':'').'>&nbsp;</option>';
293
+        }
298 294
 
299 295
         for ($i = $start ; $i <= $end ; $i += $increment)
300 296
         {
301 297
             if ($selected != '' && (int) $selected == $i)
302 298
             {
303 299
                 $return.= '<option value="'.$i.'" selected>';
304
-            }
305
-            else
300
+            } else
306 301
             {
307 302
                 $return.= '<option value="'.$i.'">';
308 303
             }
@@ -355,14 +350,19 @@  discard block
 block discarded – undo
355 350
 
356 351
         // Print a select with each of them
357 352
         $moreforfilter.='<select class="flat minwidth100'.($morecss?' '.$morecss:'').'" id="select_categ_'.$htmlname.'" name="'.$htmlname.'">';
358
-        if ($showempty) $moreforfilter.='<option value="0">&nbsp;</option>';	// Should use -1 to say nothing
353
+        if ($showempty) {
354
+            $moreforfilter.='<option value="0">&nbsp;</option>';
355
+        }
356
+        // Should use -1 to say nothing
359 357
 
360 358
         if (is_array($tab_categs))
361 359
         {
362 360
             foreach ($tab_categs as $categ)
363 361
             {
364 362
                 $moreforfilter.='<option value="'.$categ['id'].'"';
365
-                if ($categ['id'] == $selected) $moreforfilter.=' selected';
363
+                if ($categ['id'] == $selected) {
364
+                    $moreforfilter.=' selected';
365
+                }
366 366
                 $moreforfilter.='>'.dol_trunc($categ['fulllabel'],50,'middle').'</option>';
367 367
             }
368 368
         }
@@ -409,14 +409,20 @@  discard block
 block discarded – undo
409 409
         }
410 410
         // Select each sales and print them in a select input
411 411
         $out.='<select class="flat'.($morecss?' '.$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.'">';
412
-        if ($showempty) $out.='<option value="0">&nbsp;</option>';
412
+        if ($showempty) {
413
+            $out.='<option value="0">&nbsp;</option>';
414
+        }
413 415
 
414 416
         // Get list of users allowed to be viewed
415 417
         $sql_usr = "SELECT u.rowid, u.lastname, u.firstname, u.statut, u.login";
416 418
         $sql_usr.= " FROM ".MAIN_DB_PREFIX."user as u";
417 419
         $sql_usr.= " WHERE u.entity IN (0,".$conf->entity.")";
418
-        if (empty($user->rights->user->user->lire)) $sql_usr.=" AND u.rowid = ".$user->id;
419
-        if (! empty($user->societe_id)) $sql_usr.=" AND u.fk_soc = ".$user->societe_id;
420
+        if (empty($user->rights->user->user->lire)) {
421
+            $sql_usr.=" AND u.rowid = ".$user->id;
422
+        }
423
+        if (! empty($user->societe_id)) {
424
+            $sql_usr.=" AND u.fk_soc = ".$user->societe_id;
425
+        }
420 426
         // Add existing sales representatives of thirdparty of external user
421 427
         if (empty($user->rights->user->user->lire) && $user->societe_id)
422 428
         {
@@ -437,7 +443,9 @@  discard block
 block discarded – undo
437 443
 
438 444
                 $out.='<option value="'.$obj_usr->rowid.'"';
439 445
 
440
-                if ($obj_usr->rowid == $selected) $out.=' selected';
446
+                if ($obj_usr->rowid == $selected) {
447
+                    $out.=' selected';
448
+                }
441 449
 
442 450
                 $out.='>';
443 451
                 $out.=dolGetFirstLastname($obj_usr->firstname,$obj_usr->lastname);
@@ -465,8 +473,7 @@  discard block
 block discarded – undo
465 473
                 $out.='</option>';
466 474
             }
467 475
             $this->db->free($resql_usr);
468
-        }
469
-        else
476
+        } else
470 477
         {
471 478
             dol_print_error($this->db);
472 479
         }
@@ -502,15 +509,16 @@  discard block
 block discarded – undo
502 509
         if ($tasksarray)
503 510
         {
504 511
         	print '<select class="flat'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">';
505
-            if ($useempty) print '<option value="0">&nbsp;</option>';
512
+            if ($useempty) {
513
+                print '<option value="0">&nbsp;</option>';
514
+            }
506 515
             $j=0;
507 516
             $level=0;
508 517
             $this->_pLineSelect($j, 0, $tasksarray, $level, $selectedtask, $projectid, $disablechildoftaskid);
509 518
             print '</select>';
510 519
 
511 520
             print ajax_combobox($htmlname);
512
-        }
513
-        else
521
+        } else
514 522
         {
515 523
             print '<div class="warning">'.$langs->trans("NoProject").'</div>';
516 524
         }
@@ -544,20 +552,23 @@  discard block
 block discarded – undo
544 552
 				//var_dump($selectedproject."--".$selectedtask."--".$lines[$i]->fk_project."_".$lines[$i]->id);		// $lines[$i]->id may be empty if project has no lines
545 553
 
546 554
                 // Break on a new project
547
-                if ($parent == 0)	// We are on a task at first level
555
+                if ($parent == 0) {
556
+                    // We are on a task at first level
548 557
                 {
549 558
                     if ($lines[$i]->fk_project != $lastprojectid)	// Break found on project
550 559
                     {
551 560
                         if ($i > 0) print '<option value="0" disabled>----------</option>';
561
+                }
552 562
                         print '<option value="'.$lines[$i]->fk_project.'_0"';
553
-                        if ($selectedproject == $lines[$i]->fk_project) print ' selected';
563
+                        if ($selectedproject == $lines[$i]->fk_project) {
564
+                            print ' selected';
565
+                        }
554 566
                         print '>';	// Project -> Task
555 567
                         print $langs->trans("Project").' '.$lines[$i]->projectref;
556 568
                         if (empty($lines[$i]->public))
557 569
                         {
558 570
                             print ' ('.$langs->trans("Visibility").': '.$langs->trans("PrivateProject").')';
559
-                        }
560
-                        else
571
+                        } else
561 572
                         {
562 573
                             print ' ('.$langs->trans("Visibility").': '.$langs->trans("SharedProject").')';
563 574
                         }
@@ -572,31 +583,41 @@  discard block
 block discarded – undo
572 583
                 $newdisablechildoftaskid=$disablechildoftaskid;
573 584
 
574 585
                 // Print task
575
-                if (isset($lines[$i]->id))		// We use isset because $lines[$i]->id may be null if project has no task and are on root project (tasks may be caught by a left join). We enter here only if '0' or >0
586
+                if (isset($lines[$i]->id)) {
587
+                    // We use isset because $lines[$i]->id may be null if project has no task and are on root project (tasks may be caught by a left join). We enter here only if '0' or >0
576 588
                 {
577 589
                 	// Check if we must disable entry
578 590
                 	$disabled=0;
591
+                }
579 592
                 	if ($disablechildoftaskid && (($lines[$i]->id == $disablechildoftaskid || $lines[$i]->fk_parent == $disablechildoftaskid)))
580 593
                 	{
581 594
                			$disabled++;
582
-               			if ($lines[$i]->fk_parent == $disablechildoftaskid) $newdisablechildoftaskid=$lines[$i]->id;	// If task is child of a disabled parent, we will propagate id to disable next child too
595
+               			if ($lines[$i]->fk_parent == $disablechildoftaskid) {
596
+               			    $newdisablechildoftaskid=$lines[$i]->id;
597
+               			}
598
+               			// If task is child of a disabled parent, we will propagate id to disable next child too
583 599
                 	}
584 600
 
585 601
                     print '<option value="'.$lines[$i]->fk_project.'_'.$lines[$i]->id.'"';
586
-                    if (($lines[$i]->id == $selectedtask) || ($lines[$i]->fk_project.'_'.$lines[$i]->id == $selectedtask)) print ' selected';
587
-                    if ($disabled) print ' disabled';
602
+                    if (($lines[$i]->id == $selectedtask) || ($lines[$i]->fk_project.'_'.$lines[$i]->id == $selectedtask)) {
603
+                        print ' selected';
604
+                    }
605
+                    if ($disabled) {
606
+                        print ' disabled';
607
+                    }
588 608
                     print '>';
589 609
                     print $langs->trans("Project").' '.$lines[$i]->projectref;
590 610
                     print ' '.$lines[$i]->projectlabel;
591 611
                     if (empty($lines[$i]->public))
592 612
                     {
593 613
                         print ' ('.$langs->trans("Visibility").': '.$langs->trans("PrivateProject").')';
594
-                    }
595
-                    else
614
+                    } else
596 615
                     {
597 616
                         print ' ('.$langs->trans("Visibility").': '.$langs->trans("SharedProject").')';
598 617
                     }
599
-                    if ($lines[$i]->id) print ' > ';
618
+                    if ($lines[$i]->id) {
619
+                        print ' > ';
620
+                    }
600 621
                     for ($k = 0 ; $k < $level ; $k++)
601 622
                     {
602 623
                         print "&nbsp;&nbsp;&nbsp;";
@@ -606,7 +627,9 @@  discard block
 block discarded – undo
606 627
                 }
607 628
 
608 629
                 $level++;
609
-                if ($lines[$i]->id) $this->_pLineSelect($inc, $lines[$i]->id, $lines, $level, $selectedtask, $selectedproject, $newdisablechildoftaskid);
630
+                if ($lines[$i]->id) {
631
+                    $this->_pLineSelect($inc, $lines[$i]->id, $lines, $level, $selectedtask, $selectedproject, $newdisablechildoftaskid);
632
+                }
610 633
                 $level--;
611 634
             }
612 635
         }
@@ -625,12 +648,17 @@  discard block
 block discarded – undo
625 648
     {
626 649
     	$textcolor='FFF';
627 650
     	include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
628
-    	if(colorIsLight($color)) $textcolor='000';
651
+    	if(colorIsLight($color)) {
652
+    	    $textcolor='000';
653
+    	}
629 654
 
630 655
     	$color = colorArrayToHex(colorStringToArray($color,array()),'');
631 656
 
632
-		if ($color) print '<input type="text" class="colorthumb" disabled style="padding: 1px; margin-top: 0; margin-bottom: 0; color: #'.$textcolor.'; background-color: #'.$color.'" value="'.$color.'">';
633
-		else print $textifnotdefined;
657
+		if ($color) {
658
+		    print '<input type="text" class="colorthumb" disabled style="padding: 1px; margin-top: 0; margin-bottom: 0; color: #'.$textcolor.'; background-color: #'.$color.'" value="'.$color.'">';
659
+		} else {
660
+		    print $textifnotdefined;
661
+		}
634 662
     }
635 663
 
636 664
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -721,8 +749,7 @@  discard block
 block discarded – undo
721 749
 	             </script>';
722 750
             }
723 751
             $out.= '<input id="colorpicker'.$prefix.'" name="'.$prefix.'" size="6" maxlength="7" class="flat'.($morecss?' '.$morecss:'').'" type="text" value="'.$set_color.'" />';
724
-        }
725
-        else  // In most cases, this is not used. We used instead function with no specific list of colors
752
+        } else  // In most cases, this is not used. We used instead function with no specific list of colors
726 753
         {
727 754
             if (empty($conf->dol_use_jmobile))
728 755
             {
@@ -743,7 +770,9 @@  discard block
 block discarded – undo
743 770
             foreach ($arrayofcolors as $val)
744 771
             {
745 772
                 $out.= '<option value="'.$val.'"';
746
-                if ($set_color == $val) $out.= ' selected';
773
+                if ($set_color == $val) {
774
+                    $out.= ' selected';
775
+                }
747 776
                 $out.= '>'.$val.'</option>';
748 777
             }
749 778
             $out.= '</select>';
@@ -827,8 +856,7 @@  discard block
 block discarded – undo
827 856
             if ($selected == $key)
828 857
             {
829 858
                 $select_week .= '<option value="'.$key.'" selected>';
830
-            }
831
-            else
859
+            } else
832 860
             {
833 861
                 $select_week .= '<option value="'.$key.'">';
834 862
             }
@@ -857,8 +885,13 @@  discard block
 block discarded – undo
857 885
 
858 886
         require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
859 887
 
860
-        if ($longlabel) $montharray = monthArray($langs, 0);	// Get array
861
-        else $montharray = monthArray($langs, 1);
888
+        if ($longlabel) {
889
+            $montharray = monthArray($langs, 0);
890
+        }
891
+        // Get array
892
+        else {
893
+            $montharray = monthArray($langs, 1);
894
+        }
862 895
 
863 896
         $select_month = '<select class="flat'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">';
864 897
         if ($useempty)
@@ -870,8 +903,7 @@  discard block
 block discarded – undo
870 903
             if ($selected == $key)
871 904
             {
872 905
                 $select_month .= '<option value="'.$key.'" selected>';
873
-            }
874
-            else
906
+            } else
875 907
             {
876 908
                 $select_month .= '<option value="'.$key.'">';
877 909
             }
@@ -924,13 +956,17 @@  discard block
 block discarded – undo
924 956
         $currentyear = date("Y")+$offset;
925 957
         $max_year = $currentyear+$max_year;
926 958
         $min_year = $currentyear-$min_year;
927
-        if(empty($selected) && empty($useempty)) $selected = $currentyear;
959
+        if(empty($selected) && empty($useempty)) {
960
+            $selected = $currentyear;
961
+        }
928 962
 
929 963
         $out.= '<select class="flat'.($morecss?' '.$morecss:'').'" id="' . $htmlname . '" name="' . $htmlname . '"'.$option.' >';
930 964
         if($useempty)
931 965
         {
932 966
         	$selected_html='';
933
-            if ($selected == '') $selected_html = ' selected';
967
+            if ($selected == '') {
968
+                $selected_html = ' selected';
969
+            }
934 970
             $out.= '<option value=""' . $selected_html . '>&nbsp;</option>';
935 971
         }
936 972
         if (! $invert)
@@ -938,16 +974,19 @@  discard block
 block discarded – undo
938 974
             for ($y = $max_year; $y >= $min_year; $y--)
939 975
             {
940 976
                 $selected_html='';
941
-                if ($selected > 0 && $y == $selected) $selected_html = ' selected';
977
+                if ($selected > 0 && $y == $selected) {
978
+                    $selected_html = ' selected';
979
+                }
942 980
                 $out.= '<option value="'.$y.'"'.$selected_html.' >'.$y.'</option>';
943 981
             }
944
-        }
945
-        else
982
+        } else
946 983
         {
947 984
             for ($y = $min_year; $y <= $max_year; $y++)
948 985
             {
949 986
                 $selected_html='';
950
-                if ($selected > 0 && $y == $selected) $selected_html = ' selected';
987
+                if ($selected > 0 && $y == $selected) {
988
+                    $selected_html = ' selected';
989
+                }
951 990
                 $out.= '<option value="'.$y.'"'.$selected_html.' >'.$y.'</option>';
952 991
             }
953 992
         }
@@ -984,8 +1023,7 @@  discard block
 block discarded – undo
984 1023
             $langs->load("companies");
985 1024
             print ' &nbsp; <a href='.DOL_URL_ROOT.'/comm/address.php?socid='.$socid.'&action=create&origin='.$origin.'&originid='.$originid.'>'.$langs->trans("AddAddress").'</a>';
986 1025
             print '</form>';
987
-        }
988
-        else
1026
+        } else
989 1027
         {
990 1028
             if ($selected)
991 1029
             {
@@ -993,8 +1031,7 @@  discard block
 block discarded – undo
993 1031
                 $address=new Address($this->db);
994 1032
                 $result=$address->fetch_address($selected);
995 1033
                 print '<a href='.DOL_URL_ROOT.'/comm/address.php?socid='.$address->socid.'&id='.$address->id.'&action=edit&origin='.$origin.'&originid='.$originid.'>'.$address->label.'</a>';
996
-            }
997
-            else
1034
+            } else
998 1035
             {
999 1036
                 print "&nbsp;";
1000 1037
             }
@@ -1028,7 +1065,10 @@  discard block
 block discarded – undo
1028 1065
         $boxidactivatedforuser=array();
1029 1066
         foreach($boxactivated as $box)
1030 1067
         {
1031
-        	if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) $boxidactivatedforuser[$box->id]=$box->id;	// We keep only boxes to show for user
1068
+        	if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) {
1069
+        	    $boxidactivatedforuser[$box->id]=$box->id;
1070
+        	}
1071
+        	// We keep only boxes to show for user
1032 1072
         }
1033 1073
 
1034 1074
         // Define selectboxlist
@@ -1039,7 +1079,10 @@  discard block
 block discarded – undo
1039 1079
         	$langs->load("boxes");	// Load label of boxes
1040 1080
         	foreach($boxactivated as $box)
1041 1081
         	{
1042
-        		if (! empty($boxidactivatedforuser[$box->id])) continue;	// Already visible for user
1082
+        		if (! empty($boxidactivatedforuser[$box->id])) {
1083
+        		    continue;
1084
+        		}
1085
+        		// Already visible for user
1043 1086
         		$label=$langs->transnoentitiesnoconv($box->boxlabel);
1044 1087
         		//if (preg_match('/graph/',$box->class)) $label.=' ('.$langs->trans("Graph").')';
1045 1088
         		if (preg_match('/graph/',$box->class) && $conf->browser->layout != 'phone')
@@ -1050,7 +1093,9 @@  discard block
 block discarded – undo
1050 1093
         	}
1051 1094
             foreach($boxidactivatedforuser as $boxid)
1052 1095
         	{
1053
-       			if (empty($boxorder)) $boxorder.='A:';
1096
+       			if (empty($boxorder)) {
1097
+       			    $boxorder.='A:';
1098
+       			}
1054 1099
   				$boxorder.=$boxid.',';
1055 1100
         	}
1056 1101
 
@@ -1064,7 +1109,9 @@  discard block
 block discarded – undo
1064 1109
 			$selectboxlist.='<input type="hidden" name="areacode" value="'.$areacode.'">';
1065 1110
 			$selectboxlist.='<input type="hidden" name="boxorder" value="'.$boxorder.'">';
1066 1111
 			$selectboxlist.=Form::selectarray('boxcombo', $arrayboxtoactivatelabel, -1, $langs->trans("ChooseBoxToAdd").'...', 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth150onsmartphone', 0, 'hidden selected', 0, 1);
1067
-            if (empty($conf->use_javascript_ajax)) $selectboxlist.=' <input type="submit" class="button" value="'.$langs->trans("AddBox").'">';
1112
+            if (empty($conf->use_javascript_ajax)) {
1113
+                $selectboxlist.=' <input type="submit" class="button" value="'.$langs->trans("AddBox").'">';
1114
+            }
1068 1115
             $selectboxlist.='</form>';
1069 1116
             if (! empty($conf->use_javascript_ajax))
1070 1117
             {
@@ -1115,7 +1162,9 @@  discard block
 block discarded – undo
1115 1162
 	        			window.location.search=\'mainmenu='.GETPOST("mainmenu","aZ09").'&leftmenu='.GETPOST('leftmenu',"aZ09").'&action=addbox&boxid=\'+boxid;
1116 1163
 	                }
1117 1164
 	        	});';
1118
-	        	if (! count($arrayboxtoactivatelabel)) $selectboxlist.='jQuery("#boxcombo").hide();';
1165
+	        	if (! count($arrayboxtoactivatelabel)) {
1166
+	        	    $selectboxlist.='jQuery("#boxcombo").hide();';
1167
+	        	}
1119 1168
 	        	$selectboxlist.='
1120 1169
 
1121 1170
 	        	jQuery("#boxhalfleft, #boxhalfright").sortable({
@@ -1158,16 +1207,25 @@  discard block
 block discarded – undo
1158 1207
 
1159 1208
             // Define $box_max_lines
1160 1209
             $box_max_lines=5;
1161
-            if (! empty($conf->global->MAIN_BOXES_MAXLINES)) $box_max_lines=$conf->global->MAIN_BOXES_MAXLINES;
1210
+            if (! empty($conf->global->MAIN_BOXES_MAXLINES)) {
1211
+                $box_max_lines=$conf->global->MAIN_BOXES_MAXLINES;
1212
+            }
1162 1213
 
1163 1214
             $ii=0;
1164 1215
             foreach ($boxactivated as $key => $box)
1165 1216
             {
1166
-            	if ((! empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) continue;
1167
-				if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) $box->box_order='A'.sprintf("%02d",($ii+1));	// When box_order was not yet set to Axx or Bxx and is still 0
1168
-            	if (preg_match('/^A/i',$box->box_order)) // column A
1217
+            	if ((! empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) {
1218
+            	    continue;
1219
+            	}
1220
+				if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) {
1221
+				    $box->box_order='A'.sprintf("%02d",($ii+1));
1222
+				}
1223
+				// When box_order was not yet set to Axx or Bxx and is still 0
1224
+            	if (preg_match('/^A/i',$box->box_order)) {
1225
+            	    // column A
1169 1226
                 {
1170 1227
                     $ii++;
1228
+            	}
1171 1229
                     //print 'box_id '.$boxactivated[$ii]->box_id.' ';
1172 1230
                     //print 'box_order '.$boxactivated[$ii]->box_order.'<br>';
1173 1231
                     // Show box
@@ -1190,11 +1248,18 @@  discard block
 block discarded – undo
1190 1248
             $ii=0;
1191 1249
             foreach ($boxactivated as $key => $box)
1192 1250
             {
1193
-            	if ((! empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) continue;
1194
-            	if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) $box->box_order='B'.sprintf("%02d",($ii+1));	// When box_order was not yet set to Axx or Bxx and is still 0
1195
-            	if (preg_match('/^B/i',$box->box_order)) // colonne B
1251
+            	if ((! empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) {
1252
+            	    continue;
1253
+            	}
1254
+            	if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) {
1255
+            	    $box->box_order='B'.sprintf("%02d",($ii+1));
1256
+            	}
1257
+            	// When box_order was not yet set to Axx or Bxx and is still 0
1258
+            	if (preg_match('/^B/i',$box->box_order)) {
1259
+            	    // colonne B
1196 1260
                 {
1197 1261
                     $ii++;
1262
+            	}
1198 1263
                     //print 'box_id '.$boxactivated[$ii]->box_id.' ';
1199 1264
                     //print 'box_order '.$boxactivated[$ii]->box_order.'<br>';
1200 1265
                     // Show box
@@ -1262,8 +1327,7 @@  discard block
 block discarded – undo
1262 1327
                     if ($selected == $obj->rowid || $selected == $obj->$keyfield)
1263 1328
                     {
1264 1329
                         print '<option value="'.$obj->$keyfield.'" selected>';
1265
-                    }
1266
-                    else
1330
+                    } else
1267 1331
                     {
1268 1332
                         print '<option value="'.$obj->$keyfield.'">';
1269 1333
                     }
@@ -1272,13 +1336,11 @@  discard block
 block discarded – undo
1272 1336
                     $i++;
1273 1337
                 }
1274 1338
                 print "</select>";
1275
-            }
1276
-            else
1339
+            } else
1277 1340
 			{
1278 1341
                 print $langs->trans("DictionaryEmpty");
1279 1342
             }
1280
-        }
1281
-        else {
1343
+        } else {
1282 1344
             dol_print_error($this->db);
1283 1345
         }
1284 1346
     }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/class/notify.class.php 1 patch
Braces   +146 added lines, -66 removed lines patch added patch discarded remove patch
@@ -113,24 +113,42 @@  discard block
 block discarded – undo
113 113
 		$listofnotiftodo=$this->getNotificationsArray($action,$socid,$object,0);
114 114
 
115 115
 		$nb=-1;
116
-		if (is_array($listofnotiftodo)) $nb=count($listofnotiftodo);
117
-		if ($nb < 0)  $texte=img_object($langs->trans("Notifications"),'email').' '.$langs->trans("ErrorFailedToGetListOfNotificationsToSend");
118
-		if ($nb == 0) $texte=img_object($langs->trans("Notifications"),'email').' '.$langs->trans("NoNotificationsWillBeSent");
119
-   		if ($nb == 1) $texte=img_object($langs->trans("Notifications"),'email').' '.$langs->trans("ANotificationsWillBeSent");
120
-   		if ($nb >= 2) $texte=img_object($langs->trans("Notifications"),'email').' '.$langs->trans("SomeNotificationsWillBeSent",$nb);
116
+		if (is_array($listofnotiftodo)) {
117
+		    $nb=count($listofnotiftodo);
118
+		}
119
+		if ($nb < 0) {
120
+		    $texte=img_object($langs->trans("Notifications"),'email').' '.$langs->trans("ErrorFailedToGetListOfNotificationsToSend");
121
+		}
122
+		if ($nb == 0) {
123
+		    $texte=img_object($langs->trans("Notifications"),'email').' '.$langs->trans("NoNotificationsWillBeSent");
124
+		}
125
+   		if ($nb == 1) {
126
+   		    $texte=img_object($langs->trans("Notifications"),'email').' '.$langs->trans("ANotificationsWillBeSent");
127
+   		}
128
+   		if ($nb >= 2) {
129
+   		    $texte=img_object($langs->trans("Notifications"),'email').' '.$langs->trans("SomeNotificationsWillBeSent",$nb);
130
+   		}
121 131
 
122 132
    		if (is_array($listofnotiftodo))
123 133
    		{
124 134
 			$i=0;
125 135
 			foreach ($listofnotiftodo as $key => $val)
126 136
 			{
127
-				if ($i) $texte.=', ';
128
-				else $texte.=' (';
129
-				if ($val['isemailvalid']) $texte.=$val['email'];
130
-				else $texte.=$val['emaildesc'];
137
+				if ($i) {
138
+				    $texte.=', ';
139
+				} else {
140
+				    $texte.=' (';
141
+				}
142
+				if ($val['isemailvalid']) {
143
+				    $texte.=$val['email'];
144
+				} else {
145
+				    $texte.=$val['emaildesc'];
146
+				}
131 147
 				$i++;
132 148
 			}
133
-			if ($i) $texte.=')';
149
+			if ($i) {
150
+			    $texte.=')';
151
+			}
134 152
    		}
135 153
 
136 154
 		return $texte;
@@ -154,7 +172,9 @@  discard block
 block discarded – undo
154 172
 		$resarray=array();
155 173
 
156 174
 		$valueforthreshold = 0;
157
-		if (is_object($object)) $valueforthreshold = $object->total_ht;
175
+		if (is_object($object)) {
176
+		    $valueforthreshold = $object->total_ht;
177
+		}
158 178
 
159 179
 		if (! $error)
160 180
 		{
@@ -170,11 +190,19 @@  discard block
 block discarded – undo
170 190
 				$sql.= " AND n.fk_soc = s.rowid";
171 191
 				if ($notifcode)
172 192
 				{
173
-					if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode;	// Old usage
174
-					else $sql.= " AND a.code = '".$notifcode."'";			// New usage
193
+					if (is_numeric($notifcode)) {
194
+					    $sql.= " AND n.fk_action = ".$notifcode;
195
+					}
196
+					// Old usage
197
+					else {
198
+					    $sql.= " AND a.code = '".$notifcode."'";
199
+					}
200
+					// New usage
175 201
 				}
176 202
 				$sql.= " AND s.entity IN (".getEntity('societe').")";
177
-				if ($socid > 0) $sql.= " AND s.rowid = ".$socid;
203
+				if ($socid > 0) {
204
+				    $sql.= " AND s.rowid = ".$socid;
205
+				}
178 206
 
179 207
 				dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG);
180 208
 
@@ -190,12 +218,13 @@  discard block
 block discarded – undo
190 218
 						{
191 219
 							$newval2=trim($obj->email);
192 220
 							$isvalid=isValidEmail($newval2);
193
-							if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'tocontact', 'code'=>trim($obj->code), 'emaildesc'=>'Contact id '.$obj->rowid, 'email'=>$newval2, 'contactid'=>$obj->rowid, 'isemailvalid'=>$isvalid);
221
+							if (empty($resarray[$newval2])) {
222
+							    $resarray[$newval2] = array('type'=> 'tocontact', 'code'=>trim($obj->code), 'emaildesc'=>'Contact id '.$obj->rowid, 'email'=>$newval2, 'contactid'=>$obj->rowid, 'isemailvalid'=>$isvalid);
223
+							}
194 224
 						}
195 225
 						$i++;
196 226
 					}
197
-				}
198
-				else
227
+				} else
199 228
 				{
200 229
 					$error++;
201 230
 					$this->error=$this->db->lasterror();
@@ -215,11 +244,19 @@  discard block
 block discarded – undo
215 244
 				$sql.= " AND a.rowid = n.fk_action";
216 245
 				if ($notifcode)
217 246
 				{
218
-					if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode;	// Old usage
219
-					else $sql.= " AND a.code = '".$notifcode."'";			// New usage
247
+					if (is_numeric($notifcode)) {
248
+					    $sql.= " AND n.fk_action = ".$notifcode;
249
+					}
250
+					// Old usage
251
+					else {
252
+					    $sql.= " AND a.code = '".$notifcode."'";
253
+					}
254
+					// New usage
220 255
 				}
221 256
 				$sql.= " AND c.entity IN (".getEntity('user').")";
222
-				if ($userid > 0) $sql.= " AND c.rowid = ".$userid;
257
+				if ($userid > 0) {
258
+				    $sql.= " AND c.rowid = ".$userid;
259
+				}
223 260
 
224 261
 				dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG);
225 262
 
@@ -235,12 +272,13 @@  discard block
 block discarded – undo
235 272
 						{
236 273
 							$newval2=trim($obj->email);
237 274
 							$isvalid=isValidEmail($newval2);
238
-							if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'touser', 'code'=>trim($obj->code), 'emaildesc'=>'User id '.$obj->rowid, 'email'=>$newval2, 'userid'=>$obj->rowid, 'isemailvalid'=>$isvalid);
275
+							if (empty($resarray[$newval2])) {
276
+							    $resarray[$newval2] = array('type'=> 'touser', 'code'=>trim($obj->code), 'emaildesc'=>'User id '.$obj->rowid, 'email'=>$newval2, 'userid'=>$obj->rowid, 'isemailvalid'=>$isvalid);
277
+							}
239 278
 						}
240 279
 						$i++;
241 280
 					}
242
-				}
243
-				else
281
+				} else
244 282
 				{
245 283
 					$error++;
246 284
 					$this->error=$this->db->lasterror();
@@ -257,15 +295,20 @@  discard block
 block discarded – undo
257 295
 				{
258 296
 					if ($notifcode)
259 297
 					{
260
-						if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
261
-					}
262
-					else
298
+						if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) {
299
+						    continue;
300
+						}
301
+					} else
263 302
 					{
264
-						if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
303
+						if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) {
304
+						    continue;
305
+						}
265 306
 					}
266 307
 
267 308
 					$threshold = (float) $reg[1];
268
-					if ($valueforthreshold < $threshold) continue;
309
+					if ($valueforthreshold < $threshold) {
310
+					    continue;
311
+					}
269 312
 
270 313
 					$tmpemail=explode(',',$val);
271 314
 					foreach($tmpemail as $key2 => $val2)
@@ -277,22 +320,30 @@  discard block
 block discarded – undo
277 320
 							{
278 321
 								$tmpuser=new User($this->db);
279 322
 								$tmpuser->fetch($user->fk_user);
280
-								if ($tmpuser->email) $newval2=trim($tmpuser->email);
281
-								else $newval2='';
323
+								if ($tmpuser->email) {
324
+								    $newval2=trim($tmpuser->email);
325
+								} else {
326
+								    $newval2='';
327
+								}
328
+							} else {
329
+							    $newval2='';
282 330
 							}
283
-							else $newval2='';
284 331
 						}
285 332
 						if ($newval2)
286 333
 						{
287 334
 							$isvalid=isValidEmail($newval2, 0);
288
-							if (empty($resarray[$newval2])) $resarray[$newval2]=array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid);
335
+							if (empty($resarray[$newval2])) {
336
+							    $resarray[$newval2]=array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid);
337
+							}
289 338
 						}
290 339
 					}
291 340
 				}
292 341
 			}
293 342
 		}
294 343
 
295
-		if ($error) return -1;
344
+		if ($error) {
345
+		    return -1;
346
+		}
296 347
 
297 348
 		//var_dump($resarray);
298 349
 		return $resarray;
@@ -315,7 +366,9 @@  discard block
 block discarded – undo
315 366
 		global $hookmanager;
316 367
 		global $dolibarr_main_url_root;
317 368
 
318
-		if (! in_array($notifcode, $this->arrayofnotifsupported)) return 0;
369
+		if (! in_array($notifcode, $this->arrayofnotifsupported)) {
370
+		    return 0;
371
+		}
319 372
 
320 373
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
321 374
 		if (! is_object($hookmanager))
@@ -336,7 +389,9 @@  discard block
 block discarded – undo
336 389
 
337 390
 		// Define some vars
338 391
 		$application = 'Dolibarr';
339
-		if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $application = $conf->global->MAIN_APPLICATION_TITLE;
392
+		if (! empty($conf->global->MAIN_APPLICATION_TITLE)) {
393
+		    $application = $conf->global->MAIN_APPLICATION_TITLE;
394
+		}
340 395
 		$replyto = $conf->notification->email_from;
341 396
 		$object_type = '';
342 397
 		$link = '';
@@ -358,8 +413,14 @@  discard block
 block discarded – undo
358 413
 			$sql.= " ".MAIN_DB_PREFIX."societe as s";
359 414
 			$sql.= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action";
360 415
 			$sql.= " AND n.fk_soc = s.rowid";
361
-			if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode;	// Old usage
362
-			else $sql.= " AND a.code = '".$notifcode."'";	// New usage
416
+			if (is_numeric($notifcode)) {
417
+			    $sql.= " AND n.fk_action = ".$notifcode;
418
+			}
419
+			// Old usage
420
+			else {
421
+			    $sql.= " AND a.code = '".$notifcode."'";
422
+			}
423
+			// New usage
363 424
 			$sql .= " AND s.rowid = ".$object->socid;
364 425
 
365 426
 			$sql.= "\nUNION\n";
@@ -372,8 +433,14 @@  discard block
 block discarded – undo
372 433
 		$sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a,";
373 434
 		$sql.= " ".MAIN_DB_PREFIX."notify_def as n";
374 435
 		$sql.= " WHERE n.fk_user = c.rowid AND a.rowid = n.fk_action";
375
-		if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode;	// Old usage
376
-		else $sql.= " AND a.code = '".$this->db->escape($notifcode)."'";	// New usage
436
+		if (is_numeric($notifcode)) {
437
+		    $sql.= " AND n.fk_action = ".$notifcode;
438
+		}
439
+		// Old usage
440
+		else {
441
+		    $sql.= " AND a.code = '".$this->db->escape($notifcode)."'";
442
+		}
443
+		// New usage
377 444
 
378 445
 		$result = $this->db->query($sql);
379 446
 		if ($result)
@@ -391,9 +458,11 @@  discard block
 block discarded – undo
391 458
 			if ($num > 0)
392 459
 			{
393 460
 				$i = 0;
394
-				while ($i < $num && ! $error)	// For each notification couple defined (third party/actioncode)
461
+				while ($i < $num && ! $error) {
462
+				    // For each notification couple defined (third party/actioncode)
395 463
 				{
396 464
 					$obj = $this->db->fetch_object($result);
465
+				}
397 466
 
398 467
 					$sendto = dolGetFirstLastname($obj->firstname,$obj->lastname) . " <".$obj->email.">";
399 468
 					$notifcodedefid = $obj->adid;
@@ -510,8 +579,7 @@  discard block
 block discarded – undo
510 579
 						{
511 580
 							// We can't add PDF as it is not generated yet.
512 581
 							$filepdf = '';
513
-						}
514
-						else
582
+						} else
515 583
 						{
516 584
 							$filepdf = $pdf_path;
517 585
 						}
@@ -520,14 +588,20 @@  discard block
 block discarded – undo
520 588
 						$message.= $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification2",$application,$mysoc->name)."\n";
521 589
 						$message.= "\n";
522 590
 						$message.= $mesg;
523
-						if ($link) $message.= "\n" . $urlwithroot . $link;
591
+						if ($link) {
592
+						    $message.= "\n" . $urlwithroot . $link;
593
+						}
524 594
 
525 595
 						$parameters=array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list);
526 596
 						$reshook=$hookmanager->executeHooks('formatNotificationMessage',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
527 597
 						if (empty($reshook))
528 598
 						{
529
-							if (! empty($hookmanager->resArray['subject'])) $subject.=$hookmanager->resArray['subject'];
530
-							if (! empty($hookmanager->resArray['message'])) $message.=$hookmanager->resArray['message'];
599
+							if (! empty($hookmanager->resArray['subject'])) {
600
+							    $subject.=$hookmanager->resArray['subject'];
601
+							}
602
+							if (! empty($hookmanager->resArray['message'])) {
603
+							    $message.=$hookmanager->resArray['message'];
604
+							}
531 605
 						}
532 606
 
533 607
 						$mailfile = new CMailFile(
@@ -549,8 +623,7 @@  discard block
 block discarded – undo
549 623
 							if ($obj->type_target == 'touserid') {
550 624
 	 							$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_user, type, objet_type, type_target, objet_id, email)";
551 625
 								$sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')";
552
-							}
553
-							else {
626
+							} else {
554 627
 								$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, objet_type, type_target, objet_id, email)";
555 628
 								$sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')";
556 629
 							}
@@ -558,26 +631,22 @@  discard block
 block discarded – undo
558 631
 							{
559 632
 								dol_print_error($this->db);
560 633
 							}
561
-						}
562
-						else
634
+						} else
563 635
 						{
564 636
 							$error++;
565 637
 							$this->errors[]=$mailfile->error;
566 638
 						}
567
-					}
568
-					else
639
+					} else
569 640
 				  {
570 641
 						dol_syslog("No notification sent for ".$sendto." because email is empty");
571 642
 					}
572 643
 					$i++;
573 644
 				}
574
-			}
575
-			else
645
+			} else
576 646
 			{
577 647
 				dol_syslog("No notification to thirdparty sent, nothing into notification setup for the thirdparty socid = ".$object->socid);
578 648
 			}
579
-		}
580
-		else
649
+		} else
581 650
 		{
582 651
 	   		$error++;
583 652
 			$this->errors[]=$this->db->lasterror();
@@ -590,7 +659,9 @@  discard block
 block discarded – undo
590 659
 		{
591 660
 			foreach($conf->global as $key => $val)
592 661
 			{
593
-				if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
662
+				if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) {
663
+				    continue;
664
+				}
594 665
 
595 666
 				$threshold = (float) $reg[1];
596 667
 				if (!empty($object->total_ht) && $object->total_ht <= $threshold)
@@ -603,7 +674,9 @@  discard block
 block discarded – undo
603 674
 
604 675
 				$sendto = $conf->global->$param;
605 676
 				$notifcodedefid = dol_getIdFromCode($this->db, $notifcode, 'c_action_trigger', 'code', 'rowid');
606
-				if ($notifcodedefid <= 0) dol_print_error($this->db, 'Failed to get id from code');
677
+				if ($notifcodedefid <= 0) {
678
+				    dol_print_error($this->db, 'Failed to get id from code');
679
+				}
607 680
 
608 681
 				$object_type = '';
609 682
 				$link = '';
@@ -718,8 +791,7 @@  discard block
 block discarded – undo
718 791
 				{
719 792
 					// We can't add PDF as it is not generated yet.
720 793
 					$filepdf = '';
721
-				}
722
-				else
794
+				} else
723 795
 				{
724 796
 					$filepdf = $pdf_path;
725 797
 				}
@@ -740,7 +812,9 @@  discard block
 block discarded – undo
740 812
 					{
741 813
 						$supervisoruser=new User($this->db);
742 814
 						$supervisoruser->fetch($user->fk_user);
743
-						if ($supervisoruser->email) $newval=trim(dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname).' <'.$supervisoruser->email.'>');
815
+						if ($supervisoruser->email) {
816
+						    $newval=trim(dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname).' <'.$supervisoruser->email.'>');
817
+						}
744 818
 					}
745 819
 					dol_syslog("Replace the __SUPERVISOREMAIL__ key into recipient email string with ".$newval);
746 820
 					$sendto = preg_replace('/__SUPERVISOREMAIL__/', $newval, $sendto);
@@ -755,8 +829,12 @@  discard block
 block discarded – undo
755 829
 					$reshook=$hookmanager->executeHooks('formatNotificationMessage',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
756 830
 					if (empty($reshook))
757 831
 					{
758
-						if (! empty($hookmanager->resArray['subject'])) $subject.=$hookmanager->resArray['subject'];
759
-						if (! empty($hookmanager->resArray['message'])) $message.=$hookmanager->resArray['message'];
832
+						if (! empty($hookmanager->resArray['subject'])) {
833
+						    $subject.=$hookmanager->resArray['subject'];
834
+						}
835
+						if (! empty($hookmanager->resArray['message'])) {
836
+						    $message.=$hookmanager->resArray['message'];
837
+						}
760 838
 					}
761 839
 					$mailfile = new CMailFile(
762 840
 						$subject,
@@ -780,8 +858,7 @@  discard block
 block discarded – undo
780 858
 						{
781 859
 							dol_print_error($this->db);
782 860
 						}
783
-					}
784
-					else
861
+					} else
785 862
 					{
786 863
 						$error++;
787 864
 						$this->errors[]=$mailfile->error;
@@ -790,7 +867,10 @@  discard block
 block discarded – undo
790 867
 			}
791 868
 		}
792 869
 
793
-		if (! $error) return $num;
794
-		else return -1 * $error;
870
+		if (! $error) {
871
+		    return $num;
872
+		} else {
873
+		    return -1 * $error;
874
+		}
795 875
 	}
796 876
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/class/dolgeoip.class.php 1 patch
Braces   +19 added lines, -13 removed lines patch added patch discarded remove patch
@@ -46,14 +46,16 @@  discard block
 block discarded – undo
46 46
 		if ($type == 'country')
47 47
 		{
48 48
 		    // geoip may have been already included with PEAR
49
-		    if (! function_exists('geoip_country_code_by_name')) $res=include_once GEOIP_PATH.'geoip.inc';
50
-		}
51
-		else if ($type == 'city')
49
+		    if (! function_exists('geoip_country_code_by_name')) {
50
+		        $res=include_once GEOIP_PATH.'geoip.inc';
51
+		    }
52
+		} else if ($type == 'city')
52 53
 		{
53 54
 		    // geoip may have been already included with PEAR
54
-		    if (! function_exists('geoip_country_code_by_name')) $res=include_once GEOIP_PATH.'geoipcity.inc';
55
-		}
56
-		else { print 'ErrorBadParameterInConstructor'; return 0; }
55
+		    if (! function_exists('geoip_country_code_by_name')) {
56
+		        $res=include_once GEOIP_PATH.'geoipcity.inc';
57
+		    }
58
+		} else { print 'ErrorBadParameterInConstructor'; return 0; }
57 59
 
58 60
 		// Here, function exists (embedded into PHP or exists because we made include)
59 61
 		if (empty($type) || empty($datfile))
@@ -73,8 +75,7 @@  discard block
 block discarded – undo
73 75
 		if (function_exists('geoip_open'))
74 76
 		{
75 77
 			$this->gi = geoip_open($datfile,GEOIP_STANDARD);
76
-		}
77
-		else
78
+		} else
78 79
 		{
79 80
 		    $this->gi = 'NOGI';    // We are using embedded php geoip functions
80 81
 		    //print 'function_exists(geoip_country_code_by_name))='.function_exists('geoip_country_code_by_name');
@@ -98,10 +99,11 @@  discard block
 block discarded – undo
98 99
 		{
99 100
 		    // geoip_country_code_by_addr does not exists
100 101
     		return strtolower(geoip_country_code_by_name($ip));
101
-		}
102
-		else
102
+		} else
103 103
 		{
104
-		    if (! function_exists('geoip_country_code_by_addr')) return strtolower(geoip_country_code_by_name($this->gi, $ip));
104
+		    if (! function_exists('geoip_country_code_by_addr')) {
105
+		        return strtolower(geoip_country_code_by_name($this->gi, $ip));
106
+		    }
105 107
 		    return strtolower(geoip_country_code_by_addr($this->gi, $ip));
106 108
 		}
107 109
 	}
@@ -128,7 +130,9 @@  discard block
 block discarded – undo
128 130
 	 */
129 131
 	function getVersion()
130 132
 	{
131
-	    if ($this->gi == 'NOGI') return geoip_database_info();
133
+	    if ($this->gi == 'NOGI') {
134
+	        return geoip_database_info();
135
+	    }
132 136
 		return 'Not available (not using PHP internal geo functions)';
133 137
 	}
134 138
 
@@ -139,9 +143,11 @@  discard block
 block discarded – undo
139 143
 	 */
140 144
 	function close()
141 145
 	{
142
-	    if (function_exists('geoip_close'))    // With some geoip with PEAR, geoip_close function may not exists
146
+	    if (function_exists('geoip_close')) {
147
+	        // With some geoip with PEAR, geoip_close function may not exists
143 148
 	    {
144 149
 	        geoip_close($this->gi);
145 150
 	    }
151
+	    }
146 152
 	}
147 153
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/class/html.formfile.class.php 1 patch
Braces   +404 added lines, -255 removed lines patch added patch discarded remove patch
@@ -84,7 +84,9 @@  discard block
 block discarded – undo
84 84
 		$hookmanager->initHooks(array('formfile'));
85 85
 
86 86
 
87
-		if (! empty($conf->browser->layout) && $conf->browser->layout != 'classic') $useajax=0;
87
+		if (! empty($conf->browser->layout) && $conf->browser->layout != 'classic') {
88
+		    $useajax=0;
89
+		}
88 90
 
89 91
 		if ((! empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD) && $useajax) || ($useajax==2))
90 92
 		{
@@ -93,8 +95,7 @@  discard block
 block discarded – undo
93 95
 			// TODO: This does not support option savingdocmask
94 96
 			// TODO: This break feature to upload links too
95 97
 			return $this->_formAjaxFileUpload($object);
96
-		}
97
-		else
98
+		} else
98 99
 	   	{
99 100
 			//If there is no permission and the option to hide unauthorized actions is enabled, then nothing is printed
100 101
 			if (!$perm && !empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) {
@@ -105,8 +106,12 @@  discard block
 block discarded – undo
105 106
 
106 107
 			$out = "\n\n<!-- Start form attach new file -->\n";
107 108
 
108
-			if (empty($title)) $title=$langs->trans("AttachANewFile");
109
-			if ($title != 'none') $out.=load_fiche_titre($title, null, null);
109
+			if (empty($title)) {
110
+			    $title=$langs->trans("AttachANewFile");
111
+			}
112
+			if ($title != 'none') {
113
+			    $out.=load_fiche_titre($title, null, null);
114
+			}
110 115
 
111 116
 			$out .= '<form name="'.$htmlname.'" id="'.$htmlname.'" action="'.$url.'" enctype="multipart/form-data" method="POST">';
112 117
 			$out .= '<input type="hidden" id="'.$htmlname.'_section_dir" name="section_dir" value="'.$sectiondir.'">';
@@ -116,19 +121,31 @@  discard block
 block discarded – undo
116 121
 			$out .= '<table width="100%" class="nobordernopadding">';
117 122
 			$out .= '<tr>';
118 123
 
119
-			if (! empty($options)) $out .= '<td>'.$options.'</td>';
124
+			if (! empty($options)) {
125
+			    $out .= '<td>'.$options.'</td>';
126
+			}
120 127
 
121 128
 			$out .= '<td class="valignmiddle nowrap">';
122 129
 
123 130
 			$max=$conf->global->MAIN_UPLOAD_DOC;		// En Kb
124 131
 			$maxphp=@ini_get('upload_max_filesize');	// En inconnu
125
-			if (preg_match('/k$/i',$maxphp)) $maxphp=$maxphp*1;
126
-			if (preg_match('/m$/i',$maxphp)) $maxphp=$maxphp*1024;
127
-			if (preg_match('/g$/i',$maxphp)) $maxphp=$maxphp*1024*1024;
128
-			if (preg_match('/t$/i',$maxphp)) $maxphp=$maxphp*1024*1024*1024;
132
+			if (preg_match('/k$/i',$maxphp)) {
133
+			    $maxphp=$maxphp*1;
134
+			}
135
+			if (preg_match('/m$/i',$maxphp)) {
136
+			    $maxphp=$maxphp*1024;
137
+			}
138
+			if (preg_match('/g$/i',$maxphp)) {
139
+			    $maxphp=$maxphp*1024*1024;
140
+			}
141
+			if (preg_match('/t$/i',$maxphp)) {
142
+			    $maxphp=$maxphp*1024*1024*1024;
143
+			}
129 144
 			// Now $max and $maxphp are in Kb
130 145
 			$maxmin = $max;
131
-			if ($maxphp > 0) $maxmin=min($max,$maxphp);
146
+			if ($maxphp > 0) {
147
+			    $maxmin=min($max,$maxphp);
148
+			}
132 149
 
133 150
 			if ($maxmin > 0)
134 151
 			{
@@ -160,8 +177,7 @@  discard block
 block discarded – undo
160 177
 					$out .= ' ';
161 178
 					$out .= info_admin($langs->trans("ThisLimitIsDefinedInSetup",$max,$maxphp),1);
162 179
 				}
163
-			}
164
-			else
180
+			} else
165 181
 			{
166 182
 				$out .= ' ('.$langs->trans("UploadDisabled").')';
167 183
 			}
@@ -170,7 +186,9 @@  discard block
 block discarded – undo
170 186
 			if ($savingdocmask)
171 187
 			{
172 188
 				$out .= '<tr>';
173
-   				if (! empty($options)) $out .= '<td>'.$options.'</td>';
189
+   				if (! empty($options)) {
190
+   				    $out .= '<td>'.$options.'</td>';
191
+   				}
174 192
 				$out .= '<td valign="middle" class="nowrap">';
175 193
 				$out .= '<input type="checkbox" checked class="savingdocmask" name="savingdocmask" value="'.dol_escape_js($savingdocmask).'"> '.$langs->trans("SaveUploadedFileWithMask", preg_replace('/__file__/',$langs->transnoentitiesnoconv("OriginFileName"),$savingdocmask), $langs->transnoentitiesnoconv("OriginFileName"));
176 194
 				$out .= '</td>';
@@ -180,7 +198,9 @@  discard block
 block discarded – undo
180 198
 			$out .= "</table>";
181 199
 
182 200
 			$out .= '</form>';
183
-			if (empty($sectionid)) $out .= '<br>';
201
+			if (empty($sectionid)) {
202
+			    $out .= '<br>';
203
+			}
184 204
 
185 205
 			$out .= "\n<!-- End form attach new file -->\n";
186 206
 
@@ -197,11 +217,15 @@  discard block
 block discarded – undo
197 217
 
198 218
 				$out .= '<div class="valignmiddle" >';
199 219
 				$out .= '<div class="inline-block" style="padding-right: 10px;">';
200
-				if (! empty($conf->global->OPTIMIZEFORTEXTBROWSER)) $out .= '<label for="link">'.$langs->trans("URLToLink") . ':</label> ';
220
+				if (! empty($conf->global->OPTIMIZEFORTEXTBROWSER)) {
221
+				    $out .= '<label for="link">'.$langs->trans("URLToLink") . ':</label> ';
222
+				}
201 223
 				$out .= '<input type="text" name="link" class="flat minwidth400imp" id="link" placeholder="'.dol_escape_htmltag($langs->trans("URLToLink")).'">';
202 224
 				$out .= '</div>';
203 225
 				$out .= '<div class="inline-block" style="padding-right: 10px;">';
204
-				if (! empty($conf->global->OPTIMIZEFORTEXTBROWSER)) $out .= '<label for="label">'.$langs->trans("Label") . ':</label> ';
226
+				if (! empty($conf->global->OPTIMIZEFORTEXTBROWSER)) {
227
+				    $out .= '<label for="label">'.$langs->trans("Label") . ':</label> ';
228
+				}
205 229
 				$out .= '<input type="text" class="flat" name="label" id="label" placeholder="'.dol_escape_htmltag($langs->trans("Label")).'">';
206 230
 				$out .= '<input type="hidden" name="objecttype" value="' . $object->element . '">';
207 231
 				$out .= '<input type="hidden" name="objectid" value="' . $object->id . '">';
@@ -298,7 +322,9 @@  discard block
 block discarded – undo
298 322
 		global $langs, $conf, $user, $hookmanager;
299 323
 		global $form;
300 324
 
301
-		if (! is_object($form)) $form=new Form($this->db);
325
+		if (! is_object($form)) {
326
+		    $form=new Form($this->db);
327
+		}
302 328
 
303 329
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
304 330
 
@@ -311,10 +337,12 @@  discard block
 block discarded – undo
311 337
 		$param.= 'entity='.(!empty($object->entity)?$object->entity:$conf->entity);
312 338
 
313 339
 		$printer=0;
314
-		if (in_array($modulepart,array('facture','supplier_proposal','propal','proposal','order','commande','expedition', 'commande_fournisseur', 'expensereport','livraison')))	// The direct print feature is implemented only for such elements
340
+		if (in_array($modulepart,array('facture','supplier_proposal','propal','proposal','order','commande','expedition', 'commande_fournisseur', 'expensereport','livraison'))) {
341
+		    // The direct print feature is implemented only for such elements
315 342
 		{
316 343
 			$printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled))?true:false;
317 344
 		}
345
+		}
318 346
 
319 347
 		$hookmanager->initHooks(array('formfile'));
320 348
 
@@ -324,7 +352,9 @@  discard block
 block discarded – undo
324 352
 		{
325 353
 			$file_list=dol_dir_list($filedir,'files',0,'','(\.meta|_preview.*.*\.png)$','date',SORT_DESC);
326 354
 		}
327
-		if ($hideifempty && empty($file_list)) return '';
355
+		if ($hideifempty && empty($file_list)) {
356
+		    return '';
357
+		}
328 358
 
329 359
 		$out='';
330 360
 		$forname='builddoc';
@@ -361,7 +391,9 @@  discard block
 block discarded – undo
361 391
 		}
362 392
 
363 393
 		$titletoshow=$langs->trans("Documents");
364
-		if (! empty($title)) $titletoshow=$title;
394
+		if (! empty($title)) {
395
+		    $titletoshow=$title;
396
+		}
365 397
 
366 398
 		// Show table
367 399
 		if ($genallowed)
@@ -371,252 +403,251 @@  discard block
 block discarded – undo
371 403
 			if ($modulepart == 'company')
372 404
 			{
373 405
 				$showempty=1;
374
-				if (is_array($genallowed)) $modellist=$genallowed;
375
-				else
406
+				if (is_array($genallowed)) {
407
+				    $modellist=$genallowed;
408
+				} else
376 409
 				{
377 410
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/societe/modules_societe.class.php';
378 411
 					$modellist=ModeleThirdPartyDoc::liste_modeles($this->db);
379 412
 				}
380
-			}
381
-			else if ($modulepart == 'propal')
413
+			} else if ($modulepart == 'propal')
382 414
 			{
383
-				if (is_array($genallowed)) $modellist=$genallowed;
384
-				else
415
+				if (is_array($genallowed)) {
416
+				    $modellist=$genallowed;
417
+				} else
385 418
 				{
386 419
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php';
387 420
 					$modellist=ModelePDFPropales::liste_modeles($this->db);
388 421
 				}
389
-			}
390
-			else if ($modulepart == 'supplier_proposal')
422
+			} else if ($modulepart == 'supplier_proposal')
391 423
 			{
392
-				if (is_array($genallowed)) $modellist=$genallowed;
393
-				else
424
+				if (is_array($genallowed)) {
425
+				    $modellist=$genallowed;
426
+				} else
394 427
 				{
395 428
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_proposal/modules_supplier_proposal.php';
396 429
 					$modellist=ModelePDFSupplierProposal::liste_modeles($this->db);
397 430
 				}
398
-			}
399
-			else if ($modulepart == 'commande')
431
+			} else if ($modulepart == 'commande')
400 432
 			{
401
-				if (is_array($genallowed)) $modellist=$genallowed;
402
-				else
433
+				if (is_array($genallowed)) {
434
+				    $modellist=$genallowed;
435
+				} else
403 436
 				{
404 437
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php';
405 438
 					$modellist=ModelePDFCommandes::liste_modeles($this->db);
406 439
 				}
407
-			}
408
-			elseif ($modulepart == 'expedition')
440
+			} elseif ($modulepart == 'expedition')
409 441
 			{
410
-				if (is_array($genallowed)) $modellist=$genallowed;
411
-				else
442
+				if (is_array($genallowed)) {
443
+				    $modellist=$genallowed;
444
+				} else
412 445
 				{
413 446
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php';
414 447
 					$modellist=ModelePDFExpedition::liste_modeles($this->db);
415 448
 				}
416
-			}
417
-            elseif ($modulepart == 'reception')
449
+			} elseif ($modulepart == 'reception')
418 450
             {
419
-                if (is_array($genallowed)) $modellist=$genallowed;
420
-                else
451
+                if (is_array($genallowed)) {
452
+                    $modellist=$genallowed;
453
+                } else
421 454
                 {
422 455
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php';
423 456
 					$modellist = ModelePdfReception::liste_modeles($this->db);
424 457
 				}
425
-            }
426
-			elseif ($modulepart == 'livraison')
458
+            } elseif ($modulepart == 'livraison')
427 459
 			{
428
-				if (is_array($genallowed)) $modellist=$genallowed;
429
-				else
460
+				if (is_array($genallowed)) {
461
+				    $modellist=$genallowed;
462
+				} else
430 463
 				{
431 464
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/livraison/modules_livraison.php';
432 465
 					$modellist=ModelePDFDeliveryOrder::liste_modeles($this->db);
433 466
 				}
434
-			}
435
-			else if ($modulepart == 'ficheinter')
467
+			} else if ($modulepart == 'ficheinter')
436 468
 			{
437
-				if (is_array($genallowed)) $modellist=$genallowed;
438
-				else
469
+				if (is_array($genallowed)) {
470
+				    $modellist=$genallowed;
471
+				} else
439 472
 				{
440 473
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php';
441 474
 					$modellist=ModelePDFFicheinter::liste_modeles($this->db);
442 475
 				}
443
-			}
444
-			elseif ($modulepart == 'facture')
476
+			} elseif ($modulepart == 'facture')
445 477
 			{
446
-				if (is_array($genallowed)) $modellist=$genallowed;
447
-				else
478
+				if (is_array($genallowed)) {
479
+				    $modellist=$genallowed;
480
+				} else
448 481
 				{
449 482
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
450 483
 					$modellist=ModelePDFFactures::liste_modeles($this->db);
451 484
 				}
452
-			}
453
-			elseif ($modulepart == 'contract')
485
+			} elseif ($modulepart == 'contract')
454 486
 			{
455
-				if (is_array($genallowed)) $modellist=$genallowed;
456
-				else
487
+				if (is_array($genallowed)) {
488
+				    $modellist=$genallowed;
489
+				} else
457 490
 				{
458 491
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/contract/modules_contract.php';
459 492
 					$modellist=ModelePDFContract::liste_modeles($this->db);
460 493
 				}
461
-			}
462
-			elseif ($modulepart == 'project')
494
+			} elseif ($modulepart == 'project')
463 495
 			{
464
-				if (is_array($genallowed)) $modellist=$genallowed;
465
-				else
496
+				if (is_array($genallowed)) {
497
+				    $modellist=$genallowed;
498
+				} else
466 499
 				{
467 500
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
468 501
 					$modellist=ModelePDFProjects::liste_modeles($this->db);
469 502
 				}
470
-			}
471
-			elseif ($modulepart == 'project_task')
503
+			} elseif ($modulepart == 'project_task')
472 504
 			{
473
-				if (is_array($genallowed)) $modellist=$genallowed;
474
-				else
505
+				if (is_array($genallowed)) {
506
+				    $modellist=$genallowed;
507
+				} else
475 508
 				{
476 509
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php';
477 510
 					$modellist=ModelePDFTask::liste_modeles($this->db);
478 511
 				}
479
-			}
480
-			elseif ($modulepart == 'product')
512
+			} elseif ($modulepart == 'product')
481 513
 			{
482
-				if (is_array($genallowed)) $modellist=$genallowed;
483
-				else
514
+				if (is_array($genallowed)) {
515
+				    $modellist=$genallowed;
516
+				} else
484 517
 				{
485 518
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/product/modules_product.class.php';
486 519
 					$modellist=ModelePDFProduct::liste_modeles($this->db);
487 520
 				}
488
-			}
489
-			elseif ($modulepart == 'product_batch')
521
+			} elseif ($modulepart == 'product_batch')
490 522
 			{
491
-				if (is_array($genallowed)) $modellist=$genallowed;
492
-				else
523
+				if (is_array($genallowed)) {
524
+				    $modellist=$genallowed;
525
+				} else
493 526
 				{
494 527
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/product_batch/modules_product_batch.class.php';
495 528
 					$modellist=ModelePDFProductBatch::liste_modeles($this->db);
496 529
 				}
497
-			}
498
-			elseif ($modulepart == 'stock')
530
+			} elseif ($modulepart == 'stock')
499 531
 			{
500
-				if (is_array($genallowed)) $modellist=$genallowed;
501
-				else
532
+				if (is_array($genallowed)) {
533
+				    $modellist=$genallowed;
534
+				} else
502 535
 				{
503 536
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_stock.php';
504 537
 					$modellist=ModelePDFStock::liste_modeles($this->db);
505 538
 				}
506
-			}
507
-			elseif ($modulepart == 'movement')
539
+			} elseif ($modulepart == 'movement')
508 540
 			{
509
-				if (is_array($genallowed)) $modellist=$genallowed;
510
-				else
541
+				if (is_array($genallowed)) {
542
+				    $modellist=$genallowed;
543
+				} else
511 544
 				{
512 545
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_movement.php';
513 546
 					$modellist=ModelePDFMovement::liste_modeles($this->db);
514 547
 				}
515
-			}
516
-			elseif ($modulepart == 'export')
548
+			} elseif ($modulepart == 'export')
517 549
 			{
518
-				if (is_array($genallowed)) $modellist=$genallowed;
519
-				else
550
+				if (is_array($genallowed)) {
551
+				    $modellist=$genallowed;
552
+				} else
520 553
 				{
521 554
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php';
522 555
 					$modellist=ModeleExports::liste_modeles($this->db);
523 556
 				}
524
-			}
525
-			else if ($modulepart == 'commande_fournisseur' || $modulepart == 'supplier_order')
557
+			} else if ($modulepart == 'commande_fournisseur' || $modulepart == 'supplier_order')
526 558
 			{
527
-				if (is_array($genallowed)) $modellist=$genallowed;
528
-				else
559
+				if (is_array($genallowed)) {
560
+				    $modellist=$genallowed;
561
+				} else
529 562
 				{
530 563
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_order/modules_commandefournisseur.php';
531 564
 					$modellist=ModelePDFSuppliersOrders::liste_modeles($this->db);
532 565
 				}
533
-			}
534
-			else if ($modulepart == 'facture_fournisseur' || $modulepart == 'supplier_invoice')
566
+			} else if ($modulepart == 'facture_fournisseur' || $modulepart == 'supplier_invoice')
535 567
 			{
536
-				if (is_array($genallowed)) $modellist=$genallowed;
537
-				else
568
+				if (is_array($genallowed)) {
569
+				    $modellist=$genallowed;
570
+				} else
538 571
 				{
539 572
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefournisseur.php';
540 573
 					$modellist=ModelePDFSuppliersInvoices::liste_modeles($this->db);
541 574
 				}
542
-			}
543
-			else if ($modulepart == 'supplier_payment')
575
+			} else if ($modulepart == 'supplier_payment')
544 576
 			{
545
-				if (is_array($genallowed)) $modellist=$genallowed;
546
-				else
577
+				if (is_array($genallowed)) {
578
+				    $modellist=$genallowed;
579
+				} else
547 580
 				{
548 581
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_payment/modules_supplier_payment.php';
549 582
 					$modellist=ModelePDFSuppliersPayments::liste_modeles($this->db);
550 583
 				}
551
-			}
552
-			else if ($modulepart == 'remisecheque')
584
+			} else if ($modulepart == 'remisecheque')
553 585
 			{
554
-				if (is_array($genallowed)) $modellist=$genallowed;
555
-				else
586
+				if (is_array($genallowed)) {
587
+				    $modellist=$genallowed;
588
+				} else
556 589
 				{
557 590
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/cheque/modules_chequereceipts.php';
558 591
 					$modellist=ModeleChequeReceipts::liste_modeles($this->db);
559 592
 				}
560
-			}
561
-			elseif ($modulepart == 'donation')
593
+			} elseif ($modulepart == 'donation')
562 594
 			{
563
-				if (is_array($genallowed)) $modellist=$genallowed;
564
-				else
595
+				if (is_array($genallowed)) {
596
+				    $modellist=$genallowed;
597
+				} else
565 598
 				{
566 599
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/dons/modules_don.php';
567 600
 					$modellist=ModeleDon::liste_modeles($this->db);
568 601
 				}
569
-			}
570
-			elseif ($modulepart == 'member')
602
+			} elseif ($modulepart == 'member')
571 603
 			{
572
-				if (is_array($genallowed)) $modellist=$genallowed;
573
-				else
604
+				if (is_array($genallowed)) {
605
+				    $modellist=$genallowed;
606
+				} else
574 607
 				{
575 608
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/member/modules_cards.php';
576 609
 					$modellist=ModelePDFCards::liste_modeles($this->db);
577 610
 				}
578
-			}
579
-			elseif ($modulepart == 'agenda' || $modulepart == 'actions')
611
+			} elseif ($modulepart == 'agenda' || $modulepart == 'actions')
580 612
 			{
581
-				if (is_array($genallowed)) $modellist=$genallowed;
582
-				else
613
+				if (is_array($genallowed)) {
614
+				    $modellist=$genallowed;
615
+				} else
583 616
 				{
584 617
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/action/modules_action.php';
585 618
 					$modellist=ModeleAction::liste_modeles($this->db);
586 619
 				}
587
-			}
588
-			else if ($modulepart == 'expensereport')
620
+			} else if ($modulepart == 'expensereport')
589 621
 			{
590
-				if (is_array($genallowed)) $modellist=$genallowed;
591
-				else
622
+				if (is_array($genallowed)) {
623
+				    $modellist=$genallowed;
624
+				} else
592 625
 				{
593 626
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php';
594 627
 					$modellist=ModeleExpenseReport::liste_modeles($this->db);
595 628
 				}
596
-			}
597
-			else if ($modulepart == 'unpaid')
629
+			} else if ($modulepart == 'unpaid')
598 630
 			{
599 631
 				$modellist='';
600
-			}
601
-			elseif ($modulepart == 'user')
632
+			} elseif ($modulepart == 'user')
602 633
 			{
603
-				if (is_array($genallowed)) $modellist=$genallowed;
604
-				else
634
+				if (is_array($genallowed)) {
635
+				    $modellist=$genallowed;
636
+				} else
605 637
 				{
606 638
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/user/modules_user.class.php';
607 639
 					$modellist=ModelePDFUser::liste_modeles($this->db);
608 640
 				}
609
-			}
610
-			elseif ($modulepart == 'usergroup')
641
+			} elseif ($modulepart == 'usergroup')
611 642
 			{
612
-				if (is_array($genallowed)) $modellist=$genallowed;
613
-				else
643
+				if (is_array($genallowed)) {
644
+				    $modellist=$genallowed;
645
+				} else
614 646
 				{
615 647
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/usergroup/modules_usergroup.class.php';
616 648
 					$modellist=ModelePDFUserGroup::liste_modeles($this->db);
617 649
 				}
618
-			}
619
-			else
650
+			} else
620 651
 			{
621 652
 				// For normalized standard modules
622 653
 				$file=dol_buildpath('/core/modules/'.$modulepart.'/modules_'.$modulepart.'.php',0);
@@ -634,8 +665,7 @@  discard block
 block discarded – undo
634 665
 				if (class_exists($class))
635 666
 				{
636 667
 					$modellist=call_user_func($class.'::liste_modeles',$this->db);
637
-				}
638
-				else
668
+				} else
639 669
 				{
640 670
 					dol_print_error($this->db,'Bad value for modulepart');
641 671
 					return -1;
@@ -646,10 +676,17 @@  discard block
 block discarded – undo
646 676
 			$headershown=1;
647 677
 
648 678
 			$buttonlabeltoshow=$buttonlabel;
649
-			if (empty($buttonlabel)) $buttonlabel=$langs->trans('Generate');
679
+			if (empty($buttonlabel)) {
680
+			    $buttonlabel=$langs->trans('Generate');
681
+			}
650 682
 
651
-			if ($conf->browser->layout == 'phone') $urlsource.='#'.$forname.'_form';   // So we switch to form after a generation
652
-			if (empty($noform)) $out.= '<form action="'.$urlsource.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc').'" id="'.$forname.'_form" method="post">';
683
+			if ($conf->browser->layout == 'phone') {
684
+			    $urlsource.='#'.$forname.'_form';
685
+			}
686
+			// So we switch to form after a generation
687
+			if (empty($noform)) {
688
+			    $out.= '<form action="'.$urlsource.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc').'" id="'.$forname.'_form" method="post">';
689
+			}
653 690
 			$out.= '<input type="hidden" name="action" value="builddoc">';
654 691
 			$out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
655 692
 
@@ -666,9 +703,11 @@  discard block
 block discarded – undo
666 703
 			if (! empty($modellist))
667 704
 			{
668 705
 				$out.= '<span class="hideonsmartphone">'.$langs->trans('Model').' </span>';
669
-				if (is_array($modellist) && count($modellist) == 1)    // If there is only one element
706
+				if (is_array($modellist) && count($modellist) == 1) {
707
+				    // If there is only one element
670 708
 				{
671 709
 					$arraykeys=array_keys($modellist);
710
+				}
672 711
 					$modelselected=$arraykeys[0];
673 712
 				}
674 713
 				$out.= $form->selectarray('model', $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100');
@@ -676,8 +715,7 @@  discard block
 block discarded – undo
676 715
 				{
677 716
 					$out.= ajax_combobox('model');
678 717
 				}
679
-			}
680
-			else
718
+			} else
681 719
 			{
682 720
 				$out.= '<div class="float">'.$langs->trans("Files").'</div>';
683 721
 			}
@@ -689,10 +727,11 @@  discard block
 block discarded – undo
689 727
 				$formadmin=new FormAdmin($this->db);
690 728
 				$defaultlang=$codelang?$codelang:$langs->getDefaultLang();
691 729
 				$morecss='maxwidth150';
692
-				if ($conf->browser->layout == 'phone') $morecss='maxwidth100';
730
+				if ($conf->browser->layout == 'phone') {
731
+				    $morecss='maxwidth100';
732
+				}
693 733
 				$out.= $formadmin->select_language($defaultlang, 'lang_id', 0, 0, 0, 0, 0, $morecss);
694
-			}
695
-			else
734
+			} else
696 735
 			{
697 736
 				$out.= '&nbsp;';
698 737
 			}
@@ -700,15 +739,21 @@  discard block
 block discarded – undo
700 739
 			// Button
701 740
 			$genbutton = '<input class="button buttongen" id="'.$forname.'_generatebutton" name="'.$forname.'_generatebutton"';
702 741
 			$genbutton.= ' type="submit" value="'.$buttonlabel.'"';
703
-			if (! $allowgenifempty && ! is_array($modellist) && empty($modellist)) $genbutton.= ' disabled';
742
+			if (! $allowgenifempty && ! is_array($modellist) && empty($modellist)) {
743
+			    $genbutton.= ' disabled';
744
+			}
704 745
 			$genbutton.= '>';
705 746
 			if ($allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid')
706 747
 			{
707 748
 			   	$langs->load("errors");
708 749
 			   	$genbutton.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated"));
709 750
 			}
710
-			if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton='';
711
-			if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') $genbutton='';
751
+			if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') {
752
+			    $genbutton='';
753
+			}
754
+			if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') {
755
+			    $genbutton='';
756
+			}
712 757
 			$out.= $genbutton;
713 758
 			$out.= '</th>';
714 759
 
@@ -716,7 +761,9 @@  discard block
 block discarded – undo
716 761
 			{
717 762
 				foreach($hookmanager->hooks['formfile'] as $module)
718 763
 				{
719
-					if (method_exists($module, 'formBuilddocLineOptions')) $out .= '<th></th>';
764
+					if (method_exists($module, 'formBuilddocLineOptions')) {
765
+					    $out .= '<th></th>';
766
+					}
720 767
 				}
721 768
 			}
722 769
 			$out.= '</tr>';
@@ -761,19 +808,30 @@  discard block
 block discarded – undo
761 808
 				{
762 809
 					// Define relative path for download link (depends on module)
763 810
 					$relativepath=$file["name"];										// Cas general
764
-					if ($modulesubdir) $relativepath=$modulesubdir."/".$file["name"];	// Cas propal, facture...
765
-					if ($modulepart == 'export') $relativepath = $file["name"];			// Other case
811
+					if ($modulesubdir) {
812
+					    $relativepath=$modulesubdir."/".$file["name"];
813
+					}
814
+					// Cas propal, facture...
815
+					if ($modulepart == 'export') {
816
+					    $relativepath = $file["name"];
817
+					}
818
+					// Other case
766 819
 
767 820
 					$out.= '<tr class="oddeven">';
768 821
 
769 822
 					$documenturl = DOL_URL_ROOT.'/document.php';
770
-					if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP;    // To use another wrapper
823
+					if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) {
824
+					    $documenturl=$conf->global->DOL_URL_ROOT_DOCUMENT_PHP;
825
+					}
826
+					// To use another wrapper
771 827
 
772 828
 					// Show file name with link to download
773 829
 					$out.= '<td class="minwidth200">';
774 830
 					$out.= '<a class="documentdownload paddingright" href="'.$documenturl.'?modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).($param?'&'.$param:'').'"';
775 831
 					$mime=dol_mimetype($relativepath,'',0);
776
-					if (preg_match('/text/',$mime)) $out.= ' target="_blank"';
832
+					if (preg_match('/text/',$mime)) {
833
+					    $out.= ' target="_blank"';
834
+					}
777 835
 					$out.= ' target="_blank">';
778 836
 					$out.= img_mime($file["name"],$langs->trans("File").': '.$file["name"]);
779 837
 					$out.= dol_trunc($file["name"], 150);
@@ -824,8 +882,10 @@  discard block
 block discarded – undo
824 882
 						{
825 883
 							$out.= $hookmanager->resPrint;		// Complete line
826 884
 							$out.= '</tr>';
885
+						} else {
886
+						    $out = $hookmanager->resPrint;
827 887
 						}
828
-						else $out = $hookmanager->resPrint;		// Replace line
888
+						// Replace line
829 889
 			  		}
830 890
 				}
831 891
 
@@ -847,7 +907,9 @@  discard block
 block discarded – undo
847 907
 					$out.='<td align="right">';
848 908
 					$out.=dol_print_date($file->datea,'dayhour');
849 909
 					$out.='</td>';
850
-					if ($delallowed || $printer || $morepicto) $out.='<td></td>';
910
+					if ($delallowed || $printer || $morepicto) {
911
+					    $out.='<td></td>';
912
+					}
851 913
 					$out.='</tr>'."\n";
852 914
 				}
853 915
 				$this->numoffiles++;
@@ -866,7 +928,9 @@  discard block
 block discarded – undo
866 928
 			$out.= "</div>\n";
867 929
 			if ($genallowed)
868 930
 			{
869
-				if (empty($noform)) $out.= '</form>'."\n";
931
+				if (empty($noform)) {
932
+				    $out.= '</form>'."\n";
933
+				}
870 934
 			}
871 935
 		}
872 936
 		$out.= '<!-- End show_document -->'."\n";
@@ -908,8 +972,7 @@  discard block
 block discarded – undo
908 972
 		if (! empty($conf->global->MAIN_SHOW_ALL_FILES_ON_DOCUMENT_TOOLTIP))
909 973
 		{
910 974
 			$filterforfilesearch = preg_quote(basename($modulesubdir),'/');
911
-		}
912
-		else
975
+		} else
913 976
 		{
914 977
 			$filterforfilesearch = preg_quote(basename($modulesubdir),'/').'[^\-]+';
915 978
 		}
@@ -930,12 +993,18 @@  discard block
 block discarded – undo
930 993
 			foreach($file_list as $file)
931 994
 			{
932 995
 				$i++;
933
-				if ($filter && ! preg_match('/'.$filter.'/i', $file["name"])) continue;	// Discard this. It does not match provided filter.
996
+				if ($filter && ! preg_match('/'.$filter.'/i', $file["name"])) {
997
+				    continue;
998
+				}
999
+				// Discard this. It does not match provided filter.
934 1000
 
935 1001
 				$found++;
936 1002
 				// Define relative path for download link (depends on module)
937 1003
 				$relativepath=$file["name"];								// Cas general
938
-				if ($modulesubdir) $relativepath=$modulesubdir."/".$file["name"];	// Cas propal, facture...
1004
+				if ($modulesubdir) {
1005
+				    $relativepath=$modulesubdir."/".$file["name"];
1006
+				}
1007
+				// Cas propal, facture...
939 1008
 				// Autre cas
940 1009
 				if ($modulepart == 'donation')            {
941 1010
 					$relativepath = get_exdir($modulesubdir,2,0,0,null,'donation').$file["name"];
@@ -947,8 +1016,11 @@  discard block
 block discarded – undo
947 1016
 				$this->infofiles['nboffiles']++;
948 1017
 				$this->infofiles['files'][]=$file['fullname'];
949 1018
 				$ext=pathinfo($file["name"], PATHINFO_EXTENSION);
950
-				if (empty($this->infofiles[$ext])) $this->infofiles['extensions'][$ext]=1;
951
-				else $this->infofiles['extensions'][$ext]++;
1019
+				if (empty($this->infofiles[$ext])) {
1020
+				    $this->infofiles['extensions'][$ext]=1;
1021
+				} else {
1022
+				    $this->infofiles['extensions'][$ext]++;
1023
+				}
952 1024
 
953 1025
 				// Preview
954 1026
 				if (! empty($conf->use_javascript_ajax) && ($conf->browser->layout != 'phone'))
@@ -966,7 +1038,9 @@  discard block
 block discarded – undo
966 1038
 				// Download
967 1039
 				$tmpout.= '<li class="nowrap"><a class="pictopreview nowrap" href="'.DOL_URL_ROOT . '/document.php?modulepart='.$modulepart.'&amp;entity='.$entity.'&amp;file='.urlencode($relativepath).'"';
968 1040
 				$mime=dol_mimetype($relativepath,'',0);
969
-				if (preg_match('/text/',$mime)) $tmpout.= ' target="_blank"';
1041
+				if (preg_match('/text/',$mime)) {
1042
+				    $tmpout.= ' target="_blank"';
1043
+				}
970 1044
 				$tmpout.= '>';
971 1045
 				$tmpout.= img_mime($relativepath, $file["name"]);
972 1046
 				$tmpout.= $langs->trans("Download").' '.$ext;
@@ -976,9 +1050,10 @@  discard block
 block discarded – undo
976 1050
 			$out.='</ul></div></dd>
977 1051
     			</dl>';
978 1052
 
979
-			if (! $found) $out='';
980
-		}
981
-		else
1053
+			if (! $found) {
1054
+			    $out='';
1055
+			}
1056
+		} else
982 1057
 		{
983 1058
 			// TODO Add link to regenerate doc ?
984 1059
 			//$out.= '<div id="gen_pdf_'.$modulesubdir.'" class="linkobject hideobject">'.img_picto('', 'refresh').'</div>'."\n";
@@ -1027,14 +1102,21 @@  discard block
 block discarded – undo
1027 1102
 		global $form;
1028 1103
 
1029 1104
 		$disablecrop=1;
1030
-		if (in_array($modulepart, array('expensereport','holiday','member','project','product','produit','service','societe','tax','ticket','user'))) $disablecrop=0;
1105
+		if (in_array($modulepart, array('expensereport','holiday','member','project','product','produit','service','societe','tax','ticket','user'))) {
1106
+		    $disablecrop=0;
1107
+		}
1031 1108
 
1032 1109
 		// Define relative path used to store the file
1033 1110
 		if (empty($relativepath))
1034 1111
 		{
1035 1112
 			$relativepath=(! empty($object->ref)?dol_sanitizeFileName($object->ref):'').'/';
1036
-			if ($object->element == 'invoice_supplier') $relativepath=get_exdir($object->id,2,0,0,$object,'invoice_supplier').$relativepath;	// TODO Call using a defined value for $relativepath
1037
-			if ($object->element == 'project_task') $relativepath='Call_not_supported_._Call_function_using_a_defined_relative_path_.';
1113
+			if ($object->element == 'invoice_supplier') {
1114
+			    $relativepath=get_exdir($object->id,2,0,0,$object,'invoice_supplier').$relativepath;
1115
+			}
1116
+			// TODO Call using a defined value for $relativepath
1117
+			if ($object->element == 'project_task') {
1118
+			    $relativepath='Call_not_supported_._Call_function_using_a_defined_relative_path_.';
1119
+			}
1038 1120
 		}
1039 1121
 		// For backward compatiblity, we detect file stored into an old path
1040 1122
 		if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $filearray[0]['level1name'] == 'photos')
@@ -1066,11 +1148,12 @@  discard block
 block discarded – undo
1066 1148
 		);
1067 1149
 		$reshook=$hookmanager->executeHooks('showFilesList', $parameters, $object);
1068 1150
 
1069
-		if (isset($reshook) && $reshook != '') // null or '' for bypass
1151
+		if (isset($reshook) && $reshook != '') {
1152
+		    // null or '' for bypass
1070 1153
 		{
1071 1154
 			return $reshook;
1072 1155
 		}
1073
-		else
1156
+		} else
1074 1157
 		{
1075 1158
 			if (! is_object($form))
1076 1159
 			{
@@ -1078,17 +1161,27 @@  discard block
 block discarded – undo
1078 1161
 				$form=new Form($this->db);
1079 1162
 			}
1080 1163
 
1081
-			if (! preg_match('/&id=/', $param) && isset($object->id)) $param.='&id='.$object->id;
1164
+			if (! preg_match('/&id=/', $param) && isset($object->id)) {
1165
+			    $param.='&id='.$object->id;
1166
+			}
1082 1167
 			$relativepathwihtoutslashend=preg_replace('/\/$/', '', $relativepath);
1083
-			if ($relativepathwihtoutslashend) $param.= '&file='.urlencode($relativepathwihtoutslashend);
1168
+			if ($relativepathwihtoutslashend) {
1169
+			    $param.= '&file='.urlencode($relativepathwihtoutslashend);
1170
+			}
1084 1171
 
1085
-			if ($permtoeditline < 0)  // Old behaviour for backward compatibility. New feature should call method with value 0 or 1
1172
+			if ($permtoeditline < 0) {
1173
+			    // Old behaviour for backward compatibility. New feature should call method with value 0 or 1
1086 1174
 			{
1087 1175
 				$permtoeditline=0;
1176
+			}
1088 1177
 				if (in_array($modulepart, array('product','produit','service')))
1089 1178
 				{
1090
-					if ($user->rights->produit->creer && $object->type == Product::TYPE_PRODUCT) $permtoeditline=1;
1091
-					if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) $permtoeditline=1;
1179
+					if ($user->rights->produit->creer && $object->type == Product::TYPE_PRODUCT) {
1180
+					    $permtoeditline=1;
1181
+					}
1182
+					if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) {
1183
+					    $permtoeditline=1;
1184
+					}
1092 1185
 				}
1093 1186
 			}
1094 1187
 			if (empty($conf->global->MAIN_UPLOAD_DOC))
@@ -1098,8 +1191,12 @@  discard block
 block discarded – undo
1098 1191
 			}
1099 1192
 
1100 1193
 			// Show list of existing files
1101
-			if (empty($useinecm) && $title != 'none') print load_fiche_titre($title?$title:$langs->trans("AttachedFiles"));
1102
-			if (empty($url)) $url=$_SERVER["PHP_SELF"];
1194
+			if (empty($useinecm) && $title != 'none') {
1195
+			    print load_fiche_titre($title?$title:$langs->trans("AttachedFiles"));
1196
+			}
1197
+			if (empty($url)) {
1198
+			    $url=$_SERVER["PHP_SELF"];
1199
+			}
1103 1200
 
1104 1201
 			print '<!-- html.formfile::list_of_documents -->'."\n";
1105 1202
 			if (GETPOST('action','aZ09') == 'editfile' && $permtoeditline)
@@ -1119,10 +1216,14 @@  discard block
 block discarded – undo
1119 1216
 				print '<td><input type="search_doc_ref" value="'.dol_escape_htmltag(GETPOST('search_doc_ref','alpha')).'"></td>';
1120 1217
 				print '<td></td>';
1121 1218
 				print '<td></td>';
1122
-				if (empty($useinecm)) print '<td></td>';
1219
+				if (empty($useinecm)) {
1220
+				    print '<td></td>';
1221
+				}
1123 1222
 				print '<td></td>';
1124 1223
 				print '<td></td>';
1125
-				if (! $disablemove) print '<td></td>';
1224
+				if (! $disablemove) {
1225
+				    print '<td></td>';
1226
+				}
1126 1227
 				print "</tr>\n";
1127 1228
 			}
1128 1229
 
@@ -1131,10 +1232,15 @@  discard block
 block discarded – undo
1131 1232
 			print_liste_field_titre('Documents2',$url,"name","",$param,'align="left"',$sortfield,$sortorder);
1132 1233
 			print_liste_field_titre('Size',$url,"size","",$param,'align="right"',$sortfield,$sortorder);
1133 1234
 			print_liste_field_titre('Date',$url,"date","",$param,'align="center"',$sortfield,$sortorder);
1134
-			if (empty($useinecm)) print_liste_field_titre('',$url,"","",$param,'align="center"');					// Preview
1235
+			if (empty($useinecm)) {
1236
+			    print_liste_field_titre('',$url,"","",$param,'align="center"');
1237
+			}
1238
+			// Preview
1135 1239
 			print_liste_field_titre('');
1136 1240
 			print_liste_field_titre('');
1137
-			if (! $disablemove) print_liste_field_titre('');
1241
+			if (! $disablemove) {
1242
+			    print_liste_field_titre('');
1243
+			}
1138 1244
 			print "</tr>\n";
1139 1245
 
1140 1246
 			// Get list of files stored into database for same relative directory
@@ -1143,23 +1249,29 @@  discard block
 block discarded – undo
1143 1249
 				completeFileArrayWithDatabaseInfo($filearray, $relativedir);
1144 1250
 
1145 1251
 				//var_dump($sortfield.' - '.$sortorder);
1146
-				if ($sortfield && $sortorder)	// If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name)
1252
+				if ($sortfield && $sortorder) {
1253
+				    // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name)
1147 1254
 				{
1148 1255
 					$filearray=dol_sort_array($filearray, $sortfield, $sortorder);
1149 1256
 				}
1257
+				}
1150 1258
 			}
1151 1259
 
1152 1260
 			$nboffiles=count($filearray);
1153
-			if ($nboffiles > 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
1261
+			if ($nboffiles > 0) {
1262
+			    include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
1263
+			}
1154 1264
 
1155 1265
 			$i=0; $nboflines = 0; $lastrowid=0;
1156
-			foreach($filearray as $key => $file)      // filearray must be only files here
1266
+			foreach($filearray as $key => $file) {
1267
+			    // filearray must be only files here
1157 1268
 			{
1158 1269
 				if ($file['name'] != '.'
1159 1270
 						&& $file['name'] != '..'
1160 1271
 						&& ! preg_match('/\.meta$/i',$file['name']))
1161 1272
 				{
1162 1273
 					if ($filearray[$key]['rowid'] > 0) $lastrowid = $filearray[$key]['rowid'];
1274
+			}
1163 1275
 					$filepath=$relativepath.$file['name'];
1164 1276
 
1165 1277
 					$editline=0;
@@ -1175,12 +1287,18 @@  discard block
 block discarded – undo
1175 1287
 					// Show file name with link to download
1176 1288
 					//print "XX".$file['name'];	//$file['name'] must be utf8
1177 1289
 					print '<a class="paddingright" href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart;
1178
-					if ($forcedownload) print '&attachment=1';
1179
-					if (! empty($object->entity)) print '&entity='.$object->entity;
1290
+					if ($forcedownload) {
1291
+					    print '&attachment=1';
1292
+					}
1293
+					if (! empty($object->entity)) {
1294
+					    print '&entity='.$object->entity;
1295
+					}
1180 1296
 					print '&file='.urlencode($filepath);
1181 1297
 					print '">';
1182 1298
 					print img_mime($file['name'], $file['name'].' ('.dol_print_size($file['size'],0,0).')', 'inline-block valignbottom paddingright');
1183
-					if ($showrelpart == 1) print $relativepath;
1299
+					if ($showrelpart == 1) {
1300
+					    print $relativepath;
1301
+					}
1184 1302
 					//print dol_trunc($file['name'],$maxlength,'middle');
1185 1303
 					if (GETPOST('action','aZ09') == 'editfile' && $file['name'] == basename(GETPOST('urlfile','alpha')))
1186 1304
 					{
@@ -1190,14 +1308,15 @@  discard block
 block discarded – undo
1190 1308
 						print '<input type="hidden" name="renamefilefrom" value="'.dol_escape_htmltag($file['name']).'">';
1191 1309
 						print '<input type="text" name="renamefileto" class="quatrevingtpercent" value="'.dol_escape_htmltag($file['name']).'">';
1192 1310
 						$editline=1;
1193
-					}
1194
-					else
1311
+					} else
1195 1312
 					{
1196 1313
 						print dol_trunc($file['name'], 200);
1197 1314
 						print '</a>';
1198 1315
 					}
1199 1316
 					// Preview link
1200
-					if (! $editline) print $this->showPreview($file, $modulepart, $filepath);
1317
+					if (! $editline) {
1318
+					    print $this->showPreview($file, $modulepart, $filepath);
1319
+					}
1201 1320
 					// Public share link
1202 1321
 					//if (! $editline && ! empty($filearray[$key]['hashp'])) print pictowithlinktodirectdownload;
1203 1322
 
@@ -1208,8 +1327,9 @@  discard block
 block discarded – undo
1208 1327
 					$sizetoshowbytes = dol_print_size($file['size'],0,1);
1209 1328
 
1210 1329
 					print '<td align="right" width="80px">';
1211
-					if ($sizetoshow == $sizetoshowbytes) print $sizetoshow;
1212
-					else {
1330
+					if ($sizetoshow == $sizetoshowbytes) {
1331
+					    print $sizetoshow;
1332
+					} else {
1213 1333
 						print $form->textwithpicto($sizetoshow, $sizetoshowbytes, -1);
1214 1334
 					}
1215 1335
 					print '</td>';
@@ -1225,7 +1345,10 @@  discard block
 block discarded – undo
1225 1345
 						if (image_format_supported($file['name']) > 0)
1226 1346
 						{
1227 1347
 							$minifile=getImageFileNameForSize($file['name'], '_mini'); // For new thumbs using same ext (in lower case howerver) than original
1228
-							if (! dol_is_file($file['path'].'/'.$minifile)) $minifile=getImageFileNameForSize($file['name'], '_mini', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension
1348
+							if (! dol_is_file($file['path'].'/'.$minifile)) {
1349
+							    $minifile=getImageFileNameForSize($file['name'], '_mini', '.png');
1350
+							}
1351
+							// For backward compatibility of old thumbs that were created with filename in lower case and with .png extension
1229 1352
 							//print $file['path'].'/'.$minifile.'<br>';
1230 1353
 
1231 1354
 							$urlforhref=getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity)?$object->entity:$conf->entity));
@@ -1237,8 +1360,9 @@  discard block
 block discarded – undo
1237 1360
 							}
1238 1361
 							print '<img border="0" height="'.$maxheightmini.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity)?$object->entity:$conf->entity).'&file='.urlencode($relativepath.$minifile).'" title="">';
1239 1362
 							print '</a>';
1363
+						} else {
1364
+						    print '&nbsp;';
1240 1365
 						}
1241
-						else print '&nbsp;';
1242 1366
 						print '</td>';
1243 1367
 					}
1244 1368
 
@@ -1250,8 +1374,7 @@  discard block
 block discarded – undo
1250 1374
 						{
1251 1375
 							print $langs->trans("FileSharedViaALink").' ';
1252 1376
 							print '<input class="inline-block" type="checkbox" name="shareenabled"'.($file['share']?' checked="checked"':'').' /> ';
1253
-						}
1254
-						else
1377
+						} else
1255 1378
 						{
1256 1379
 							if ($file['share'])
1257 1380
 							{
@@ -1263,15 +1386,19 @@  discard block
 block discarded – undo
1263 1386
 								//print '<span class="opacitymedium">'.$langs->trans("Hash").' : '.$file['share'].'</span>';
1264 1387
 								$forcedownload=0;
1265 1388
 								$paramlink='';
1266
-								if (! empty($file['share'])) $paramlink.=($paramlink?'&':'').'hashp='.$file['share'];			// Hash for public share
1267
-								if ($forcedownload) $paramlink.=($paramlink?'&':'').'attachment=1';
1389
+								if (! empty($file['share'])) {
1390
+								    $paramlink.=($paramlink?'&':'').'hashp='.$file['share'];
1391
+								}
1392
+								// Hash for public share
1393
+								if ($forcedownload) {
1394
+								    $paramlink.=($paramlink?'&':'').'attachment=1';
1395
+								}
1268 1396
 
1269 1397
 								$fulllink=$urlwithroot.'/document.php'.($paramlink?'?'.$paramlink:'');
1270 1398
 
1271 1399
 								print img_picto($langs->trans("FileSharedViaALink"),'object_globe.png').' ';
1272 1400
 								print '<input type="text" class="quatrevingtpercent" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).'">';
1273
-							}
1274
-							else
1401
+							} else
1275 1402
 							{
1276 1403
 								//print '<span class="opacitymedium">'.$langs->trans("FileNotShared").'</span>';
1277 1404
 							}
@@ -1292,7 +1419,9 @@  discard block
 block discarded – undo
1292 1419
 						if (! $useinecm || $useinecm == 2)
1293 1420
 						{
1294 1421
 							$newmodulepart=$modulepart;
1295
-							if (in_array($modulepart, array('product','produit','service'))) $newmodulepart='produit|service';
1422
+							if (in_array($modulepart, array('product','produit','service'))) {
1423
+							    $newmodulepart='produit|service';
1424
+							}
1296 1425
 
1297 1426
 							if (! $disablecrop && image_format_supported($file['name']) > 0)
1298 1427
 							{
@@ -1312,9 +1441,15 @@  discard block
 block discarded – undo
1312 1441
 						if ($permonobject)
1313 1442
 						{
1314 1443
 							$useajax=1;
1315
-							if (! empty($conf->dol_use_jmobile)) $useajax=0;
1316
-							if (empty($conf->use_javascript_ajax)) $useajax=0;
1317
-							if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0;
1444
+							if (! empty($conf->dol_use_jmobile)) {
1445
+							    $useajax=0;
1446
+							}
1447
+							if (empty($conf->use_javascript_ajax)) {
1448
+							    $useajax=0;
1449
+							}
1450
+							if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) {
1451
+							    $useajax=0;
1452
+							}
1318 1453
 							print '<a href="'.(($useinecm && $useajax)?'#':($url.'?action=delete&urlfile='.urlencode($filepath).$param)).'" class="deletefilelink" rel="'.$filepath.'">'.img_delete().'</a>';
1319 1454
 						}
1320 1455
 						print "</td>";
@@ -1330,21 +1465,21 @@  discard block
 block discarded – undo
1330 1465
 									print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=down&amp;rowid='.$line->id.'">'.img_down('default',0,'imgdownforline').'</a>';
1331 1466
 								}
1332 1467
 								print '</td>';
1333
-							}
1334
-							else {
1468
+							} else {
1335 1469
 							   	print '<td align="center"'.(($conf->browser->layout != 'phone' && empty($disablemove)) ?' class="linecolmove tdlineupdown"':' class="linecolmove"').'>';
1336 1470
 							   	print '</td>';
1337 1471
 							}
1338 1472
 					   }
1339
-					}
1340
-					else
1473
+					} else
1341 1474
 					{
1342 1475
 						print '<td class="right">';
1343 1476
 						print '<input type="hidden" name="ecmfileid" value="'.$filearray[$key]['rowid'].'">';
1344 1477
 						print '<input type="submit" class="button" name="renamefilesave" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
1345 1478
 						print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
1346 1479
 						print '</td>';
1347
-						if (empty($disablemove)) print '<td class="right"></td>';
1480
+						if (empty($disablemove)) {
1481
+						    print '<td class="right"></td>';
1482
+						}
1348 1483
 					}
1349 1484
 					print "</tr>\n";
1350 1485
 
@@ -1354,10 +1489,16 @@  discard block
 block discarded – undo
1354 1489
 			if ($nboffiles == 0)
1355 1490
 			{
1356 1491
 				$colspan=(empty($useinecm)?'6':'6');
1357
-				if (empty($disablemove)) $colspan++;		// 6 columns or 7
1492
+				if (empty($disablemove)) {
1493
+				    $colspan++;
1494
+				}
1495
+				// 6 columns or 7
1358 1496
 				print '<tr class="oddeven"><td colspan="'.$colspan.'" class="opacitymedium">';
1359
-				if (empty($textifempty)) print $langs->trans("NoFileFound");
1360
-				else print $textifempty;
1497
+				if (empty($textifempty)) {
1498
+				    print $langs->trans("NoFileFound");
1499
+				} else {
1500
+				    print $textifempty;
1501
+				}
1361 1502
 				print '</td></tr>';
1362 1503
 			}
1363 1504
 			print "</table>";
@@ -1411,8 +1552,12 @@  discard block
 block discarded – undo
1411 1552
 		dol_syslog(get_class($this).'::list_of_autoecmfiles upload_dir='.$upload_dir.' modulepart='.$modulepart);
1412 1553
 
1413 1554
 		// Show list of documents
1414
-		if (empty($useinecm)) print load_fiche_titre($langs->trans("AttachedFiles"));
1415
-		if (empty($url)) $url=$_SERVER["PHP_SELF"];
1555
+		if (empty($useinecm)) {
1556
+		    print load_fiche_titre($langs->trans("AttachedFiles"));
1557
+		}
1558
+		if (empty($url)) {
1559
+		    $url=$_SERVER["PHP_SELF"];
1560
+		}
1416 1561
 
1417 1562
 		if (! empty($addfilterfields))
1418 1563
 		{
@@ -1440,7 +1585,9 @@  discard block
 block discarded – undo
1440 1585
 
1441 1586
 		print '<tr class="liste_titre">';
1442 1587
 		$sortref="fullname";
1443
-		if ($modulepart == 'invoice_supplier') $sortref='level1name';
1588
+		if ($modulepart == 'invoice_supplier') {
1589
+		    $sortref='level1name';
1590
+		}
1444 1591
 		print_liste_field_titre("Ref",$url,$sortref,"",$param,'align="left"',$sortfield,$sortorder);
1445 1592
 		print_liste_field_titre("Documents2",$url,"name","",$param,'align="left"',$sortfield,$sortorder);
1446 1593
 		print_liste_field_titre("Size",$url,"size","",$param,'align="right"',$sortfield,$sortorder);
@@ -1453,73 +1600,59 @@  discard block
 block discarded – undo
1453 1600
 		{
1454 1601
 			include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
1455 1602
 			$object_instance=new Societe($this->db);
1456
-		}
1457
-		else if ($modulepart == 'invoice')
1603
+		} else if ($modulepart == 'invoice')
1458 1604
 		{
1459 1605
 			include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
1460 1606
 			$object_instance=new Facture($this->db);
1461
-		}
1462
-		else if ($modulepart == 'invoice_supplier')
1607
+		} else if ($modulepart == 'invoice_supplier')
1463 1608
 		{
1464 1609
 			include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
1465 1610
 			$object_instance=new FactureFournisseur($this->db);
1466
-		}
1467
-		else if ($modulepart == 'propal')
1611
+		} else if ($modulepart == 'propal')
1468 1612
 		{
1469 1613
 			include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
1470 1614
 			$object_instance=new Propal($this->db);
1471
-		}
1472
-		else if ($modulepart == 'supplier_proposal')
1615
+		} else if ($modulepart == 'supplier_proposal')
1473 1616
 		{
1474 1617
 			include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
1475 1618
 			$object_instance=new SupplierProposal($this->db);
1476
-		}
1477
-		else if ($modulepart == 'order')
1619
+		} else if ($modulepart == 'order')
1478 1620
 		{
1479 1621
 			include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
1480 1622
 			$object_instance=new Commande($this->db);
1481
-		}
1482
-		else if ($modulepart == 'order_supplier')
1623
+		} else if ($modulepart == 'order_supplier')
1483 1624
 		{
1484 1625
 			include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
1485 1626
 			$object_instance=new CommandeFournisseur($this->db);
1486
-		}
1487
-		else if ($modulepart == 'contract')
1627
+		} else if ($modulepart == 'contract')
1488 1628
 		{
1489 1629
 			include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
1490 1630
 			$object_instance=new Contrat($this->db);
1491
-		}
1492
-		else if ($modulepart == 'product')
1631
+		} else if ($modulepart == 'product')
1493 1632
 		{
1494 1633
 			include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
1495 1634
 			$object_instance=new Product($this->db);
1496
-		}
1497
-		else if ($modulepart == 'tax')
1635
+		} else if ($modulepart == 'tax')
1498 1636
 		{
1499 1637
 			include_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
1500 1638
 			$object_instance=new ChargeSociales($this->db);
1501
-		}
1502
-		else if ($modulepart == 'project')
1639
+		} else if ($modulepart == 'project')
1503 1640
 		{
1504 1641
 			include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
1505 1642
 			$object_instance=new Project($this->db);
1506
-		}
1507
-		else if ($modulepart == 'fichinter')
1643
+		} else if ($modulepart == 'fichinter')
1508 1644
 		{
1509 1645
 			include_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
1510 1646
 			$object_instance=new Fichinter($this->db);
1511
-		}
1512
-		else if ($modulepart == 'user')
1647
+		} else if ($modulepart == 'user')
1513 1648
 		{
1514 1649
 			include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
1515 1650
 			$object_instance=new User($this->db);
1516
-		}
1517
-		else if ($modulepart == 'expensereport')
1651
+		} else if ($modulepart == 'expensereport')
1518 1652
 		{
1519 1653
 			include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
1520 1654
 			$object_instance=new ExpenseReport($this->db);
1521
-		}
1522
-		else if ($modulepart == 'holiday')
1655
+		} else if ($modulepart == 'holiday')
1523 1656
 		{
1524 1657
 			include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
1525 1658
 			$object_instance=new Holiday($this->db);
@@ -1556,13 +1689,14 @@  discard block
 block discarded – undo
1556 1689
 				if ($modulepart == 'expensereport')     { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg);  $ref=(isset($reg[1])?$reg[1]:'');}
1557 1690
 				if ($modulepart == 'holiday')           { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg);  $id=(isset($reg[1])?$reg[1]:'');}
1558 1691
 
1559
-				if (! $id && ! $ref) continue;
1692
+				if (! $id && ! $ref) {
1693
+				    continue;
1694
+				}
1560 1695
 				$found=0;
1561 1696
 				if (! empty($this->cache_objects[$modulepart.'_'.$id.'_'.$ref]))
1562 1697
 				{
1563 1698
 					$found=1;
1564
-				}
1565
-				else
1699
+				} else
1566 1700
 				{
1567 1701
 					//print 'Fetch '.$id." - ".$ref.'<br>';
1568 1702
 
@@ -1584,13 +1718,19 @@  discard block
 block discarded – undo
1584 1718
 					if ($result == 0) { $found=1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]='notfound'; unset($filearray[$key]); }
1585 1719
 				}
1586 1720
 
1587
-				if (! $found > 0 || ! is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) continue;    // We do not show orphelins files
1721
+				if (! $found > 0 || ! is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) {
1722
+				    continue;
1723
+				}
1724
+				// We do not show orphelins files
1588 1725
 
1589 1726
 				print '<!-- Line list_of_autoecmfiles '.$key.' -->'."\n";
1590 1727
 				print '<tr class="oddeven">';
1591 1728
 				print '<td>';
1592
-				if ($found > 0 && is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) print $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]->getNomUrl(1,'document');
1593
-				else print $langs->trans("ObjectDeleted",($id?$id:$ref));
1729
+				if ($found > 0 && is_object($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) {
1730
+				    print $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]->getNomUrl(1,'document');
1731
+				} else {
1732
+				    print $langs->trans("ObjectDeleted",($id?$id:$ref));
1733
+				}
1594 1734
 
1595 1735
 				//$modulesubdir=dol_sanitizeFileName($ref);
1596 1736
 				$modulesubdir=dirname($relativefile);
@@ -1606,7 +1746,9 @@  discard block
 block discarded – undo
1606 1746
 				print '<td>';
1607 1747
 				//print "XX".$file['name']; //$file['name'] must be utf8
1608 1748
 				print '<a href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart;
1609
-				if ($forcedownload) print '&attachment=1';
1749
+				if ($forcedownload) {
1750
+				    print '&attachment=1';
1751
+				}
1610 1752
 				print '&file='.urlencode($relativefile).'">';
1611 1753
 				print img_mime($file['name'],$file['name'].' ('.dol_print_size($file['size'],0,0).')');
1612 1754
 				print dol_trunc($file['name'],$maxlength,'middle');
@@ -1632,14 +1774,19 @@  discard block
 block discarded – undo
1632 1774
 		if (count($filearray) == 0)
1633 1775
 		{
1634 1776
 			print '<tr class="oddeven"><td colspan="5">';
1635
-			if (empty($textifempty)) print $langs->trans("NoFileFound");
1636
-			else print $textifempty;
1777
+			if (empty($textifempty)) {
1778
+			    print $langs->trans("NoFileFound");
1779
+			} else {
1780
+			    print $textifempty;
1781
+			}
1637 1782
 			print '</td></tr>';
1638 1783
 		}
1639 1784
 		print "</table>";
1640 1785
 		print '</div>';
1641 1786
 
1642
-		if (! empty($addfilterfields)) print '</form>';
1787
+		if (! empty($addfilterfields)) {
1788
+		    print '</form>';
1789
+		}
1643 1790
 		// Fin de zone
1644 1791
 	}
1645 1792
 
@@ -1750,7 +1897,9 @@  discard block
 block discarded – undo
1750 1897
 		print_liste_field_titre('','','');
1751 1898
 		print '</tr>';
1752 1899
 		$nboflinks = count($links);
1753
-		if ($nboflinks > 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
1900
+		if ($nboflinks > 0) {
1901
+		    include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
1902
+		}
1754 1903
 
1755 1904
 		foreach ($links as $link)
1756 1905
 		{
@@ -1773,8 +1922,7 @@  discard block
 block discarded – undo
1773 1922
 				print '<input type="submit" name="save" class="button" value="' . dol_escape_htmltag($langs->trans('Save')) . '">';
1774 1923
 				print '<input type="submit" name="cancel" class="button" value="' . dol_escape_htmltag($langs->trans('Cancel')) . '">';
1775 1924
 				print '</td>';
1776
-			}
1777
-			else
1925
+			} else
1778 1926
 			{
1779 1927
 				print '<td>';
1780 1928
 				print img_picto('', 'object_globe').' ';
@@ -1836,8 +1984,9 @@  discard block
 block discarded – undo
1836 1984
 				{
1837 1985
 					//$out.= img_picto($langs->trans('Preview').' '.$file['name'], 'detail');
1838 1986
 					$out.='<span class="fa fa-search-plus" style="color: gray"></span>';
1987
+				} else {
1988
+				    $out.= img_mime($relativepath, $langs->trans('Preview').' '.$file['name']);
1839 1989
 				}
1840
-				else $out.= img_mime($relativepath, $langs->trans('Preview').' '.$file['name']);
1841 1990
 				$out.= '</a>';
1842 1991
 			}
1843 1992
 		}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/class/html.formaccounting.class.php 1 patch
Braces   +17 added lines, -14 removed lines patch added patch discarded remove patch
@@ -82,8 +82,7 @@  discard block
 block discarded – undo
82 82
 		{
83 83
 		    $options = $this->options_cache[$usecache];
84 84
 		    $selected=$selectid;
85
-		}
86
-		else
85
+		} else
87 86
 		{
88 87
 			$sql = "SELECT rowid, code, label, nature, entity, active";
89 88
 			$sql.= " FROM " . MAIN_DB_PREFIX . "accounting_journal";
@@ -168,17 +167,20 @@  discard block
 block discarded – undo
168 167
             $sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c";
169 168
             $sql.= " WHERE c.active = 1";
170 169
 			$sql.= " AND c.category_type = 0";
171
-            if (empty($allcountries)) $sql.= " AND c.fk_country = ".$mysoc->country_id;
170
+            if (empty($allcountries)) {
171
+                $sql.= " AND c.fk_country = ".$mysoc->country_id;
172
+            }
172 173
             $sql.= " ORDER BY c.label ASC";
173
-        }
174
-        else
174
+        } else
175 175
         {
176 176
             $sql = "SELECT c.rowid, c.label as type, c.range_account";
177 177
             $sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c, ".MAIN_DB_PREFIX."c_country as co";
178 178
             $sql.= " WHERE c.active = 1";
179 179
 			$sql.= " AND c.category_type = 0";
180 180
 			$sql.= " AND c.fk_country = co.rowid";
181
-            if (empty($allcountries)) $sql.= " AND co.code = '".$mysoc->country_code."'";
181
+            if (empty($allcountries)) {
182
+                $sql.= " AND co.code = '".$mysoc->country_code."'";
183
+            }
182 184
             $sql.= " ORDER BY c.label ASC";
183 185
         }
184 186
 
@@ -192,25 +194,27 @@  discard block
 block discarded – undo
192 194
                 $out = '<select class="flat minwidth200" id="'.$htmlname.'" name="'.$htmlname.'">';
193 195
                 $i = 0;
194 196
 
195
-                if ($useempty) $out.= '<option value="0">&nbsp;</option>';
197
+                if ($useempty) {
198
+                    $out.= '<option value="0">&nbsp;</option>';
199
+                }
196 200
                 while ($i < $num)
197 201
                 {
198 202
                     $obj = $db->fetch_object($resql);
199 203
                     $out .= '<option value="'.$obj->rowid.'"';
200
-                    if ($obj->rowid == $selected) $out .= ' selected';
204
+                    if ($obj->rowid == $selected) {
205
+                        $out .= ' selected';
206
+                    }
201 207
                     $out .= '>'.($maxlen ? dol_trunc($obj->type,$maxlen) : $obj->type);
202 208
 					$out .= ' ('.$obj->range_account.')';
203 209
                     $i++;
204 210
                 }
205 211
                 $out .=  '</select>';
206 212
                 //if ($user->admin && $help) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
207
-            }
208
-            else
213
+            } else
209 214
             {
210 215
                 $out .= $langs->trans("ErrorNoAccountingCategoryForThisCountry",$mysoc->country_code);
211 216
             }
212
-        }
213
-        else
217
+        } else
214 218
         {
215 219
             dol_print_error($db,$db->lasterror());
216 220
         }
@@ -281,8 +285,7 @@  discard block
 block discarded – undo
281 285
 		{
282 286
 		    $options = $this->options_cache[$usecache];
283 287
 		    $selected=$selectid;
284
-		}
285
-		else
288
+		} else
286 289
 		{
287 290
     		$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT) ? 50 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT;
288 291
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/class/vcard.class.php 1 patch
Braces   +36 added lines, -12 removed lines patch added patch discarded remove patch
@@ -73,7 +73,9 @@  discard block
 block discarded – undo
73 73
             $newline .= $c;
74 74
         } // end of for
75 75
         $output .= $newline;
76
-        if ($j<count($lines)-1) $output .= $linebreak;
76
+        if ($j<count($lines)-1) {
77
+            $output .= $linebreak;
78
+        }
77 79
     }
78 80
     return trim($output);
79 81
 }
@@ -102,7 +104,9 @@  discard block
 block discarded – undo
102 104
     {
103 105
         // type may be PREF | WORK | HOME | VOICE | FAX | MSG | CELL | PAGER | BBS | CAR | MODEM | ISDN | VIDEO or any senseful combination, e.g. "PREF;WORK;VOICE"
104 106
         $key = "TEL";
105
-        if ($type!="") $key .= ";".$type;
107
+        if ($type!="") {
108
+            $key .= ";".$type;
109
+        }
106 110
         $key.= ";CHARSET=".$this->encoding;
107 111
         $this->properties[$key] = encode($number);
108 112
     }
@@ -146,7 +150,9 @@  discard block
 block discarded – undo
146 150
     {
147 151
         $this->properties["N;CHARSET=".$this->encoding] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix);
148 152
         $this->filename = "$first%20$family.vcf";
149
-        if (empty($this->properties["FN"])) $this->setFormattedName(trim("$prefix $first $additional $family $suffix"));
153
+        if (empty($this->properties["FN"])) {
154
+            $this->setFormattedName(trim("$prefix $first $additional $family $suffix"));
155
+        }
150 156
     }
151 157
 
152 158
     /**
@@ -178,7 +184,9 @@  discard block
 block discarded – undo
178 184
     {
179 185
         // $type may be DOM | INTL | POSTAL | PARCEL | HOME | WORK or any combination of these: e.g. "WORK;PARCEL;POSTAL"
180 186
         $key = "ADR";
181
-        if ($type!="") $key.= ";$type";
187
+        if ($type!="") {
188
+            $key.= ";$type";
189
+        }
182 190
         $key.= ";CHARSET=".$this->encoding;
183 191
         $this->properties[$key] = ";".encode($extended).";".encode($street).";".encode($city).";".encode($region).";".encode($zip).";".encode($country);
184 192
 
@@ -204,13 +212,27 @@  discard block
 block discarded – undo
204 212
     function setLabel($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="HOME;POSTAL")
205 213
     {
206 214
         $label = "";
207
-        if ($postoffice!="") $label.= "$postoffice\r\n";
208
-        if ($extended!="") $label.= "$extended\r\n";
209
-        if ($street!="") $label.= "$street\r\n";
210
-        if ($zip!="") $label.= "$zip ";
211
-        if ($city!="") $label.= "$city\r\n";
212
-        if ($region!="") $label.= "$region\r\n";
213
-        if ($country!="") $country.= "$country\r\n";
215
+        if ($postoffice!="") {
216
+            $label.= "$postoffice\r\n";
217
+        }
218
+        if ($extended!="") {
219
+            $label.= "$extended\r\n";
220
+        }
221
+        if ($street!="") {
222
+            $label.= "$street\r\n";
223
+        }
224
+        if ($zip!="") {
225
+            $label.= "$zip ";
226
+        }
227
+        if ($city!="") {
228
+            $label.= "$city\r\n";
229
+        }
230
+        if ($region!="") {
231
+            $label.= "$region\r\n";
232
+        }
233
+        if ($country!="") {
234
+            $country.= "$country\r\n";
235
+        }
214 236
 
215 237
         $this->properties["LABEL;$type;CHARSET=".$this->encoding] = encode($label);
216 238
     }
@@ -297,7 +319,9 @@  discard block
 block discarded – undo
297 319
     {
298 320
         // $type may be WORK | HOME
299 321
         $key = "URL";
300
-        if ($type!="") $key.= ";$type";
322
+        if ($type!="") {
323
+            $key.= ";$type";
324
+        }
301 325
         $this->properties[$key] = $url;
302 326
     }
303 327
 
Please login to merge, or discard this patch.