Passed
Branch develop (07a336)
by
unknown
39:19
created
htdocs/core/tpl/massactions_pre.tpl.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -41,14 +41,14 @@  discard block
 block discarded – undo
41 41
 {
42 42
 	require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
43 43
 	$categ = new Categorie($db);
44
-	$categ_types=array();
45
-	$categ_type_array=$categ->getMapList();
44
+	$categ_types = array();
45
+	$categ_type_array = $categ->getMapList();
46 46
 	foreach ($categ_type_array as $categdef) {
47
-		if (isset($object) && $categdef['obj_table']==$object->table_element) {
48
-			if (!array_key_exists($categdef['code'], $categ_types)) $categ_types[$categdef['code']] = array('code'=>$categdef['code'],'label'=>$langs->trans($categdef['obj_class']));
47
+		if (isset($object) && $categdef['obj_table'] == $object->table_element) {
48
+			if (!array_key_exists($categdef['code'], $categ_types)) $categ_types[$categdef['code']] = array('code'=>$categdef['code'], 'label'=>$langs->trans($categdef['obj_class']));
49 49
 		}
50
-		if (isset($objecttmp) && $categdef['obj_table']==$objecttmp->table_element) {
51
-			if (!array_key_exists($categdef['code'], $categ_types)) $categ_types[$categdef['code']] = array('code'=>$categdef['code'],'label'=>$langs->trans($categdef['obj_class']));
50
+		if (isset($objecttmp) && $categdef['obj_table'] == $objecttmp->table_element) {
51
+			if (!array_key_exists($categdef['code'], $categ_types)) $categ_types[$categdef['code']] = array('code'=>$categdef['code'], 'label'=>$langs->trans($categdef['obj_class']));
52 52
 		}
53 53
 	}
54 54
 
@@ -56,12 +56,12 @@  discard block
 block discarded – undo
56 56
 	if (!empty($categ_types)) {
57 57
 		foreach ($categ_types as $categ_type) {
58 58
 			$cate_arbo = $form->select_all_categories($categ_type['code'], null, 'parent', null, null, 1);
59
-			$formquestion[]=array('type' => 'other',
59
+			$formquestion[] = array('type' => 'other',
60 60
 					'name' => 'affecttag_'.$categ_type['code'],
61 61
 					'label' => $langs->trans("Tag").' '.$categ_type['label'],
62 62
 					'value' => $form->multiselectarray('contcats_'.$categ_type['code'], $cate_arbo, GETPOST('contcats_'.$categ_type['code'], 'array'), null, null, null, null, '60%'));
63 63
 		}
64
-		$formquestion[]=array('type' => 'other',
64
+		$formquestion[] = array('type' => 'other',
65 65
 				'name' => 'affecttag_type',
66 66
 				'label' => '',
67 67
 				'value' => '<input type="hidden" name="affecttag_type"  id="affecttag_type" value="'.implode(",", array_keys($categ_types)).'"/>');
Please login to merge, or discard this patch.
Braces   +18 added lines, -8 removed lines patch added patch discarded remove patch
@@ -45,10 +45,14 @@  discard block
 block discarded – undo
45 45
 	$categ_type_array=$categ->getMapList();
46 46
 	foreach ($categ_type_array as $categdef) {
47 47
 		if (isset($object) && $categdef['obj_table']==$object->table_element) {
48
-			if (!array_key_exists($categdef['code'], $categ_types)) $categ_types[$categdef['code']] = array('code'=>$categdef['code'],'label'=>$langs->trans($categdef['obj_class']));
48
+			if (!array_key_exists($categdef['code'], $categ_types)) {
49
+				$categ_types[$categdef['code']] = array('code'=>$categdef['code'],'label'=>$langs->trans($categdef['obj_class']));
50
+			}
49 51
 		}
50 52
 		if (isset($objecttmp) && $categdef['obj_table']==$objecttmp->table_element) {
51
-			if (!array_key_exists($categdef['code'], $categ_types)) $categ_types[$categdef['code']] = array('code'=>$categdef['code'],'label'=>$langs->trans($categdef['obj_class']));
53
+			if (!array_key_exists($categdef['code'], $categ_types)) {
54
+				$categ_types[$categdef['code']] = array('code'=>$categdef['code'],'label'=>$langs->trans($categdef['obj_class']));
55
+			}
52 56
 		}
53 57
 	}
54 58
 
@@ -87,10 +91,12 @@  discard block
 block discarded – undo
87 91
 			{
88 92
 				$listofselectedid[$toselectid] = $toselectid;
89 93
 				$thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
90
-				if ($objecttmp->element == 'societe')
91
-					$thirdpartyid = $objecttmp->id;
92
-				if ($objecttmp->element == 'expensereport')
93
-					$thirdpartyid = $objecttmp->fk_user_author;
94
+				if ($objecttmp->element == 'societe') {
95
+									$thirdpartyid = $objecttmp->id;
96
+				}
97
+				if ($objecttmp->element == 'expensereport') {
98
+									$thirdpartyid = $objecttmp->fk_user_author;
99
+				}
94 100
 				$listofselectedthirdparties[$thirdpartyid] = $thirdpartyid;
95 101
 				$listofselectedref[$thirdpartyid][$toselectid] = $objecttmp->ref;
96 102
 			}
@@ -115,16 +121,20 @@  discard block
 block discarded – undo
115 121
 		$formmail->fromid = $user->id;
116 122
 	}
117 123
 	$formmail->trackid = $trackid;
118
-	if (!empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set
124
+	if (!empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) {
125
+		// If bit 2 is set
119 126
 	{
120 127
 		include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
128
+	}
121 129
 		$formmail->frommail = dolAddEmailTrackId($formmail->frommail, $trackid);
122 130
 	}
123 131
 	$formmail->withfrom = 1;
124 132
 	$liste = $langs->trans("AllRecipientSelected", count($arrayofselected));
125
-	if (count($listofselectedthirdparties) == 1) // Only 1 different recipient selected, we can suggest contacts
133
+	if (count($listofselectedthirdparties) == 1) {
134
+		// Only 1 different recipient selected, we can suggest contacts
126 135
 	{
127 136
 		$liste = array();
137
+	}
128 138
 		$thirdpartyid = array_shift($listofselectedthirdparties);
129 139
 		if ($objecttmp->element == 'expensereport')
130 140
 		{
Please login to merge, or discard this patch.
htdocs/core/actions_massactions.inc.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1294,9 +1294,9 @@  discard block
 block discarded – undo
1294 1294
 if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd) {
1295 1295
 	$db->begin();
1296 1296
 
1297
-	$affecttag_type=GETPOST('affecttag_type', 'alpha');
1297
+	$affecttag_type = GETPOST('affecttag_type', 'alpha');
1298 1298
 	if (!empty($affecttag_type)) {
1299
-		$affecttag_type_array=explode(',', $affecttag_type);
1299
+		$affecttag_type_array = explode(',', $affecttag_type);
1300 1300
 	} else {
1301 1301
 		setEventMessage('CategTypeNotFound', 'errors');
1302 1302
 	}
@@ -1304,10 +1304,10 @@  discard block
 block discarded – undo
1304 1304
 		//check if tag type submited exists into Tag Map categorie class
1305 1305
 		require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1306 1306
 		$categ = new Categorie($db);
1307
-		$to_affecttag_type_array=array();
1308
-		$categ_type_array=$categ->getMapList();
1307
+		$to_affecttag_type_array = array();
1308
+		$categ_type_array = $categ->getMapList();
1309 1309
 		foreach ($categ_type_array as $categdef) {
1310
-			if (in_array($categdef['code'],  $affecttag_type_array)) {
1310
+			if (in_array($categdef['code'], $affecttag_type_array)) {
1311 1311
 				$to_affecttag_type_array[] = $categdef['code'];
1312 1312
 			}
1313 1313
 		}
@@ -1316,7 +1316,7 @@  discard block
 block discarded – undo
1316 1316
 		$nbok = 0;
1317 1317
 		if (!empty($to_affecttag_type_array)) {
1318 1318
 			foreach ($to_affecttag_type_array as $categ_type) {
1319
-				$contcats = GETPOST('contcats_' . $categ_type, 'array');
1319
+				$contcats = GETPOST('contcats_'.$categ_type, 'array');
1320 1320
 				//var_dump($toselect);exit;
1321 1321
 				foreach ($toselect as $toselectid) {
1322 1322
 					$result = $object->fetch($toselectid);
@@ -1343,7 +1343,7 @@  discard block
 block discarded – undo
1343 1343
 		if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null);
1344 1344
 		else setEventMessages($langs->trans("RecordsModified", $nbok), null);
1345 1345
 		$db->commit();
1346
-		$toselect=array();
1346
+		$toselect = array();
1347 1347
 	} else {
1348 1348
 		$db->rollback();
1349 1349
 	}
Please login to merge, or discard this patch.
Braces   +380 added lines, -133 removed lines patch added patch discarded remove patch
@@ -44,9 +44,15 @@  discard block
 block discarded – undo
44 44
 }
45 45
 
46 46
 // For backward compatibility
47
-if (!empty($permtoread) && empty($permissiontoread)) $permissiontoread = $permtoread;
48
-if (!empty($permtocreate) && empty($permissiontoadd)) $permissiontoadd = $permtocreate;
49
-if (!empty($permtodelete) && empty($permissiontodelete)) $permissiontodelete = $permtodelete;
47
+if (!empty($permtoread) && empty($permissiontoread)) {
48
+	$permissiontoread = $permtoread;
49
+}
50
+if (!empty($permtocreate) && empty($permissiontoadd)) {
51
+	$permissiontoadd = $permtocreate;
52
+}
53
+if (!empty($permtodelete) && empty($permissiontodelete)) {
54
+	$permissiontodelete = $permtodelete;
55
+}
50 56
 
51 57
 
52 58
 // Mass actions. Controls on number of lines checked.
@@ -62,10 +68,12 @@  discard block
 block discarded – undo
62 68
 	$error++;
63 69
 }
64 70
 
65
-if (!$error && $massaction == 'confirm_presend' && !GETPOST('sendmail'))  // If we do not choose button send (for example when we change template or limit), we must not send email, but keep on send email form
71
+if (!$error && $massaction == 'confirm_presend' && !GETPOST('sendmail')) {
72
+	// If we do not choose button send (for example when we change template or limit), we must not send email, but keep on send email form
66 73
 {
67 74
 	$massaction = 'presend';
68 75
 }
76
+}
69 77
 if (!$error && $massaction == 'confirm_presend')
70 78
 {
71 79
 	$resaction = '';
@@ -87,8 +95,12 @@  discard block
 block discarded – undo
87 95
 		$thirdparty = new Societe($db);
88 96
 
89 97
 		$objecttmp = new $objectclass($db);
90
-		if ($objecttmp->element == 'expensereport') $thirdparty = new User($db);
91
-		if ($objecttmp->element == 'holiday')       $thirdparty = new User($db);
98
+		if ($objecttmp->element == 'expensereport') {
99
+			$thirdparty = new User($db);
100
+		}
101
+		if ($objecttmp->element == 'holiday') {
102
+			$thirdparty = new User($db);
103
+		}
92 104
 
93 105
 		foreach ($toselect as $toselectid)
94 106
 		{
@@ -99,10 +111,18 @@  discard block
 block discarded – undo
99 111
 				$listofobjectid[$toselectid] = $toselectid;
100 112
 
101 113
 				$thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
102
-				if ($objecttmp->element == 'societe') $thirdpartyid = $objecttmp->id;
103
-				if ($objecttmp->element == 'expensereport') $thirdpartyid = $objecttmp->fk_user_author;
104
-				if ($objecttmp->element == 'holiday')       $thirdpartyid = $objecttmp->fk_user;
105
-				if (empty($thirdpartyid)) $thirdpartyid = 0;
114
+				if ($objecttmp->element == 'societe') {
115
+					$thirdpartyid = $objecttmp->id;
116
+				}
117
+				if ($objecttmp->element == 'expensereport') {
118
+					$thirdpartyid = $objecttmp->fk_user_author;
119
+				}
120
+				if ($objecttmp->element == 'holiday') {
121
+					$thirdpartyid = $objecttmp->fk_user;
122
+				}
123
+				if (empty($thirdpartyid)) {
124
+					$thirdpartyid = 0;
125
+				}
106 126
 
107 127
 				if ($objectclass == 'Facture') {
108 128
 					$tmparraycontact = array();
@@ -131,12 +151,17 @@  discard block
 block discarded – undo
131 151
 	$receiver = $_POST['receiver'];
132 152
 	if (!is_array($receiver))
133 153
 	{
134
-		if (empty($receiver) || $receiver == '-1') $receiver = array();
135
-		else $receiver = array($receiver);
154
+		if (empty($receiver) || $receiver == '-1') {
155
+			$receiver = array();
156
+		} else {
157
+			$receiver = array($receiver);
158
+		}
136 159
 	}
137
-	if (!trim($_POST['sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1)	// if only one recipient, receiver is mandatory
160
+	if (!trim($_POST['sendto']) && count($receiver) == 0 && count($listofobjectthirdparties) == 1) {
161
+		// if only one recipient, receiver is mandatory
138 162
 	{
139 163
 	 	$error++;
164
+	}
140 165
 	   	setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Recipient")), null, 'warnings');
141 166
 	   	$massaction = 'presend';
142 167
 	}
@@ -177,12 +202,16 @@  discard block
 block discarded – undo
177 202
 				foreach ($receiver as $key=>$val)
178 203
 				{
179 204
 					// Recipient was provided from combo list
180
-					if ($val == 'thirdparty') // Id of third party or user
205
+					if ($val == 'thirdparty') {
206
+						// Id of third party or user
181 207
 					{
182 208
 						$tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>';
183
-					} elseif ($val && method_exists($thirdparty, 'contact_get_property'))		// Id of contact
209
+					}
210
+					} elseif ($val && method_exists($thirdparty, 'contact_get_property')) {
211
+						// Id of contact
184 212
 					{
185 213
 						$tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
214
+					}
186 215
 						$sendtoid[] = $val;
187 216
 					}
188 217
 				}
@@ -193,8 +222,11 @@  discard block
 block discarded – undo
193 222
 			$receivercc = $_POST['receivercc'];
194 223
 			if (!is_array($receivercc))
195 224
 			{
196
-				if ($receivercc == '-1') $receivercc = array();
197
-				else $receivercc = array($receivercc);
225
+				if ($receivercc == '-1') {
226
+					$receivercc = array();
227
+				} else {
228
+					$receivercc = array($receivercc);
229
+				}
198 230
 			}
199 231
 			$tmparray = array();
200 232
 			if (trim($_POST['sendtocc']))
@@ -206,12 +238,16 @@  discard block
 block discarded – undo
206 238
 				foreach ($receivercc as $key=>$val)
207 239
 				{
208 240
 					// Recipient was provided from combo list
209
-					if ($val == 'thirdparty') // Id of third party
241
+					if ($val == 'thirdparty') {
242
+						// Id of third party
210 243
 					{
211 244
 						$tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>';
212
-					} elseif ($val)	// Id du contact
245
+					}
246
+					} elseif ($val) {
247
+						// Id du contact
213 248
 					{
214 249
 						$tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
250
+					}
215 251
 						//$sendtoid[] = $val;  TODO Add also id of contact in CC ?
216 252
 					}
217 253
 				}
@@ -249,11 +285,13 @@  discard block
 block discarded – undo
249 285
 				}
250 286
 
251 287
 				// Test recipient
252
-				if (empty($sendto)) 	// For the case, no recipient were set (multi thirdparties send)
288
+				if (empty($sendto)) {
289
+					// For the case, no recipient were set (multi thirdparties send)
253 290
 				{
254 291
 					if ($objectobj->element == 'societe')
255 292
 					{
256 293
 						$sendto = $objectobj->email;
294
+				}
257 295
 					} elseif ($objectobj->element == 'expensereport')
258 296
 					{
259 297
 						$fuser = new User($db);
@@ -380,13 +418,27 @@  discard block
 block discarded – undo
380 418
 				$message = GETPOST('message', 'restricthtml');
381 419
 
382 420
 				$sendtobcc = GETPOST('sendtoccc');
383
-				if ($objectclass == 'Propal') 				$sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO));
384
-				if ($objectclass == 'Commande') 			$sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO));
385
-				if ($objectclass == 'Facture') 				$sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO));
386
-				if ($objectclass == 'Supplier_Proposal') 	$sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO));
387
-				if ($objectclass == 'CommandeFournisseur')	$sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO));
388
-				if ($objectclass == 'FactureFournisseur')	$sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO));
389
-				if ($objectclass == 'Project') 			    $sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO));
421
+				if ($objectclass == 'Propal') {
422
+					$sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO));
423
+				}
424
+				if ($objectclass == 'Commande') {
425
+					$sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO));
426
+				}
427
+				if ($objectclass == 'Facture') {
428
+					$sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO));
429
+				}
430
+				if ($objectclass == 'Supplier_Proposal') {
431
+					$sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO));
432
+				}
433
+				if ($objectclass == 'CommandeFournisseur') {
434
+					$sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO));
435
+				}
436
+				if ($objectclass == 'FactureFournisseur') {
437
+					$sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO));
438
+				}
439
+				if ($objectclass == 'Project') {
440
+					$sendtobcc .= (empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) ? '' : (($sendtobcc ? ", " : "").$conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO));
441
+				}
390 442
 
391 443
 				// $listofqualifiedobj is array with key = object id and value is instance of qualified objects, for the current thirdparty (but thirdparty property is not loaded yet)
392 444
 				// $looparray will be an array with number of email to send for the current thirdparty (so 1 or n if n object for same thirdparty)
@@ -406,12 +458,14 @@  discard block
 block discarded – undo
406 458
 				//var_dump($looparray);exit;
407 459
 				dol_syslog("We have set an array of ".count($looparray)." emails to send. oneemailperrecipient=".$oneemailperrecipient);
408 460
 				//var_dump($oneemailperrecipient); var_dump($listofqualifiedobj); var_dump($listofqualifiedref);
409
-				foreach ($looparray as $objectid => $objecttmp)		// $objecttmp is a real object or an empty object if we choose to send one email per thirdparty instead of one per object
461
+				foreach ($looparray as $objectid => $objecttmp) {
462
+					// $objecttmp is a real object or an empty object if we choose to send one email per thirdparty instead of one per object
410 463
 				{
411 464
 					// Make substitution in email content
412 465
 					if (!empty($conf->projet->enabled) && method_exists($objecttmp, 'fetch_projet') && is_null($objecttmp->project))
413 466
 					{
414 467
 						$objecttmp->fetch_projet();
468
+				}
415 469
 					}
416 470
 					$substitutionarray = getCommonSubstitutionArray($langs, 0, null, $objecttmp);
417 471
 					$substitutionarray['__ID__']    = ($oneemailperrecipient ? join(', ', array_keys($listofqualifiedobj)) : $objecttmp->id);
@@ -462,17 +516,35 @@  discard block
 block discarded – undo
462 516
 					if ($oneemailperrecipient)
463 517
 					{
464 518
 						$trackid = 'thi'.$thirdparty->id;
465
-						if ($objecttmp->element == 'expensereport') $trackid = 'use'.$thirdparty->id;
466
-						if ($objecttmp->element == 'holiday') $trackid = 'use'.$thirdparty->id;
519
+						if ($objecttmp->element == 'expensereport') {
520
+							$trackid = 'use'.$thirdparty->id;
521
+						}
522
+						if ($objecttmp->element == 'holiday') {
523
+							$trackid = 'use'.$thirdparty->id;
524
+						}
467 525
 					} else {
468 526
 						$trackid = strtolower(get_class($objecttmp));
469
-						if (get_class($objecttmp) == 'Contrat')  $trackid = 'con';
470
-						if (get_class($objecttmp) == 'Propal')   $trackid = 'pro';
471
-						if (get_class($objecttmp) == 'Commande') $trackid = 'ord';
472
-						if (get_class($objecttmp) == 'Facture')  $trackid = 'inv';
473
-						if (get_class($objecttmp) == 'Supplier_Proposal')   $trackid = 'spr';
474
-						if (get_class($objecttmp) == 'CommandeFournisseur') $trackid = 'sor';
475
-						if (get_class($objecttmp) == 'FactureFournisseur')  $trackid = 'sin';
527
+						if (get_class($objecttmp) == 'Contrat') {
528
+							$trackid = 'con';
529
+						}
530
+						if (get_class($objecttmp) == 'Propal') {
531
+							$trackid = 'pro';
532
+						}
533
+						if (get_class($objecttmp) == 'Commande') {
534
+							$trackid = 'ord';
535
+						}
536
+						if (get_class($objecttmp) == 'Facture') {
537
+							$trackid = 'inv';
538
+						}
539
+						if (get_class($objecttmp) == 'Supplier_Proposal') {
540
+							$trackid = 'spr';
541
+						}
542
+						if (get_class($objecttmp) == 'CommandeFournisseur') {
543
+							$trackid = 'sor';
544
+						}
545
+						if (get_class($objecttmp) == 'FactureFournisseur') {
546
+							$trackid = 'sin';
547
+						}
476 548
 
477 549
 						$trackid .= $objecttmp->id;
478 550
 					}
@@ -480,7 +552,9 @@  discard block
 block discarded – undo
480 552
 					//var_dump($trackid);exit;
481 553
 					//var_dump($subjectreplaced);
482 554
 
483
-					if (empty($sendcontext)) $sendcontext = 'standard';
555
+					if (empty($sendcontext)) {
556
+						$sendcontext = 'standard';
557
+					}
484 558
 
485 559
 					// Send mail (substitutionarray must be done just before this)
486 560
 					require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
@@ -499,7 +573,10 @@  discard block
 block discarded – undo
499 573
 							// Insert logs into agenda
500 574
 							foreach ($listofqualifiedobj as $objid2 => $objectobj2)
501 575
 							{
502
-								if ((!$oneemailperrecipient) && $objid2 != $objectid) continue; // We discard this pass to avoid duplicate with other pass in looparray at higher level
576
+								if ((!$oneemailperrecipient) && $objid2 != $objectid) {
577
+									continue;
578
+								}
579
+								// We discard this pass to avoid duplicate with other pass in looparray at higher level
503 580
 
504 581
 								dol_syslog("Try to insert email event into agenda for objid=".$objid2." => objectobj=".get_class($objectobj2));
505 582
 
@@ -513,7 +590,9 @@  discard block
 block discarded – undo
513 590
 								$actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto;
514 591
 								if ($message)
515 592
 								{
516
-									if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc);
593
+									if ($sendtocc) {
594
+										$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc);
595
+									}
517 596
 									$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subjectreplaced);
518 597
 									$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":");
519 598
 									$actionmsg = dol_concatdesc($actionmsg, $messagereplaced);
@@ -528,20 +607,38 @@  discard block
 block discarded – undo
528 607
 								$objectobj2->elementtype	= $objectobj2->element;
529 608
 
530 609
 								$triggername = strtoupper(get_class($objectobj2)).'_SENTBYMAIL';
531
-								if ($triggername == 'SOCIETE_SENTBYMAIL')    $triggername = 'COMPANY_SENTBYMAIL';
532
-								if ($triggername == 'CONTRAT_SENTBYMAIL')    $triggername = 'CONTRACT_SENTBYMAIL';
533
-								if ($triggername == 'COMMANDE_SENTBYMAIL')   $triggername = 'ORDER_SENTBYMAIL';
534
-								if ($triggername == 'FACTURE_SENTBYMAIL')    $triggername = 'BILL_SENTBYMAIL';
535
-								if ($triggername == 'EXPEDITION_SENTBYMAIL') $triggername = 'SHIPPING_SENTBYMAIL';
536
-								if ($triggername == 'COMMANDEFOURNISSEUR_SENTBYMAIL') $triggername = 'ORDER_SUPPLIER_SENTBYMAIL';
537
-								if ($triggername == 'FACTUREFOURNISSEUR_SENTBYMAIL') $triggername = 'BILL_SUPPLIER_SENTBYMAIL';
538
-								if ($triggername == 'SUPPLIERPROPOSAL_SENTBYMAIL') $triggername = 'PROPOSAL_SUPPLIER_SENTBYMAIL';
610
+								if ($triggername == 'SOCIETE_SENTBYMAIL') {
611
+									$triggername = 'COMPANY_SENTBYMAIL';
612
+								}
613
+								if ($triggername == 'CONTRAT_SENTBYMAIL') {
614
+									$triggername = 'CONTRACT_SENTBYMAIL';
615
+								}
616
+								if ($triggername == 'COMMANDE_SENTBYMAIL') {
617
+									$triggername = 'ORDER_SENTBYMAIL';
618
+								}
619
+								if ($triggername == 'FACTURE_SENTBYMAIL') {
620
+									$triggername = 'BILL_SENTBYMAIL';
621
+								}
622
+								if ($triggername == 'EXPEDITION_SENTBYMAIL') {
623
+									$triggername = 'SHIPPING_SENTBYMAIL';
624
+								}
625
+								if ($triggername == 'COMMANDEFOURNISSEUR_SENTBYMAIL') {
626
+									$triggername = 'ORDER_SUPPLIER_SENTBYMAIL';
627
+								}
628
+								if ($triggername == 'FACTUREFOURNISSEUR_SENTBYMAIL') {
629
+									$triggername = 'BILL_SUPPLIER_SENTBYMAIL';
630
+								}
631
+								if ($triggername == 'SUPPLIERPROPOSAL_SENTBYMAIL') {
632
+									$triggername = 'PROPOSAL_SUPPLIER_SENTBYMAIL';
633
+								}
539 634
 
540 635
 								if (!empty($triggername))
541 636
 								{
542 637
 									// Call trigger
543 638
 									$result = $objectobj2->call_trigger($triggername, $user);
544
-									if ($result < 0) $error++;
639
+									if ($result < 0) {
640
+										$error++;
641
+									}
545 642
 									// End call triggers
546 643
 
547 644
 									if ($error)
@@ -590,9 +687,11 @@  discard block
 block discarded – undo
590 687
 	}
591 688
 }
592 689
 
593
-if ($massaction == 'confirm_createbills')   // Create bills from orders
690
+if ($massaction == 'confirm_createbills') {
691
+	// Create bills from orders
594 692
 {
595 693
 	$orders = GETPOST('toselect', 'array');
694
+}
596 695
 	$createbills_onebythird = GETPOST('createbills_onebythird', 'int');
597 696
 	$validate_invoices = GETPOST('validate_invoices', 'int');
598 697
 
@@ -606,10 +705,15 @@  discard block
 block discarded – undo
606 705
 	foreach ($orders as $id_order)
607 706
 	{
608 707
 		$cmd = new Commande($db);
609
-		if ($cmd->fetch($id_order) <= 0) continue;
708
+		if ($cmd->fetch($id_order) <= 0) {
709
+			continue;
710
+		}
610 711
 
611 712
 		$objecttmp = new Facture($db);
612
-		if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $objecttmp = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order.
713
+		if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) {
714
+			$objecttmp = $TFactThird[$cmd->socid];
715
+		}
716
+		// If option "one bill per third" is set, we use already created order.
613 717
 		else {
614 718
 			// Load extrafields of order
615 719
 			$cmd->fetch_optionals();
@@ -620,7 +724,9 @@  discard block
 block discarded – undo
620 724
 			$objecttmp->mode_reglement_id	= $cmd->mode_reglement_id;
621 725
 			$objecttmp->fk_project = $cmd->fk_project;
622 726
 			$objecttmp->multicurrency_code = $cmd->multicurrency_code;
623
-			if (empty($createbills_onebythird)) $objecttmp->ref_client = $cmd->ref_client;
727
+			if (empty($createbills_onebythird)) {
728
+				$objecttmp->ref_client = $cmd->ref_client;
729
+			}
624 730
 
625 731
 			$datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
626 732
 			if (empty($datefacture))
@@ -636,7 +742,9 @@  discard block
 block discarded – undo
636 742
 
637 743
 			$res = $objecttmp->create($user);
638 744
 
639
-			if ($res > 0) $nb_bills_created++;
745
+			if ($res > 0) {
746
+				$nb_bills_created++;
747
+			}
640 748
 		}
641 749
 
642 750
 		if ($objecttmp->id > 0)
@@ -705,14 +813,26 @@  discard block
 block discarded – undo
705 813
 						$product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
706 814
 						// Date start
707 815
 						$date_start = false;
708
-						if ($lines[$i]->date_debut_prevue) $date_start = $lines[$i]->date_debut_prevue;
709
-						if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel;
710
-						if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start;
816
+						if ($lines[$i]->date_debut_prevue) {
817
+							$date_start = $lines[$i]->date_debut_prevue;
818
+						}
819
+						if ($lines[$i]->date_debut_reel) {
820
+							$date_start = $lines[$i]->date_debut_reel;
821
+						}
822
+						if ($lines[$i]->date_start) {
823
+							$date_start = $lines[$i]->date_start;
824
+						}
711 825
 						//Date end
712 826
 						$date_end = false;
713
-						if ($lines[$i]->date_fin_prevue) $date_end = $lines[$i]->date_fin_prevue;
714
-						if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel;
715
-						if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end;
827
+						if ($lines[$i]->date_fin_prevue) {
828
+							$date_end = $lines[$i]->date_fin_prevue;
829
+						}
830
+						if ($lines[$i]->date_fin_reel) {
831
+							$date_end = $lines[$i]->date_fin_reel;
832
+						}
833
+						if ($lines[$i]->date_end) {
834
+							$date_end = $lines[$i]->date_end;
835
+						}
716 836
 						// Reset fk_parent_line for no child products and special product
717 837
 						if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9)
718 838
 						{
@@ -775,8 +895,11 @@  discard block
 block discarded – undo
775 895
 
776 896
 		//$cmd->classifyBilled($user);        // Disabled. This behavior must be set or not using the workflow module.
777 897
 
778
-		if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $objecttmp;
779
-		else $TFact[$objecttmp->id] = $objecttmp;
898
+		if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) {
899
+			$TFactThird[$cmd->socid] = $objecttmp;
900
+		} else {
901
+			$TFact[$objecttmp->id] = $objecttmp;
902
+		}
780 903
 	}
781 904
 
782 905
 	// Build doc with all invoices
@@ -822,29 +945,75 @@  discard block
 block discarded – undo
822 945
 
823 946
 		// Make a redirect to avoid to bill twice if we make a refresh or back
824 947
 		$param = '';
825
-		if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
826
-		if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
827
-		if ($sall)					$param .= '&sall='.urlencode($sall);
828
-		if ($socid > 0)             $param .= '&socid='.urlencode($socid);
829
-		if ($search_status != '')      $param .= '&search_status='.urlencode($search_status);
830
-		if ($search_orderday)      		$param .= '&search_orderday='.urlencode($search_orderday);
831
-		if ($search_ordermonth)      		$param .= '&search_ordermonth='.urlencode($search_ordermonth);
832
-		if ($search_orderyear)       		$param .= '&search_orderyear='.urlencode($search_orderyear);
833
-		if ($search_deliveryday)   		$param .= '&search_deliveryday='.urlencode($search_deliveryday);
834
-		if ($search_deliverymonth)   		$param .= '&search_deliverymonth='.urlencode($search_deliverymonth);
835
-		if ($search_deliveryyear)    		$param .= '&search_deliveryyear='.urlencode($search_deliveryyear);
836
-		if ($search_ref)      		$param .= '&search_ref='.urlencode($search_ref);
837
-		if ($search_company)  		$param .= '&search_company='.urlencode($search_company);
838
-		if ($search_ref_customer)	$param .= '&search_ref_customer='.urlencode($search_ref_customer);
839
-		if ($search_user > 0) 		$param .= '&search_user='.urlencode($search_user);
840
-		if ($search_sale > 0) 		$param .= '&search_sale='.urlencode($search_sale);
841
-		if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht);
842
-		if ($search_total_vat != '') $param .= '&search_total_vat='.urlencode($search_total_vat);
843
-		if ($search_total_ttc != '') $param .= '&search_total_ttc='.urlencode($search_total_ttc);
844
-		if ($search_project_ref >= 0)  	$param .= "&search_project_ref=".urlencode($search_project_ref);
845
-		if ($show_files)            $param .= '&show_files='.urlencode($show_files);
846
-		if ($optioncss != '')       $param .= '&optioncss='.urlencode($optioncss);
847
-		if ($billed != '')			$param .= '&billed='.urlencode($billed);
948
+		if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
949
+			$param .= '&contextpage='.urlencode($contextpage);
950
+		}
951
+		if ($limit > 0 && $limit != $conf->liste_limit) {
952
+			$param .= '&limit='.urlencode($limit);
953
+		}
954
+		if ($sall) {
955
+			$param .= '&sall='.urlencode($sall);
956
+		}
957
+		if ($socid > 0) {
958
+			$param .= '&socid='.urlencode($socid);
959
+		}
960
+		if ($search_status != '') {
961
+			$param .= '&search_status='.urlencode($search_status);
962
+		}
963
+		if ($search_orderday) {
964
+			$param .= '&search_orderday='.urlencode($search_orderday);
965
+		}
966
+		if ($search_ordermonth) {
967
+			$param .= '&search_ordermonth='.urlencode($search_ordermonth);
968
+		}
969
+		if ($search_orderyear) {
970
+			$param .= '&search_orderyear='.urlencode($search_orderyear);
971
+		}
972
+		if ($search_deliveryday) {
973
+			$param .= '&search_deliveryday='.urlencode($search_deliveryday);
974
+		}
975
+		if ($search_deliverymonth) {
976
+			$param .= '&search_deliverymonth='.urlencode($search_deliverymonth);
977
+		}
978
+		if ($search_deliveryyear) {
979
+			$param .= '&search_deliveryyear='.urlencode($search_deliveryyear);
980
+		}
981
+		if ($search_ref) {
982
+			$param .= '&search_ref='.urlencode($search_ref);
983
+		}
984
+		if ($search_company) {
985
+			$param .= '&search_company='.urlencode($search_company);
986
+		}
987
+		if ($search_ref_customer) {
988
+			$param .= '&search_ref_customer='.urlencode($search_ref_customer);
989
+		}
990
+		if ($search_user > 0) {
991
+			$param .= '&search_user='.urlencode($search_user);
992
+		}
993
+		if ($search_sale > 0) {
994
+			$param .= '&search_sale='.urlencode($search_sale);
995
+		}
996
+		if ($search_total_ht != '') {
997
+			$param .= '&search_total_ht='.urlencode($search_total_ht);
998
+		}
999
+		if ($search_total_vat != '') {
1000
+			$param .= '&search_total_vat='.urlencode($search_total_vat);
1001
+		}
1002
+		if ($search_total_ttc != '') {
1003
+			$param .= '&search_total_ttc='.urlencode($search_total_ttc);
1004
+		}
1005
+		if ($search_project_ref >= 0) {
1006
+			$param .= "&search_project_ref=".urlencode($search_project_ref);
1007
+		}
1008
+		if ($show_files) {
1009
+			$param .= '&show_files='.urlencode($show_files);
1010
+		}
1011
+		if ($optioncss != '') {
1012
+			$param .= '&optioncss='.urlencode($optioncss);
1013
+		}
1014
+		if ($billed != '') {
1015
+			$param .= '&billed='.urlencode($billed);
1016
+		}
848 1017
 
849 1018
 		header("Location: ".$_SERVER['PHP_SELF'].'?'.$param);
850 1019
 		exit;
@@ -869,8 +1038,9 @@  discard block
 block discarded – undo
869 1038
 	foreach ($orders as $id_order)
870 1039
 	{
871 1040
 		$cmd = new Commande($db);
872
-		if ($cmd->fetch($id_order) <= 0)
873
-			continue;
1041
+		if ($cmd->fetch($id_order) <= 0) {
1042
+					continue;
1043
+		}
874 1044
 
875 1045
 		if ($cmd->statut != Commande::STATUS_VALIDATED)
876 1046
 		{
@@ -888,13 +1058,17 @@  discard block
 block discarded – undo
888 1058
 			setEventMessages($cmd->error, $cmd->errors, 'errors');
889 1059
 			$error++;
890 1060
 			break;
891
-		} else $nbok++;
1061
+		} else {
1062
+			$nbok++;
1063
+		}
892 1064
 	}
893 1065
 	if (!$error)
894 1066
 	{
895
-		if ($nbok > 1)
1067
+		if ($nbok > 1) {
1068
+					setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
1069
+		} else {
896 1070
 			setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
897
-		else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
1071
+		}
898 1072
 		$db->commit();
899 1073
 	} else {
900 1074
 		$db->rollback();
@@ -932,8 +1106,13 @@  discard block
 block discarded – undo
932 1106
 	}
933 1107
 
934 1108
 	$arrayofinclusion = array();
935
-	foreach ($listofobjectref as $tmppdf) $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'\.pdf$';
936
-	foreach ($listofobjectref as $tmppdf) $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'_[a-zA-Z0-9-_]+\.pdf$'; // To include PDF generated from ODX files
1109
+	foreach ($listofobjectref as $tmppdf) {
1110
+		$arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'\.pdf$';
1111
+	}
1112
+	foreach ($listofobjectref as $tmppdf) {
1113
+		$arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'_[a-zA-Z0-9-_]+\.pdf$';
1114
+	}
1115
+	// To include PDF generated from ODX files
937 1116
 	$listoffiles = dol_dir_list($uploaddir, 'all', 1, implode('|', $arrayofinclusion), '\.meta$|\.png', 'date', SORT_DESC, 0, true);
938 1117
 
939 1118
 	// build list of files with full path
@@ -954,8 +1133,12 @@  discard block
 block discarded – undo
954 1133
 	// Define output language (Here it is not used because we do only merging existing PDF)
955 1134
 	$outputlangs = $langs;
956 1135
 	$newlang = '';
957
-	if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
958
-	if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $objecttmp->thirdparty->default_lang;
1136
+	if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
1137
+		$newlang = GETPOST('lang_id', 'aZ09');
1138
+	}
1139
+	if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
1140
+		$newlang = $objecttmp->thirdparty->default_lang;
1141
+	}
959 1142
 	if (!empty($newlang)) {
960 1143
 		$outputlangs = new Translate("", $conf);
961 1144
 		$outputlangs->setDefaultLang($newlang);
@@ -973,11 +1156,18 @@  discard block
 block discarded – undo
973 1156
 		// Save merged file
974 1157
 		if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED)
975 1158
 		{
976
-			if ($option == 'late') $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
977
-			else $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
1159
+			if ($option == 'late') {
1160
+				$filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
1161
+			} else {
1162
+				$filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
1163
+			}
1164
+		}
1165
+		if ($year) {
1166
+			$filename .= '_'.$year;
1167
+		}
1168
+		if ($month) {
1169
+			$filename .= '_'.$month;
978 1170
 		}
979
-		if ($year) $filename .= '_'.$year;
980
-		if ($month) $filename .= '_'.$month;
981 1171
 
982 1172
 		if (count($files) > 0)
983 1173
 		{
@@ -994,8 +1184,9 @@  discard block
 block discarded – undo
994 1184
 
995 1185
 			// check if pdftk is installed
996 1186
 			if (file_exists($file)) {
997
-				if (!empty($conf->global->MAIN_UMASK))
998
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
1187
+				if (!empty($conf->global->MAIN_UMASK)) {
1188
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
1189
+				}
999 1190
 
1000 1191
 				$langs->load("exports");
1001 1192
 				setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs');
@@ -1021,7 +1212,9 @@  discard block
 block discarded – undo
1021 1212
 		}
1022 1213
 		$pdf->SetFont(pdf_getPDFFont($outputlangs));
1023 1214
 
1024
-		if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1215
+		if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
1216
+			$pdf->SetCompression(false);
1217
+		}
1025 1218
 
1026 1219
 		// Add all others
1027 1220
 		foreach ($files as $file)
@@ -1047,18 +1240,26 @@  discard block
 block discarded – undo
1047 1240
 		// Save merged file
1048 1241
 		if (in_array($objecttmp->element, array('facture', 'facture_fournisseur')) && $search_status == Facture::STATUS_VALIDATED)
1049 1242
 		{
1050
-			if ($option == 'late') $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
1051
-			else $filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
1243
+			if ($option == 'late') {
1244
+				$filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
1245
+			} else {
1246
+				$filename .= '_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
1247
+			}
1248
+		}
1249
+		if ($year) {
1250
+			$filename .= '_'.$year;
1251
+		}
1252
+		if ($month) {
1253
+			$filename .= '_'.$month;
1052 1254
 		}
1053
-		if ($year) $filename .= '_'.$year;
1054
-		if ($month) $filename .= '_'.$month;
1055 1255
 		if ($pagecount)
1056 1256
 		{
1057 1257
 			$now = dol_now();
1058 1258
 			$file = $diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf';
1059 1259
 			$pdf->Output($file, 'F');
1060
-			if (!empty($conf->global->MAIN_UMASK))
1061
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
1260
+			if (!empty($conf->global->MAIN_UMASK)) {
1261
+							@chmod($file, octdec($conf->global->MAIN_UMASK));
1262
+			}
1062 1263
 
1063 1264
 			$langs->load("exports");
1064 1265
 			setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs');
@@ -1077,8 +1278,11 @@  discard block
 block discarded – undo
1077 1278
 	$upload_dir = $diroutputmassaction;
1078 1279
 	$file = $upload_dir.'/'.GETPOST('file');
1079 1280
 	$ret = dol_delete_file($file);
1080
-	if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
1081
-	else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
1281
+	if ($ret) {
1282
+		setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
1283
+	} else {
1284
+		setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
1285
+	}
1082 1286
 	$action = '';
1083 1287
 }
1084 1288
 
@@ -1121,7 +1325,9 @@  discard block
 block discarded – undo
1121 1325
 					setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
1122 1326
 					$error++;
1123 1327
 					break;
1124
-				} else $nbok++;
1328
+				} else {
1329
+					$nbok++;
1330
+				}
1125 1331
 			} else {
1126 1332
 				setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
1127 1333
 				$error++;
@@ -1131,8 +1337,11 @@  discard block
 block discarded – undo
1131 1337
 
1132 1338
 		if (!$error)
1133 1339
 		{
1134
-			if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
1135
-			else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
1340
+			if ($nbok > 1) {
1341
+				setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
1342
+			} else {
1343
+				setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
1344
+			}
1136 1345
 			$db->commit();
1137 1346
 		} else {
1138 1347
 			$db->rollback();
@@ -1155,7 +1364,9 @@  discard block
 block discarded – undo
1155 1364
 				setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
1156 1365
 				$error++;
1157 1366
 				break;
1158
-			} else $nbok++;
1367
+			} else {
1368
+				$nbok++;
1369
+			}
1159 1370
 		} else {
1160 1371
 			setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
1161 1372
 			$error++;
@@ -1164,9 +1375,11 @@  discard block
 block discarded – undo
1164 1375
 	}
1165 1376
 
1166 1377
 	if (!$error) {
1167
-		if ($nbok > 1)
1378
+		if ($nbok > 1) {
1379
+					setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
1380
+		} else {
1168 1381
 			setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
1169
-		else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
1382
+		}
1170 1383
 		$db->commit();
1171 1384
 	} else {
1172 1385
 		$db->rollback();
@@ -1208,15 +1421,20 @@  discard block
 block discarded – undo
1208 1421
 				}
1209 1422
 			}
1210 1423
 
1211
-			if (in_array($objecttmp->element, array('societe', 'member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1);
1212
-			else $result = $objecttmp->delete($user);
1424
+			if (in_array($objecttmp->element, array('societe', 'member'))) {
1425
+				$result = $objecttmp->delete($objecttmp->id, $user, 1);
1426
+			} else {
1427
+				$result = $objecttmp->delete($user);
1428
+			}
1213 1429
 
1214 1430
 			if ($result <= 0)
1215 1431
 			{
1216 1432
 				setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
1217 1433
 				$error++;
1218 1434
 				break;
1219
-			} else $nbok++;
1435
+			} else {
1436
+				$nbok++;
1437
+			}
1220 1438
 		} else {
1221 1439
 			setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
1222 1440
 			$error++;
@@ -1226,8 +1444,11 @@  discard block
 block discarded – undo
1226 1444
 
1227 1445
 	if (!$error)
1228 1446
 	{
1229
-		if ($nbok > 1) setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
1230
-		else setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs');
1447
+		if ($nbok > 1) {
1448
+			setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
1449
+		} else {
1450
+			setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs');
1451
+		}
1231 1452
 		$db->commit();
1232 1453
 	} else {
1233 1454
 		$db->rollback();
@@ -1251,9 +1472,17 @@  discard block
 block discarded – undo
1251 1472
 			$outputlangs = $langs;
1252 1473
 			$newlang = '';
1253 1474
 
1254
-			if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
1255
-			if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) $newlang = $objecttmp->thirdparty->default_lang; // for proposal, order, invoice, ...
1256
-			if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) $newlang = $objecttmp->default_lang; // for thirdparty
1475
+			if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
1476
+				$newlang = GETPOST('lang_id', 'aZ09');
1477
+			}
1478
+			if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) {
1479
+				$newlang = $objecttmp->thirdparty->default_lang;
1480
+			}
1481
+			// for proposal, order, invoice, ...
1482
+			if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) {
1483
+				$newlang = $objecttmp->default_lang;
1484
+			}
1485
+			// for thirdparty
1257 1486
 			if (!empty($newlang))
1258 1487
 			{
1259 1488
 				$outputlangs = new Translate("", $conf);
@@ -1261,10 +1490,18 @@  discard block
 block discarded – undo
1261 1490
 			}
1262 1491
 
1263 1492
 			// To be sure vars is defined
1264
-			if (empty($hidedetails)) $hidedetails = 0;
1265
-			if (empty($hidedesc)) $hidedesc = 0;
1266
-			if (empty($hideref)) $hideref = 0;
1267
-			if (empty($moreparams)) $moreparams = null;
1493
+			if (empty($hidedetails)) {
1494
+				$hidedetails = 0;
1495
+			}
1496
+			if (empty($hidedesc)) {
1497
+				$hidedesc = 0;
1498
+			}
1499
+			if (empty($hideref)) {
1500
+				$hideref = 0;
1501
+			}
1502
+			if (empty($moreparams)) {
1503
+				$moreparams = null;
1504
+			}
1268 1505
 
1269 1506
 			$result = $objecttmp->generateDocument($objecttmp->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1270 1507
 
@@ -1273,7 +1510,9 @@  discard block
 block discarded – undo
1273 1510
 				setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
1274 1511
 				$error++;
1275 1512
 				break;
1276
-			} else $nbok++;
1513
+			} else {
1514
+				$nbok++;
1515
+			}
1277 1516
 		} else {
1278 1517
 			setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
1279 1518
 			$error++;
@@ -1283,8 +1522,11 @@  discard block
 block discarded – undo
1283 1522
 
1284 1523
 	if (!$error)
1285 1524
 	{
1286
-		if ($nbok > 1) setEventMessages($langs->trans("RecordsGenerated", $nbok), null, 'mesgs');
1287
-		else setEventMessages($langs->trans("RecordGenerated", $nbok), null, 'mesgs');
1525
+		if ($nbok > 1) {
1526
+			setEventMessages($langs->trans("RecordsGenerated", $nbok), null, 'mesgs');
1527
+		} else {
1528
+			setEventMessages($langs->trans("RecordGenerated", $nbok), null, 'mesgs');
1529
+		}
1288 1530
 		$db->commit();
1289 1531
 	} else {
1290 1532
 		$db->rollback();
@@ -1340,8 +1582,11 @@  discard block
 block discarded – undo
1340 1582
 
1341 1583
 	if (!$error)
1342 1584
 	{
1343
-		if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null);
1344
-		else setEventMessages($langs->trans("RecordsModified", $nbok), null);
1585
+		if ($nbok > 1) {
1586
+			setEventMessages($langs->trans("RecordsModified", $nbok), null);
1587
+		} else {
1588
+			setEventMessages($langs->trans("RecordsModified", $nbok), null);
1589
+		}
1345 1590
 		$db->commit();
1346 1591
 		$toselect=array();
1347 1592
 	} else {
@@ -1355,4 +1600,6 @@  discard block
 block discarded – undo
1355 1600
 $parameters['diroutputmassaction'] = $diroutputmassaction;
1356 1601
 
1357 1602
 $reshook = $hookmanager->executeHooks('doMassActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
1358
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1603
+if ($reshook < 0) {
1604
+	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1605
+}
Please login to merge, or discard this patch.
htdocs/core/class/commonobject.class.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -2955,7 +2955,7 @@  discard block
 block discarded – undo
2955 2955
 		// Special cas
2956 2956
 		if ($this->table_element == 'product' && $newsuffix == '_private') $newsuffix = '';
2957 2957
 		if (in_array($this->table_element, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))) {
2958
-			$fieldusermod =  "fk_user_mod";
2958
+			$fieldusermod = "fk_user_mod";
2959 2959
 		} elseif ($this->table_element == 'ecm_files') {
2960 2960
 			$fieldusermod = "fk_user_m";
2961 2961
 		} else {
@@ -8427,12 +8427,12 @@  discard block
 block discarded – undo
8427 8427
 		}
8428 8428
 
8429 8429
 		$error = 0;
8430
-		$ok=0;
8430
+		$ok = 0;
8431 8431
 
8432 8432
 		// Process
8433 8433
 		foreach ($to_del as $del) {
8434 8434
 			if ($c->fetch($del) > 0) {
8435
-				$result=$c->del_type($this, $type_categ);
8435
+				$result = $c->del_type($this, $type_categ);
8436 8436
 				if ($result < 0)
8437 8437
 				{
8438 8438
 					$error++;
@@ -8440,7 +8440,7 @@  discard block
 block discarded – undo
8440 8440
 					$this->errors = $c->errors;
8441 8441
 					break;
8442 8442
 				} else {
8443
-					$ok+=$result;
8443
+					$ok += $result;
8444 8444
 				}
8445 8445
 			}
8446 8446
 		}
@@ -8455,7 +8455,7 @@  discard block
 block discarded – undo
8455 8455
 					$this->errors = $c->errors;
8456 8456
 					break;
8457 8457
 				} else {
8458
-					$ok+=$result;
8458
+					$ok += $result;
8459 8459
 				}
8460 8460
 			}
8461 8461
 		}
Please login to merge, or discard this patch.
htdocs/core/class/html.form.class.php 1 patch
Braces   +1541 added lines, -545 removed lines patch added patch discarded remove patch
@@ -117,40 +117,70 @@  discard block
 block discarded – undo
117 117
 			{
118 118
 				$tmp = explode(':', $typeofdata);
119 119
 				$ret .= '<div class="editkey_'.$tmp[0].(!empty($tmp[1]) ? ' '.$tmp[1] : '').'" id="'.$htmlname.'">';
120
-				if ($fieldrequired) $ret .= '<span class="fieldrequired">';
120
+				if ($fieldrequired) {
121
+					$ret .= '<span class="fieldrequired">';
122
+				}
121 123
 				if ($help) {
122 124
 					$ret .= $this->textwithpicto($langs->trans($text), $help);
123 125
 				} else {
124 126
 					$ret .= $langs->trans($text);
125 127
 				}
126
-				if ($fieldrequired) $ret .= '</span>';
128
+				if ($fieldrequired) {
129
+					$ret .= '</span>';
130
+				}
127 131
 				$ret .= '</div>'."\n";
128 132
 			} else {
129
-				if ($fieldrequired) $ret .= '<span class="fieldrequired">';
133
+				if ($fieldrequired) {
134
+					$ret .= '<span class="fieldrequired">';
135
+				}
130 136
 				if ($help) {
131 137
 					$ret .= $this->textwithpicto($langs->trans($text), $help);
132 138
 				} else {
133 139
 					$ret .= $langs->trans($text);
134 140
 				}
135
-				if ($fieldrequired) $ret .= '</span>';
141
+				if ($fieldrequired) {
142
+					$ret .= '</span>';
143
+				}
136 144
 			}
137 145
 		} else {
138
-			if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) $ret .= '<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
139
-			if ($fieldrequired) $ret .= '<span class="fieldrequired">';
146
+			if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) {
147
+				$ret .= '<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
148
+			}
149
+			if ($fieldrequired) {
150
+				$ret .= '<span class="fieldrequired">';
151
+			}
140 152
 			if ($help) {
141 153
 				$ret .= $this->textwithpicto($langs->trans($text), $help);
142 154
 			} else {
143 155
 				$ret .= $langs->trans($text);
144 156
 			}
145
-			if ($fieldrequired) $ret .= '</span>';
146
-			if (!empty($notabletag)) $ret .= ' ';
147
-			if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) $ret .= '</td>';
148
-			if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) $ret .= '<td class="right">';
149
-			if ($htmlname && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) $ret .= '<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=edit'.$htmlname.'&amp;'.$paramid.'='.$object->id.$moreparam.'">'.img_edit($langs->trans('Edit'), ($notabletag ? 0 : 1)).'</a>';
150
-			if (!empty($notabletag) && $notabletag == 1) $ret .= ' : ';
151
-			if (!empty($notabletag) && $notabletag == 3) $ret .= ' ';
152
-			if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) $ret .= '</td>';
153
-			if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) $ret .= '</tr></table>';
157
+			if ($fieldrequired) {
158
+				$ret .= '</span>';
159
+			}
160
+			if (!empty($notabletag)) {
161
+				$ret .= ' ';
162
+			}
163
+			if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) {
164
+				$ret .= '</td>';
165
+			}
166
+			if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) {
167
+				$ret .= '<td class="right">';
168
+			}
169
+			if ($htmlname && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) {
170
+				$ret .= '<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=edit'.$htmlname.'&amp;'.$paramid.'='.$object->id.$moreparam.'">'.img_edit($langs->trans('Edit'), ($notabletag ? 0 : 1)).'</a>';
171
+			}
172
+			if (!empty($notabletag) && $notabletag == 1) {
173
+				$ret .= ' : ';
174
+			}
175
+			if (!empty($notabletag) && $notabletag == 3) {
176
+				$ret .= ' ';
177
+			}
178
+			if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) {
179
+				$ret .= '</td>';
180
+			}
181
+			if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) {
182
+				$ret .= '</tr></table>';
183
+			}
154 184
 		}
155 185
 
156 186
 		return $ret;
@@ -181,12 +211,16 @@  discard block
 block discarded – undo
181 211
 		$ret = '';
182 212
 
183 213
 		// Check parameters
184
-		if (empty($typeofdata)) return 'ErrorBadParameter';
214
+		if (empty($typeofdata)) {
215
+			return 'ErrorBadParameter';
216
+		}
185 217
 
186 218
 		// When option to edit inline is activated
187
-		if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match('/^select;|datehourpicker/', $typeofdata)) // TODO add jquery timepicker and support select
219
+		if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match('/^select;|datehourpicker/', $typeofdata)) {
220
+			// TODO add jquery timepicker and support select
188 221
 		{
189 222
 			$ret .= $this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $editvalue, $extObject, $custommsg);
223
+		}
190 224
 		} else {
191 225
 			$editmode = (GETPOST('action', 'aZ09') == 'edit'.$htmlname);
192 226
 			if ($editmode)
@@ -196,8 +230,12 @@  discard block
 block discarded – undo
196 230
 				$ret .= '<input type="hidden" name="action" value="set'.$htmlname.'">';
197 231
 				$ret .= '<input type="hidden" name="token" value="'.newToken().'">';
198 232
 				$ret .= '<input type="hidden" name="'.$paramid.'" value="'.$object->id.'">';
199
-				if (empty($notabletag)) $ret .= '<table class="nobordernopadding centpercent" cellpadding="0" cellspacing="0">';
200
-				if (empty($notabletag)) $ret .= '<tr><td>';
233
+				if (empty($notabletag)) {
234
+					$ret .= '<table class="nobordernopadding centpercent" cellpadding="0" cellspacing="0">';
235
+				}
236
+				if (empty($notabletag)) {
237
+					$ret .= '<tr><td>';
238
+				}
201 239
 				if (preg_match('/^(string|safehtmlstring|email)/', $typeofdata))
202 240
 				{
203 241
 					$tmp = explode(':', $typeofdata);
@@ -207,9 +245,11 @@  discard block
 block discarded – undo
207 245
 					$tmp = explode(':', $typeofdata);
208 246
 					$valuetoshow = price2num($editvalue ? $editvalue : $value);
209 247
 					$ret .= '<input type="text" id="'.$htmlname.'" name="'.$htmlname.'" value="'.($valuetoshow != '' ?price($valuetoshow) : '').'"'.($tmp[1] ? ' size="'.$tmp[1].'"' : '').' autofocus>';
210
-				} elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata))	// if wysiwyg is enabled $typeofdata = 'ckeditor'
248
+				} elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) {
249
+					// if wysiwyg is enabled $typeofdata = 'ckeditor'
211 250
 				{
212 251
 					$tmp = explode(':', $typeofdata);
252
+				}
213 253
 					$cols = $tmp[2];
214 254
 					$morealt = '';
215 255
 					if (preg_match('/%/', $cols))
@@ -249,26 +289,43 @@  discard block
 block discarded – undo
249 289
 					$doleditor = new DolEditor($htmlname, ($editvalue ? $editvalue : $value), ($tmp[2] ? $tmp[2] : ''), ($tmp[3] ? $tmp[3] : '100'), ($tmp[1] ? $tmp[1] : 'dolibarr_notes'), 'In', ($tmp[5] ? $tmp[5] : 0), (isset($tmp[8]) ? ($tmp[8] ?true:false) : true), true, ($tmp[6] ? $tmp[6] : '20'), ($tmp[7] ? $tmp[7] : '100'));
250 290
 					$ret .= $doleditor->Create(1);
251 291
 				}
252
-				if (empty($notabletag)) $ret .= '</td>';
292
+				if (empty($notabletag)) {
293
+					$ret .= '</td>';
294
+				}
253 295
 
254
-				if (empty($notabletag)) $ret .= '<td class="left">';
296
+				if (empty($notabletag)) {
297
+					$ret .= '<td class="left">';
298
+				}
255 299
 				//else $ret.='<div class="clearboth"></div>';
256 300
 				$ret .= '<input type="submit" class="button'.(empty($notabletag) ? '' : ' ').'" name="modify" value="'.$langs->trans("Modify").'">';
257
-				if (preg_match('/ckeditor|textarea/', $typeofdata) && empty($notabletag)) $ret .= '<br>'."\n";
301
+				if (preg_match('/ckeditor|textarea/', $typeofdata) && empty($notabletag)) {
302
+					$ret .= '<br>'."\n";
303
+				}
258 304
 				$ret .= '<input type="submit" class="button button-cancel'.(empty($notabletag) ? '' : ' ').'" name="cancel" value="'.$langs->trans("Cancel").'">';
259
-				if (empty($notabletag)) $ret .= '</td>';
305
+				if (empty($notabletag)) {
306
+					$ret .= '</td>';
307
+				}
260 308
 
261
-				if (empty($notabletag)) $ret .= '</tr></table>'."\n";
309
+				if (empty($notabletag)) {
310
+					$ret .= '</tr></table>'."\n";
311
+				}
262 312
 				$ret .= '</form>'."\n";
263 313
 			} else {
264
-				if (preg_match('/^(email)/', $typeofdata))              $ret .= dol_print_email($value, 0, 0, 0, 0, 1);
265
-				elseif (preg_match('/^(amount|numeric)/', $typeofdata)) $ret .= ($value != '' ? price($value, '', $langs, 0, -1, -1, $conf->currency) : '');
266
-				elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata))  $ret .= dol_htmlentitiesbr($value);
267
-				elseif (preg_match('/^safehtmlstring/', $typeofdata)) $ret .= dol_string_onlythesehtmltags($value);
268
-				elseif (preg_match('/^restricthtml/', $typeofdata)) $ret .= dol_string_onlythesehtmltags($value);
269
-				elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') $ret .= '<span class="valuedate">'.dol_print_date($value, 'day').'</span>';
270
-				elseif ($typeofdata == 'dayhour' || $typeofdata == 'datehourpicker') $ret .= '<span class="valuedate">'.dol_print_date($value, 'dayhour').'</span>';
271
-				elseif (preg_match('/^select;/', $typeofdata))
314
+				if (preg_match('/^(email)/', $typeofdata)) {
315
+					$ret .= dol_print_email($value, 0, 0, 0, 0, 1);
316
+				} elseif (preg_match('/^(amount|numeric)/', $typeofdata)) {
317
+					$ret .= ($value != '' ? price($value, '', $langs, 0, -1, -1, $conf->currency) : '');
318
+				} elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) {
319
+					$ret .= dol_htmlentitiesbr($value);
320
+				} elseif (preg_match('/^safehtmlstring/', $typeofdata)) {
321
+					$ret .= dol_string_onlythesehtmltags($value);
322
+				} elseif (preg_match('/^restricthtml/', $typeofdata)) {
323
+					$ret .= dol_string_onlythesehtmltags($value);
324
+				} elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') {
325
+					$ret .= '<span class="valuedate">'.dol_print_date($value, 'day').'</span>';
326
+				} elseif ($typeofdata == 'dayhour' || $typeofdata == 'datehourpicker') {
327
+					$ret .= '<span class="valuedate">'.dol_print_date($value, 'dayhour').'</span>';
328
+				} elseif (preg_match('/^select;/', $typeofdata))
272 329
 				{
273 330
 					$arraydata = explode(',', preg_replace('/^select;/', '', $typeofdata));
274 331
 					$arraylist = array();
@@ -322,7 +379,9 @@  discard block
 block discarded – undo
322 379
 
323 380
 		// List of extra languages
324 381
 		$arrayoflangcode = array();
325
-		if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) $arrayoflangcode[] = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE;
382
+		if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) {
383
+			$arrayoflangcode[] = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE;
384
+		}
326 385
 
327 386
 		if (is_array($arrayoflangcode) && count($arrayoflangcode)) {
328 387
 			if (!is_object($extralanguages)) {
@@ -394,9 +453,13 @@  discard block
 block discarded – undo
394 453
 		$out = '';
395 454
 
396 455
 		// Check parameters
397
-		if (preg_match('/^text/', $inputType)) $value = dol_nl2br($value);
398
-		elseif (preg_match('/^numeric/', $inputType)) $value = price($value);
399
-		elseif ($inputType == 'day' || $inputType == 'datepicker') $value = dol_print_date($value, 'day');
456
+		if (preg_match('/^text/', $inputType)) {
457
+			$value = dol_nl2br($value);
458
+		} elseif (preg_match('/^numeric/', $inputType)) {
459
+			$value = price($value);
460
+		} elseif ($inputType == 'day' || $inputType == 'datepicker') {
461
+			$value = dol_print_date($value, 'day');
462
+		}
400 463
 
401 464
 		if ($condition)
402 465
 		{
@@ -425,23 +488,35 @@  discard block
 block discarded – undo
425 488
 			{
426 489
 				$tmp = explode(':', $inputType);
427 490
 				$inputType = $tmp[0];
428
-				if (!empty($tmp[1])) $inputOption = $tmp[1];
429
-				if (!empty($tmp[2])) $savemethod = $tmp[2];
491
+				if (!empty($tmp[1])) {
492
+					$inputOption = $tmp[1];
493
+				}
494
+				if (!empty($tmp[2])) {
495
+					$savemethod = $tmp[2];
496
+				}
430 497
 				$out .= '<input id="width_'.$htmlname.'" value="'.$inputOption.'" type="hidden"/>'."\n";
431 498
 			} elseif ((preg_match('/^day$/', $inputType)) || (preg_match('/^datepicker/', $inputType)) || (preg_match('/^datehourpicker/', $inputType)))
432 499
 			{
433 500
 				$tmp = explode(':', $inputType);
434 501
 				$inputType = $tmp[0];
435
-				if (!empty($tmp[1])) $inputOption = $tmp[1];
436
-				if (!empty($tmp[2])) $savemethod = $tmp[2];
502
+				if (!empty($tmp[1])) {
503
+					$inputOption = $tmp[1];
504
+				}
505
+				if (!empty($tmp[2])) {
506
+					$savemethod = $tmp[2];
507
+				}
437 508
 
438 509
 				$out .= '<input id="timestamp" type="hidden"/>'."\n"; // Use for timestamp format
439 510
 			} elseif (preg_match('/^(select|autocomplete)/', $inputType))
440 511
 			{
441 512
 				$tmp = explode(':', $inputType);
442 513
 				$inputType = $tmp[0]; $loadmethod = $tmp[1];
443
-				if (!empty($tmp[2])) $savemethod = $tmp[2];
444
-				if (!empty($tmp[3])) $button_only = true;
514
+				if (!empty($tmp[2])) {
515
+					$savemethod = $tmp[2];
516
+				}
517
+				if (!empty($tmp[3])) {
518
+					$button_only = true;
519
+				}
445 520
 			} elseif (preg_match('/^textarea/', $inputType))
446 521
 			{
447 522
 				$tmp = explode(':', $inputType);
@@ -452,9 +527,15 @@  discard block
 block discarded – undo
452 527
 			{
453 528
 				$tmp = explode(':', $inputType);
454 529
 				$inputType = $tmp[0]; $toolbar = $tmp[1];
455
-				if (!empty($tmp[2])) $width = $tmp[2];
456
-				if (!empty($tmp[3])) $heigth = $tmp[3];
457
-				if (!empty($tmp[4])) $savemethod = $tmp[4];
530
+				if (!empty($tmp[2])) {
531
+					$width = $tmp[2];
532
+				}
533
+				if (!empty($tmp[3])) {
534
+					$heigth = $tmp[3];
535
+				}
536
+				if (!empty($tmp[4])) {
537
+					$savemethod = $tmp[4];
538
+				}
458 539
 
459 540
 				if (!empty($conf->fckeditor->enabled))
460 541
 				{
@@ -468,17 +549,25 @@  discard block
 block discarded – undo
468 549
 			$out .= '<input id="table_element_'.$htmlname.'" value="'.$table_element.'" type="hidden"/>'."\n";
469 550
 			$out .= '<input id="fk_element_'.$htmlname.'" value="'.$fk_element.'" type="hidden"/>'."\n";
470 551
 			$out .= '<input id="loadmethod_'.$htmlname.'" value="'.$loadmethod.'" type="hidden"/>'."\n";
471
-			if (!empty($savemethod))	$out .= '<input id="savemethod_'.$htmlname.'" value="'.$savemethod.'" type="hidden"/>'."\n";
472
-			if (!empty($ext_element))	$out .= '<input id="ext_element_'.$htmlname.'" value="'.$ext_element.'" type="hidden"/>'."\n";
552
+			if (!empty($savemethod)) {
553
+				$out .= '<input id="savemethod_'.$htmlname.'" value="'.$savemethod.'" type="hidden"/>'."\n";
554
+			}
555
+			if (!empty($ext_element)) {
556
+				$out .= '<input id="ext_element_'.$htmlname.'" value="'.$ext_element.'" type="hidden"/>'."\n";
557
+			}
473 558
 			if (!empty($custommsg))
474 559
 			{
475 560
 				if (is_array($custommsg))
476 561
 				{
477
-					if (!empty($custommsg['success']))
478
-						$out .= '<input id="successmsg_'.$htmlname.'" value="'.$custommsg['success'].'" type="hidden"/>'."\n";
479
-						if (!empty($custommsg['error']))
480
-							$out .= '<input id="errormsg_'.$htmlname.'" value="'.$custommsg['error'].'" type="hidden"/>'."\n";
481
-				} else $out .= '<input id="successmsg_'.$htmlname.'" value="'.$custommsg.'" type="hidden"/>'."\n";
562
+					if (!empty($custommsg['success'])) {
563
+											$out .= '<input id="successmsg_'.$htmlname.'" value="'.$custommsg['success'].'" type="hidden"/>'."\n";
564
+					}
565
+						if (!empty($custommsg['error'])) {
566
+													$out .= '<input id="errormsg_'.$htmlname.'" value="'.$custommsg['error'].'" type="hidden"/>'."\n";
567
+						}
568
+				} else {
569
+					$out .= '<input id="successmsg_'.$htmlname.'" value="'.$custommsg.'" type="hidden"/>'."\n";
570
+				}
482 571
 			}
483 572
 			if ($inputType == 'textarea') {
484 573
 				$out .= '<input id="textarea_'.$htmlname.'_rows" value="'.$rows.'" type="hidden"/>'."\n";
@@ -513,12 +602,20 @@  discard block
 block discarded – undo
513 602
 	 */
514 603
 	public function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 3, $incbefore = '', $noencodehtmltext = 0, $tooltiptrigger = '', $forcenowrap = 0)
515 604
 	{
516
-		if ($incbefore) $text = $incbefore.$text;
517
-		if (!$htmltext) return $text;
605
+		if ($incbefore) {
606
+			$text = $incbefore.$text;
607
+		}
608
+		if (!$htmltext) {
609
+			return $text;
610
+		}
518 611
 
519 612
 		$tag = 'td';
520
-		if ($notabs == 2) $tag = 'div';
521
-		if ($notabs == 3) $tag = 'span';
613
+		if ($notabs == 2) {
614
+			$tag = 'div';
615
+		}
616
+		if ($notabs == 3) {
617
+			$tag = 'span';
618
+		}
522 619
 		// Sanitize tooltip
523 620
 		$htmltext = str_replace(array("\r", "\n"), '', $htmltext);
524 621
 
@@ -540,17 +637,36 @@  discard block
 block discarded – undo
540 637
 		if ($tooltipon == 2 || $tooltipon == 3)
541 638
 		{
542 639
 			$paramfortooltipimg = ' class="'.$classfortooltip.($notabs != 3 ? ' inline-block' : '').($extracss ? ' '.$extracss : '').'" style="padding: 0px;'.($extrastyle ? ' '.$extrastyle : '').'"';
543
-			if ($tooltiptrigger == '') $paramfortooltipimg .= ' title="'.($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)).'"'; // Attribut to put on img tag to store tooltip
544
-			else $paramfortooltipimg .= ' dolid="'.$tooltiptrigger.'"';
545
-		} else $paramfortooltipimg = ($extracss ? ' class="'.$extracss.'"' : '').($extrastyle ? ' style="'.$extrastyle.'"' : ''); // Attribut to put on td text tag
640
+			if ($tooltiptrigger == '') {
641
+				$paramfortooltipimg .= ' title="'.($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)).'"';
642
+			}
643
+			// Attribut to put on img tag to store tooltip
644
+			else {
645
+				$paramfortooltipimg .= ' dolid="'.$tooltiptrigger.'"';
646
+			}
647
+		} else {
648
+			$paramfortooltipimg = ($extracss ? ' class="'.$extracss.'"' : '').($extrastyle ? ' style="'.$extrastyle.'"' : '');
649
+		}
650
+		// Attribut to put on td text tag
546 651
 		if ($tooltipon == 1 || $tooltipon == 3)
547 652
 		{
548 653
 			$paramfortooltiptd = ' class="'.($tooltipon == 3 ? 'cursorpointer ' : '').$classfortooltip.' inline-block'.($extracss ? ' '.$extracss : '').'" style="padding: 0px;'.($extrastyle ? ' '.$extrastyle : '').'" ';
549
-			if ($tooltiptrigger == '') $paramfortooltiptd .= ' title="'.($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)).'"'; // Attribut to put on td tag to store tooltip
550
-			else $paramfortooltiptd .= ' dolid="'.$tooltiptrigger.'"';
551
-		} else $paramfortooltiptd = ($extracss ? ' class="'.$extracss.'"' : '').($extrastyle ? ' style="'.$extrastyle.'"' : ''); // Attribut to put on td text tag
552
-		if (empty($notabs)) $s .= '<table class="nobordernopadding"><tr style="height: auto;">';
553
-		elseif ($notabs == 2) $s .= '<div class="inline-block'.($forcenowrap ? ' nowrap' : '').'">';
654
+			if ($tooltiptrigger == '') {
655
+				$paramfortooltiptd .= ' title="'.($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)).'"';
656
+			}
657
+			// Attribut to put on td tag to store tooltip
658
+			else {
659
+				$paramfortooltiptd .= ' dolid="'.$tooltiptrigger.'"';
660
+			}
661
+		} else {
662
+			$paramfortooltiptd = ($extracss ? ' class="'.$extracss.'"' : '').($extrastyle ? ' style="'.$extrastyle.'"' : '');
663
+		}
664
+		// Attribut to put on td text tag
665
+		if (empty($notabs)) {
666
+			$s .= '<table class="nobordernopadding"><tr style="height: auto;">';
667
+		} elseif ($notabs == 2) {
668
+			$s .= '<div class="inline-block'.($forcenowrap ? ' nowrap' : '').'">';
669
+		}
554 670
 		// Define value if value is before
555 671
 		if ($direction < 0) {
556 672
 			$s .= '<'.$tag.$paramfortooltipimg;
@@ -561,15 +677,22 @@  discard block
 block discarded – undo
561 677
 		}
562 678
 		// Use another method to help avoid having a space in value in order to use this value with jquery
563 679
 		// Define label
564
-		if ((string) $text != '') $s .= '<'.$tag.$paramfortooltiptd.'>'.$text.'</'.$tag.'>';
680
+		if ((string) $text != '') {
681
+			$s .= '<'.$tag.$paramfortooltiptd.'>'.$text.'</'.$tag.'>';
682
+		}
565 683
 		// Define value if value is after
566 684
 		if ($direction > 0) {
567 685
 			$s .= '<'.$tag.$paramfortooltipimg;
568
-			if ($tag == 'td') $s .= ' class="valignmiddle" width="14"';
686
+			if ($tag == 'td') {
687
+				$s .= ' class="valignmiddle" width="14"';
688
+			}
569 689
 			$s .= '>'.$textfordialog.$img.'</'.$tag.'>';
570 690
 		}
571
-		if (empty($notabs)) $s .= '</tr></table>';
572
-		elseif ($notabs == 2) $s .= '</div>';
691
+		if (empty($notabs)) {
692
+			$s .= '</tr></table>';
693
+		} elseif ($notabs == 2) {
694
+			$s .= '</div>';
695
+		}
573 696
 
574 697
 		return $s;
575 698
 	}
@@ -593,17 +716,23 @@  discard block
 block discarded – undo
593 716
 		global $conf, $langs;
594 717
 
595 718
 		$alt = '';
596
-		if ($tooltiptrigger) $alt = $langs->transnoentitiesnoconv("ClickToShowHelp");
719
+		if ($tooltiptrigger) {
720
+			$alt = $langs->transnoentitiesnoconv("ClickToShowHelp");
721
+		}
597 722
 
598 723
 		//For backwards compatibility
599
-		if ($type == '0') $type = 'info';
600
-		elseif ($type == '1') $type = 'help';
724
+		if ($type == '0') {
725
+			$type = 'info';
726
+		} elseif ($type == '1') {
727
+			$type = 'help';
728
+		}
601 729
 
602 730
 		// If info or help with no javascript, show only text
603 731
 		if (empty($conf->use_javascript_ajax))
604 732
 		{
605
-			if ($type == 'info' || $type == 'infoclickable' || $type == 'help' || $type == 'helpclickable')	return $text;
606
-			else {
733
+			if ($type == 'info' || $type == 'infoclickable' || $type == 'help' || $type == 'helpclickable') {
734
+				return $text;
735
+			} else {
607 736
 				$alt = $htmltext;
608 737
 				$htmltext = '';
609 738
 			}
@@ -612,7 +741,9 @@  discard block
 block discarded – undo
612 741
 		// If info or help with smartphone, show only text (tooltip hover can't works)
613 742
 		if (!empty($conf->dol_no_mouse_hover) && empty($tooltiptrigger))
614 743
 		{
615
-			if ($type == 'info' || $type == 'infoclickable' || $type == 'help' || $type == 'helpclickable') return $text;
744
+			if ($type == 'info' || $type == 'infoclickable' || $type == 'help' || $type == 'helpclickable') {
745
+				return $text;
746
+			}
616 747
 		}
617 748
 		// If info or help with smartphone, show only text (tooltip on click does not works with dialog on smaprtphone)
618 749
 		//if (! empty($conf->dol_no_mouse_hover) && ! empty($tooltiptrigger))
@@ -621,13 +752,22 @@  discard block
 block discarded – undo
621 752
 		//}
622 753
 
623 754
 		$img = '';
624
-		if ($type == 'info') $img = img_help(0, $alt);
625
-		elseif ($type == 'help') $img = img_help(($tooltiptrigger != '' ? 2 : 1), $alt);
626
-		elseif ($type == 'helpclickable') $img = img_help(($tooltiptrigger != '' ? 2 : 1), $alt);
627
-		elseif ($type == 'superadmin') $img = img_picto($alt, 'redstar');
628
-		elseif ($type == 'admin') $img = img_picto($alt, 'star');
629
-		elseif ($type == 'warning') $img = img_warning($alt);
630
-		elseif ($type != 'none') $img = img_picto($alt, $type); // $type can be an image path
755
+		if ($type == 'info') {
756
+			$img = img_help(0, $alt);
757
+		} elseif ($type == 'help') {
758
+			$img = img_help(($tooltiptrigger != '' ? 2 : 1), $alt);
759
+		} elseif ($type == 'helpclickable') {
760
+			$img = img_help(($tooltiptrigger != '' ? 2 : 1), $alt);
761
+		} elseif ($type == 'superadmin') {
762
+			$img = img_picto($alt, 'redstar');
763
+		} elseif ($type == 'admin') {
764
+			$img = img_picto($alt, 'star');
765
+		} elseif ($type == 'warning') {
766
+			$img = img_warning($alt);
767
+		} elseif ($type != 'none') {
768
+			$img = img_picto($alt, $type);
769
+		}
770
+		// $type can be an image path
631 771
 
632 772
 		return $this->textwithtooltip($text, $htmltext, ((($tooltiptrigger && !$img) || strpos($type, 'clickable')) ? 3 : 2), $direction, $img, $extracss, $notabs, '', $noencodehtmltext, $tooltiptrigger, $forcenowrap);
633 773
 	}
@@ -655,7 +795,9 @@  discard block
 block discarded – undo
655 795
 		$parameters = array();
656 796
 		$reshook = $hookmanager->executeHooks('addMoreMassActions', $parameters); // Note that $action and $object may have been modified by hook
657 797
 		// check if there is a mass action
658
-		if (count($arrayofaction) == 0 && empty($hookmanager->resPrint)) return;
798
+		if (count($arrayofaction) == 0 && empty($hookmanager->resPrint)) {
799
+			return;
800
+		}
659 801
 		if (empty($reshook))
660 802
 		{
661 803
 			$ret .= '<option value="0"'.($disabled ? ' disabled="disabled"' : '').'>-- '.$langs->trans("SelectAction").' --</option>';
@@ -668,7 +810,9 @@  discard block
 block discarded – undo
668 810
 
669 811
 		$ret .= '</select>';
670 812
 
671
-				if (empty($conf->dol_optimize_smallscreen)) $ret .= ajax_combobox('.'.$name.'select');
813
+				if (empty($conf->dol_optimize_smallscreen)) {
814
+					$ret .= ajax_combobox('.'.$name.'select');
815
+				}
672 816
 
673 817
 		// Warning: if you set submit button to disabled, post using 'Enter' will no more work if there is no another input submit. So we add a hidden button
674 818
 		$ret .= '<input type="submit" name="confirmmassactioninvisible" style="display: none" tabindex="-1">'; // Hidden button BEFORE so it is the one used when we submit with ENTER.
@@ -794,20 +938,27 @@  discard block
 block discarded – undo
794 938
 					$i++;
795 939
 				}
796 940
 
797
-				if (empty($disablefavorites)) array_multisort($favorite, SORT_DESC, $label, SORT_ASC, $countryArray);
798
-				else $countryArray = dol_sort_array($countryArray, 'label');
941
+				if (empty($disablefavorites)) {
942
+					array_multisort($favorite, SORT_DESC, $label, SORT_ASC, $countryArray);
943
+				} else {
944
+					$countryArray = dol_sort_array($countryArray, 'label');
945
+				}
799 946
 
800 947
 				if ($showempty)
801 948
 				{
802 949
 					$out .= '<option value="">&nbsp;</option>'."\n";
803 950
 				}
804 951
 
805
-				if ($addspecialentries)	// Add dedicated entries for groups of countries
952
+				if ($addspecialentries) {
953
+					// Add dedicated entries for groups of countries
806 954
 				{
807 955
 					//if ($showempty) $out.= '<option value="" disabled class="selectoptiondisabledwhite">--------------</option>';
808 956
 					$out .= '<option value="special_allnotme"'.($selected == 'special_allnotme' ? ' selected' : '').'>'.$langs->trans("CountriesExceptMe", $langs->transnoentitiesnoconv("Country".$mysoc->country_code)).'</option>';
957
+				}
809 958
 					$out .= '<option value="special_eec"'.($selected == 'special_eec' ? ' selected' : '').'>'.$langs->trans("CountriesInEEC").'</option>';
810
-					if ($mysoc->isInEEC()) $out .= '<option value="special_eecnotme"'.($selected == 'special_eecnotme' ? ' selected' : '').'>'.$langs->trans("CountriesInEECExceptMe", $langs->transnoentitiesnoconv("Country".$mysoc->country_code)).'</option>';
959
+					if ($mysoc->isInEEC()) {
960
+						$out .= '<option value="special_eecnotme"'.($selected == 'special_eecnotme' ? ' selected' : '').'>'.$langs->trans("CountriesInEECExceptMe", $langs->transnoentitiesnoconv("Country".$mysoc->country_code)).'</option>';
961
+					}
811 962
 					$out .= '<option value="special_noteec"'.($selected == 'special_noteec' ? ' selected' : '').'>'.$langs->trans("CountriesNotInEEC").'</option>';
812 963
 					$out .= '<option value="" disabled class="selectoptiondisabledwhite">------------</option>';
813 964
 				}
@@ -815,10 +966,17 @@  discard block
 block discarded – undo
815 966
 				foreach ($countryArray as $row)
816 967
 				{
817 968
 					//if (empty($showempty) && empty($row['rowid'])) continue;
818
-					if (empty($row['rowid'])) continue;
819
-					if (is_array($exclude_country_code) && count($exclude_country_code) && in_array($row['code_iso'], $exclude_country_code)) continue; // exclude some countries
969
+					if (empty($row['rowid'])) {
970
+						continue;
971
+					}
972
+					if (is_array($exclude_country_code) && count($exclude_country_code) && in_array($row['code_iso'], $exclude_country_code)) {
973
+						continue;
974
+					}
975
+					// exclude some countries
820 976
 
821
-					if (empty($disablefavorites) && $row['favorite'] && $row['code_iso']) $atleastonefavorite++;
977
+					if (empty($disablefavorites) && $row['favorite'] && $row['code_iso']) {
978
+						$atleastonefavorite++;
979
+					}
822 980
 					if (empty($row['favorite']) && $atleastonefavorite)
823 981
 					{
824 982
 						$atleastonefavorite = 0;
@@ -826,8 +984,11 @@  discard block
 block discarded – undo
826 984
 					}
827 985
 
828 986
 					$labeltoshow = '';
829
-					if ($row['label']) $labeltoshow .= dol_trunc($row['label'], $maxlength, 'middle');
830
-					else $labeltoshow .= '&nbsp;';
987
+					if ($row['label']) {
988
+						$labeltoshow .= dol_trunc($row['label'], $maxlength, 'middle');
989
+					} else {
990
+						$labeltoshow .= '&nbsp;';
991
+					}
831 992
 					if ($row['code_iso']) {
832 993
 						$labeltoshow .= ' <span class="opacitymedium">('.$row['code_iso'].')</span>';
833 994
 						$tmpflag = picto_from_langcode($row['code_iso'], 'class="saturatemedium marginrightonly"');
@@ -925,7 +1086,9 @@  discard block
 block discarded – undo
925 1086
 						$out .= '<option value="'.$row['rowid'].'">';
926 1087
 					}
927 1088
 
928
-					if ($row['code']) $out .= $row['code'];
1089
+					if ($row['code']) {
1090
+						$out .= $row['code'];
1091
+					}
929 1092
 
930 1093
 					$out .= '</option>';
931 1094
 				}
@@ -966,21 +1129,29 @@  discard block
 block discarded – undo
966 1129
 		if ($forceall == 1 || (empty($forceall) && !empty($conf->product->enabled) && !empty($conf->service->enabled))
967 1130
 			|| (empty($forceall) && empty($conf->product->enabled) && empty($conf->service->enabled)))
968 1131
 		{
969
-			if (empty($hidetext)) print $langs->trans("Type").': ';
1132
+			if (empty($hidetext)) {
1133
+				print $langs->trans("Type").': ';
1134
+			}
970 1135
 			print '<select class="flat" id="select_'.$htmlname.'" name="'.$htmlname.'">';
971 1136
 			if ($showempty)
972 1137
 			{
973 1138
 				print '<option value="-1"';
974
-				if ($selected == -1) print ' selected';
1139
+				if ($selected == -1) {
1140
+					print ' selected';
1141
+				}
975 1142
 				print '>&nbsp;</option>';
976 1143
 			}
977 1144
 
978 1145
 			print '<option value="0"';
979
-			if (0 == $selected) print ' selected';
1146
+			if (0 == $selected) {
1147
+				print ' selected';
1148
+			}
980 1149
 			print '>'.$langs->trans("Product");
981 1150
 
982 1151
 			print '<option value="1"';
983
-			if (1 == $selected) print ' selected';
1152
+			if (1 == $selected) {
1153
+				print ' selected';
1154
+			}
984 1155
 			print '>'.$langs->trans("Service");
985 1156
 
986 1157
 			print '</select>';
@@ -996,9 +1167,12 @@  discard block
 block discarded – undo
996 1167
 			print $langs->trans("Product");
997 1168
 			print '<input type="hidden" name="'.$htmlname.'" value="0">';
998 1169
 		}
999
-		if ($forceall < 0)	// This should happened only for contracts when both predefined product and service are disabled.
1170
+		if ($forceall < 0) {
1171
+			// This should happened only for contracts when both predefined product and service are disabled.
1000 1172
 		{
1001
-			print '<input type="hidden" name="'.$htmlname.'" value="1">'; // By default we set on service for contract. If CONTRACT_SUPPORT_PRODUCTS is set, forceall should be 1 not -1
1173
+			print '<input type="hidden" name="'.$htmlname.'" value="1">';
1174
+		}
1175
+		// By default we set on service for contract. If CONTRACT_SUPPORT_PRODUCTS is set, forceall should be 1 not -1
1002 1176
 		}
1003 1177
 	}
1004 1178
 
@@ -1014,7 +1188,10 @@  discard block
 block discarded – undo
1014 1188
 		global $langs;
1015 1189
 
1016 1190
 		$num = count($this->cache_types_fees);
1017
-		if ($num > 0) return 0; // Cache already loaded
1191
+		if ($num > 0) {
1192
+			return 0;
1193
+		}
1194
+		// Cache already loaded
1018 1195
 
1019 1196
 		dol_syslog(__METHOD__, LOG_DEBUG);
1020 1197
 
@@ -1071,21 +1248,27 @@  discard block
 block discarded – undo
1071 1248
 		if ($showempty)
1072 1249
 		{
1073 1250
 			print '<option value="-1"';
1074
-			if ($selected == -1) print ' selected';
1251
+			if ($selected == -1) {
1252
+				print ' selected';
1253
+			}
1075 1254
 			print '>&nbsp;</option>';
1076 1255
 		}
1077 1256
 
1078 1257
 		foreach ($this->cache_types_fees as $key => $value)
1079 1258
 		{
1080 1259
 			print '<option value="'.$key.'"';
1081
-			if ($key == $selected) print ' selected';
1260
+			if ($key == $selected) {
1261
+				print ' selected';
1262
+			}
1082 1263
 			print '>';
1083 1264
 			print $value;
1084 1265
 			print '</option>';
1085 1266
 		}
1086 1267
 
1087 1268
 		print '</select>';
1088
-		if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1269
+		if ($user->admin) {
1270
+			print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1271
+		}
1089 1272
 	}
1090 1273
 
1091 1274
 
@@ -1132,8 +1315,9 @@  discard block
 block discarded – undo
1132 1315
 			$urloption = 'htmlname='.urlencode($htmlname).'&outjson=1&filter='.urlencode($filter).($showtype ? '&showtype='.urlencode($showtype) : '');
1133 1316
 			$out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
1134 1317
 			$out .= '<style type="text/css">.ui-autocomplete { z-index: 250; }</style>';
1135
-			if (empty($hidelabel)) print $langs->trans("RefOrLabel").' : ';
1136
-			elseif ($hidelabel > 1) {
1318
+			if (empty($hidelabel)) {
1319
+				print $langs->trans("RefOrLabel").' : ';
1320
+			} elseif ($hidelabel > 1) {
1137 1321
 				$placeholder = ' placeholder="'.$langs->trans("RefOrLabel").'"';
1138 1322
 				if ($hidelabel == 2) {
1139 1323
 					$out .= img_picto($langs->trans("Search"), 'search');
@@ -1180,8 +1364,11 @@  discard block
 block discarded – undo
1180 1364
 		$num = 0;
1181 1365
 		$outarray = array();
1182 1366
 
1183
-		if ($selected === '') $selected = array();
1184
-		elseif (!is_array($selected)) $selected = array($selected);
1367
+		if ($selected === '') {
1368
+			$selected = array();
1369
+		} elseif (!is_array($selected)) {
1370
+			$selected = array($selected);
1371
+		}
1185 1372
 
1186 1373
 		// Clean $filter that may contains sql conditions so sql code
1187 1374
 		if (function_exists('testSqlAndScriptInject')) {
@@ -1200,12 +1387,22 @@  discard block
 block discarded – undo
1200 1387
 		if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
1201 1388
 			$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as dictp ON dictp.rowid = s.fk_pays";
1202 1389
 		}
1203
-		if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
1390
+		if (!$user->rights->societe->client->voir && !$user->socid) {
1391
+			$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
1392
+		}
1204 1393
 		$sql .= " WHERE s.entity IN (".getEntity('societe').")";
1205
-		if (!empty($user->socid)) $sql .= " AND s.rowid = ".$user->socid;
1206
-		if ($filter) $sql .= " AND (".$filter.")";
1207
-		if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
1208
-		if (!empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) $sql .= " AND s.status <> 0";
1394
+		if (!empty($user->socid)) {
1395
+			$sql .= " AND s.rowid = ".$user->socid;
1396
+		}
1397
+		if ($filter) {
1398
+			$sql .= " AND (".$filter.")";
1399
+		}
1400
+		if (!$user->rights->societe->client->voir && !$user->socid) {
1401
+			$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
1402
+		}
1403
+		if (!empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) {
1404
+			$sql .= " AND s.status <> 0";
1405
+		}
1209 1406
 		// Add criteria
1210 1407
 		if ($filterkey && $filterkey != '')
1211 1408
 		{
@@ -1214,13 +1411,19 @@  discard block
 block discarded – undo
1214 1411
 			// For natural search
1215 1412
 			$scrit = explode(' ', $filterkey);
1216 1413
 			$i = 0;
1217
-			if (count($scrit) > 1) $sql .= "(";
1414
+			if (count($scrit) > 1) {
1415
+				$sql .= "(";
1416
+			}
1218 1417
 			foreach ($scrit as $crit) {
1219
-				if ($i > 0) $sql .= " AND ";
1418
+				if ($i > 0) {
1419
+					$sql .= " AND ";
1420
+				}
1220 1421
 				$sql .= "(s.nom LIKE '".$this->db->escape($prefix.$crit)."%')";
1221 1422
 				$i++;
1222 1423
 			}
1223
-			if (count($scrit) > 1) $sql .= ")";
1424
+			if (count($scrit) > 1) {
1425
+				$sql .= ")";
1426
+			}
1224 1427
 			if (!empty($conf->barcode->enabled))
1225 1428
 			{
1226 1429
 				$sql .= " OR s.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'";
@@ -1250,10 +1453,15 @@  discard block
 block discarded – undo
1250 1453
 			{
1251 1454
 				// Do not use textifempty = ' ' or '&nbsp;' here, or search on key will search on ' key'.
1252 1455
 				//if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
1253
-				if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
1254
-				else $textifempty .= $langs->trans("All");
1456
+				if ($showempty && !is_numeric($showempty)) {
1457
+					$textifempty = $langs->trans($showempty);
1458
+				} else {
1459
+					$textifempty .= $langs->trans("All");
1460
+				}
1461
+			}
1462
+			if ($showempty) {
1463
+				$out .= '<option value="-1" data-html="'.dol_escape_htmltag('<span class="opacitymedium">'.$textifempty.'</span>').'">'.$textifempty.'</option>'."\n";
1255 1464
 			}
1256
-			if ($showempty) $out .= '<option value="-1" data-html="'.dol_escape_htmltag('<span class="opacitymedium">'.$textifempty.'</span>').'">'.$textifempty.'</option>'."\n";
1257 1465
 
1258 1466
 			$num = $this->db->num_rows($resql);
1259 1467
 			$i = 0;
@@ -1281,11 +1489,21 @@  discard block
 block discarded – undo
1281 1489
 
1282 1490
 					if ($showtype)
1283 1491
 					{
1284
-						if ($obj->client || $obj->fournisseur) $label .= ' (';
1285
-						if ($obj->client == 1 || $obj->client == 3) $label .= $langs->trans("Customer");
1286
-						if ($obj->client == 2 || $obj->client == 3) $label .= ($obj->client == 3 ? ', ' : '').$langs->trans("Prospect");
1287
-						if ($obj->fournisseur) $label .= ($obj->client ? ', ' : '').$langs->trans("Supplier");
1288
-						if ($obj->client || $obj->fournisseur) $label .= ')';
1492
+						if ($obj->client || $obj->fournisseur) {
1493
+							$label .= ' (';
1494
+						}
1495
+						if ($obj->client == 1 || $obj->client == 3) {
1496
+							$label .= $langs->trans("Customer");
1497
+						}
1498
+						if ($obj->client == 2 || $obj->client == 3) {
1499
+							$label .= ($obj->client == 3 ? ', ' : '').$langs->trans("Prospect");
1500
+						}
1501
+						if ($obj->fournisseur) {
1502
+							$label .= ($obj->client ? ', ' : '').$langs->trans("Supplier");
1503
+						}
1504
+						if ($obj->client || $obj->fournisseur) {
1505
+							$label .= ')';
1506
+						}
1289 1507
 					}
1290 1508
 
1291 1509
 					if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
@@ -1308,7 +1526,9 @@  discard block
 block discarded – undo
1308 1526
 					}
1309 1527
 
1310 1528
 					$i++;
1311
-					if (($i % 10) == 0) $out .= "\n";
1529
+					if (($i % 10) == 0) {
1530
+						$out .= "\n";
1531
+					}
1312 1532
 				}
1313 1533
 			}
1314 1534
 			$out .= '</select>'."\n";
@@ -1318,7 +1538,9 @@  discard block
 block discarded – undo
1318 1538
 
1319 1539
 		$this->result = array('nbofthirdparties'=>$num);
1320 1540
 
1321
-		if ($outputmode) return $outarray;
1541
+		if ($outputmode) {
1542
+			return $outarray;
1543
+		}
1322 1544
 		return $out;
1323 1545
 	}
1324 1546
 
@@ -1345,7 +1567,9 @@  discard block
 block discarded – undo
1345 1567
 		$sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re";
1346 1568
 		$sql .= " WHERE re.fk_soc = ".(int) $socid;
1347 1569
 		$sql .= " AND re.entity = ".$conf->entity;
1348
-		if ($filter) $sql .= " AND ".$filter;
1570
+		if ($filter) {
1571
+			$sql .= " AND ".$filter;
1572
+		}
1349 1573
 		$sql .= " ORDER BY re.description ASC";
1350 1574
 
1351 1575
 		dol_syslog(get_class($this)."::select_remises", LOG_DEBUG);
@@ -1365,13 +1589,23 @@  discard block
 block discarded – undo
1365 1589
 				{
1366 1590
 					$obj = $this->db->fetch_object($resql);
1367 1591
 					$desc = dol_trunc($obj->description, 40);
1368
-					if (preg_match('/\(CREDIT_NOTE\)/', $desc)) $desc = preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $desc);
1369
-					if (preg_match('/\(DEPOSIT\)/', $desc)) $desc = preg_replace('/\(DEPOSIT\)/', $langs->trans("Deposit"), $desc);
1370
-					if (preg_match('/\(EXCESS RECEIVED\)/', $desc)) $desc = preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("ExcessReceived"), $desc);
1371
-					if (preg_match('/\(EXCESS PAID\)/', $desc)) $desc = preg_replace('/\(EXCESS PAID\)/', $langs->trans("ExcessPaid"), $desc);
1592
+					if (preg_match('/\(CREDIT_NOTE\)/', $desc)) {
1593
+						$desc = preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $desc);
1594
+					}
1595
+					if (preg_match('/\(DEPOSIT\)/', $desc)) {
1596
+						$desc = preg_replace('/\(DEPOSIT\)/', $langs->trans("Deposit"), $desc);
1597
+					}
1598
+					if (preg_match('/\(EXCESS RECEIVED\)/', $desc)) {
1599
+						$desc = preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("ExcessReceived"), $desc);
1600
+					}
1601
+					if (preg_match('/\(EXCESS PAID\)/', $desc)) {
1602
+						$desc = preg_replace('/\(EXCESS PAID\)/', $langs->trans("ExcessPaid"), $desc);
1603
+					}
1372 1604
 
1373 1605
 					$selectstring = '';
1374
-					if ($selected > 0 && $selected == $obj->rowid) $selectstring = ' selected';
1606
+					if ($selected > 0 && $selected == $obj->rowid) {
1607
+						$selectstring = ' selected';
1608
+					}
1375 1609
 
1376 1610
 					$disabled = '';
1377 1611
 					if ($maxvalue > 0 && $obj->amount_ttc > $maxvalue)
@@ -1383,7 +1617,9 @@  discard block
 block discarded – undo
1383 1617
 					if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST) && !empty($obj->fk_facture_source))
1384 1618
 					{
1385 1619
 						$tmpfac = new Facture($this->db);
1386
-						if ($tmpfac->fetch($obj->fk_facture_source) > 0) $desc = $desc.' - '.$tmpfac->ref;
1620
+						if ($tmpfac->fetch($obj->fk_facture_source) > 0) {
1621
+							$desc = $desc.' - '.$tmpfac->ref;
1622
+						}
1387 1623
 					}
1388 1624
 
1389 1625
 					print '<option value="'.$obj->rowid.'"'.$selectstring.$disabled.'>'.$desc.' ('.price($obj->amount_ht).' '.$langs->trans("HT").' - '.price($obj->amount_ttc).' '.$langs->trans("TTC").')</option>';
@@ -1456,11 +1692,16 @@  discard block
 block discarded – undo
1456 1692
 
1457 1693
 		$langs->load('companies');
1458 1694
 
1459
-		if (empty($htmlid)) $htmlid = $htmlname;
1695
+		if (empty($htmlid)) {
1696
+			$htmlid = $htmlname;
1697
+		}
1460 1698
 		$num = 0;
1461 1699
 
1462
-		if ($selected === '') $selected = array();
1463
-		elseif (!is_array($selected)) $selected = array($selected);
1700
+		if ($selected === '') {
1701
+			$selected = array();
1702
+		} elseif (!is_array($selected)) {
1703
+			$selected = array($selected);
1704
+		}
1464 1705
 		$out = '';
1465 1706
 
1466 1707
 		if (!is_object($hookmanager))
@@ -1471,12 +1712,20 @@  discard block
 block discarded – undo
1471 1712
 
1472 1713
 		// We search third parties
1473 1714
 		$sql = "SELECT sp.rowid, sp.lastname, sp.statut, sp.firstname, sp.poste, sp.email, sp.phone, sp.phone_perso, sp.phone_mobile, sp.town AS contact_town";
1474
-		if ($showsoc > 0 || !empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) $sql .= ", s.nom as company, s.town AS company_town";
1715
+		if ($showsoc > 0 || !empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) {
1716
+			$sql .= ", s.nom as company, s.town AS company_town";
1717
+		}
1475 1718
 		$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
1476
-		if ($showsoc > 0 || !empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) $sql .= " LEFT OUTER JOIN  ".MAIN_DB_PREFIX."societe as s ON s.rowid=sp.fk_soc";
1719
+		if ($showsoc > 0 || !empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) {
1720
+			$sql .= " LEFT OUTER JOIN  ".MAIN_DB_PREFIX."societe as s ON s.rowid=sp.fk_soc";
1721
+		}
1477 1722
 		$sql .= " WHERE sp.entity IN (".getEntity('socpeople').")";
1478
-		if ($socid > 0 || $socid == -1) $sql .= " AND sp.fk_soc=".$socid;
1479
-		if (!empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) $sql .= " AND sp.statut <> 0";
1723
+		if ($socid > 0 || $socid == -1) {
1724
+			$sql .= " AND sp.fk_soc=".$socid;
1725
+		}
1726
+		if (!empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) {
1727
+			$sql .= " AND sp.statut <> 0";
1728
+		}
1480 1729
 		$sql .= " ORDER BY sp.lastname ASC";
1481 1730
 
1482 1731
 		dol_syslog(get_class($this)."::select_contacts", LOG_DEBUG);
@@ -1495,8 +1744,12 @@  discard block
 block discarded – undo
1495 1744
 				$out .= '<select class="flat'.($moreclass ? ' '.$moreclass : '').'" id="'.$htmlid.'" name="'.$htmlname.(($num || empty($disableifempty)) ? '' : ' disabled').($multiple ? '[]' : '').'" '.($multiple ? 'multiple' : '').' '.(!empty($moreparam) ? $moreparam : '').'>';
1496 1745
 			}
1497 1746
 
1498
-			if (($showempty == 1 || ($showempty == 3 && $num > 1)) && !$multiple) $out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'>&nbsp;</option>';
1499
-			if ($showempty == 2) $out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'>-- '.$langs->trans("Internal").' --</option>';
1747
+			if (($showempty == 1 || ($showempty == 3 && $num > 1)) && !$multiple) {
1748
+				$out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'>&nbsp;</option>';
1749
+			}
1750
+			if ($showempty == 2) {
1751
+				$out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'>-- '.$langs->trans("Internal").' --</option>';
1752
+			}
1500 1753
 
1501 1754
 			$i = 0;
1502 1755
 			if ($num)
@@ -1513,21 +1766,33 @@  discard block
 block discarded – undo
1513 1766
 					if (!empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) {
1514 1767
 						$extendedInfos = array();
1515 1768
 						$email = trim($obj->email);
1516
-						if (!empty($email)) $extendedInfos[] = $email;
1517
-						else {
1769
+						if (!empty($email)) {
1770
+							$extendedInfos[] = $email;
1771
+						} else {
1518 1772
 							$phone = trim($obj->phone);
1519 1773
 							$phone_perso = trim($obj->phone_perso);
1520 1774
 							$phone_mobile = trim($obj->phone_mobile);
1521
-							if (!empty($phone)) $extendedInfos[] = $phone;
1522
-							if (!empty($phone_perso)) $extendedInfos[] = $phone_perso;
1523
-							if (!empty($phone_mobile)) $extendedInfos[] = $phone_mobile;
1775
+							if (!empty($phone)) {
1776
+								$extendedInfos[] = $phone;
1777
+							}
1778
+							if (!empty($phone_perso)) {
1779
+								$extendedInfos[] = $phone_perso;
1780
+							}
1781
+							if (!empty($phone_mobile)) {
1782
+								$extendedInfos[] = $phone_mobile;
1783
+							}
1524 1784
 						}
1525 1785
 						$contact_town = trim($obj->contact_town);
1526 1786
 						$company_town = trim($obj->company_town);
1527
-						if (!empty($contact_town)) $extendedInfos[] = $contact_town;
1528
-						elseif (!empty($company_town)) $extendedInfos[] = $company_town;
1787
+						if (!empty($contact_town)) {
1788
+							$extendedInfos[] = $contact_town;
1789
+						} elseif (!empty($company_town)) {
1790
+							$extendedInfos[] = $company_town;
1791
+						}
1529 1792
 						$extendedInfos = implode(' - ', $extendedInfos);
1530
-						if (!empty($extendedInfos)) $extendedInfos = ' - '.$extendedInfos;
1793
+						if (!empty($extendedInfos)) {
1794
+							$extendedInfos = ' - '.$extendedInfos;
1795
+						}
1531 1796
 					}
1532 1797
 
1533 1798
 					$contactstatic->id = $obj->rowid;
@@ -1537,32 +1802,52 @@  discard block
 block discarded – undo
1537 1802
 						if ($htmlname != 'none')
1538 1803
 						{
1539 1804
 							$disabled = 0;
1540
-							if (is_array($exclude) && count($exclude) && in_array($obj->rowid, $exclude)) $disabled = 1;
1541
-							if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) $disabled = 1;
1805
+							if (is_array($exclude) && count($exclude) && in_array($obj->rowid, $exclude)) {
1806
+								$disabled = 1;
1807
+							}
1808
+							if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) {
1809
+								$disabled = 1;
1810
+							}
1542 1811
 							if (!empty($selected) && in_array($obj->rowid, $selected))
1543 1812
 							{
1544 1813
 								$out .= '<option value="'.$obj->rowid.'"';
1545
-								if ($disabled) $out .= ' disabled';
1814
+								if ($disabled) {
1815
+									$out .= ' disabled';
1816
+								}
1546 1817
 								$out .= ' selected>';
1547 1818
 								$out .= $contactstatic->getFullName($langs).$extendedInfos;
1548
-								if ($showfunction && $obj->poste) $out .= ' ('.$obj->poste.')';
1549
-								if (($showsoc > 0) && $obj->company) $out .= ' - ('.$obj->company.')';
1819
+								if ($showfunction && $obj->poste) {
1820
+									$out .= ' ('.$obj->poste.')';
1821
+								}
1822
+								if (($showsoc > 0) && $obj->company) {
1823
+									$out .= ' - ('.$obj->company.')';
1824
+								}
1550 1825
 								$out .= '</option>';
1551 1826
 							} else {
1552 1827
 								$out .= '<option value="'.$obj->rowid.'"';
1553
-								if ($disabled) $out .= ' disabled';
1828
+								if ($disabled) {
1829
+									$out .= ' disabled';
1830
+								}
1554 1831
 								$out .= '>';
1555 1832
 								$out .= $contactstatic->getFullName($langs).$extendedInfos;
1556
-								if ($showfunction && $obj->poste) $out .= ' ('.$obj->poste.')';
1557
-								if (($showsoc > 0) && $obj->company) $out .= ' - ('.$obj->company.')';
1833
+								if ($showfunction && $obj->poste) {
1834
+									$out .= ' ('.$obj->poste.')';
1835
+								}
1836
+								if (($showsoc > 0) && $obj->company) {
1837
+									$out .= ' - ('.$obj->company.')';
1838
+								}
1558 1839
 								$out .= '</option>';
1559 1840
 							}
1560 1841
 						} else {
1561 1842
 							if (in_array($obj->rowid, $selected))
1562 1843
 							{
1563 1844
 								$out .= $contactstatic->getFullName($langs).$extendedInfos;
1564
-								if ($showfunction && $obj->poste) $out .= ' ('.$obj->poste.')';
1565
-								if (($showsoc > 0) && $obj->company) $out .= ' - ('.$obj->company.')';
1845
+								if ($showfunction && $obj->poste) {
1846
+									$out .= ' ('.$obj->poste.')';
1847
+								}
1848
+								if (($showsoc > 0) && $obj->company) {
1849
+									$out .= ' - ('.$obj->company.')';
1850
+								}
1566 1851
 							}
1567 1852
 						}
1568 1853
 					}
@@ -1651,19 +1936,27 @@  discard block
 block discarded – undo
1651 1936
 		global $conf, $user, $langs, $hookmanager;
1652 1937
 
1653 1938
 		// If no preselected user defined, we take current user
1654
-		if ((is_numeric($selected) && ($selected < -2 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) $selected = $user->id;
1939
+		if ((is_numeric($selected) && ($selected < -2 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) {
1940
+			$selected = $user->id;
1941
+		}
1655 1942
 
1656
-		if ($selected === '') $selected = array();
1657
-		elseif (!is_array($selected)) $selected = array($selected);
1943
+		if ($selected === '') {
1944
+			$selected = array();
1945
+		} elseif (!is_array($selected)) {
1946
+			$selected = array($selected);
1947
+		}
1658 1948
 
1659 1949
 		$excludeUsers = null;
1660 1950
 		$includeUsers = null;
1661 1951
 
1662 1952
 		// Permettre l'exclusion d'utilisateurs
1663
-		if (is_array($exclude))	$excludeUsers = implode(",", $exclude);
1953
+		if (is_array($exclude)) {
1954
+			$excludeUsers = implode(",", $exclude);
1955
+		}
1664 1956
 		// Permettre l'inclusion d'utilisateurs
1665
-		if (is_array($include))	$includeUsers = implode(",", $include);
1666
-		elseif ($include == 'hierarchy')
1957
+		if (is_array($include)) {
1958
+			$includeUsers = implode(",", $include);
1959
+		} elseif ($include == 'hierarchy')
1667 1960
 		{
1668 1961
 			// Build list includeUsers to have only hierarchy
1669 1962
 			$includeUsers = implode(",", $user->getAllChildIds(0));
@@ -1686,8 +1979,11 @@  discard block
 block discarded – undo
1686 1979
 		if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity)
1687 1980
 		{
1688 1981
 			$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entity as e ON e.rowid=u.entity";
1689
-			if ($force_entity) $sql .= " WHERE u.entity IN (0,".$force_entity.")";
1690
-			else $sql .= " WHERE u.entity IS NOT NULL";
1982
+			if ($force_entity) {
1983
+				$sql .= " WHERE u.entity IN (0,".$force_entity.")";
1984
+			} else {
1985
+				$sql .= " WHERE u.entity IS NOT NULL";
1986
+			}
1691 1987
 		} else {
1692 1988
 			if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
1693 1989
 			{
@@ -1698,19 +1994,33 @@  discard block
 block discarded – undo
1698 1994
 				$sql .= " WHERE u.entity IN (0,".$conf->entity.")";
1699 1995
 			}
1700 1996
 		}
1701
-		if (!empty($user->socid)) $sql .= " AND u.fk_soc = ".$user->socid;
1702
-		if (is_array($exclude) && $excludeUsers) $sql .= " AND u.rowid NOT IN (".$excludeUsers.")";
1703
-		if ($includeUsers) $sql .= " AND u.rowid IN (".$includeUsers.")";
1704
-		if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) $sql .= " AND u.statut <> 0";
1705
-		if (!empty($morefilter)) $sql .= " ".$morefilter;
1997
+		if (!empty($user->socid)) {
1998
+			$sql .= " AND u.fk_soc = ".$user->socid;
1999
+		}
2000
+		if (is_array($exclude) && $excludeUsers) {
2001
+			$sql .= " AND u.rowid NOT IN (".$excludeUsers.")";
2002
+		}
2003
+		if ($includeUsers) {
2004
+			$sql .= " AND u.rowid IN (".$includeUsers.")";
2005
+		}
2006
+		if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) {
2007
+			$sql .= " AND u.statut <> 0";
2008
+		}
2009
+		if (!empty($morefilter)) {
2010
+			$sql .= " ".$morefilter;
2011
+		}
1706 2012
 
1707 2013
 		//Add hook to filter on user (for exemple on usergroup define in custom modules)
1708 2014
 		$reshook = $hookmanager->executeHooks('addSQLWhereFilterOnSelectUsers', array(), $this, $action);
1709
-		if (!empty($reshook)) $sql .= $hookmanager->resPrint;
2015
+		if (!empty($reshook)) {
2016
+			$sql .= $hookmanager->resPrint;
2017
+		}
1710 2018
 
1711
-		if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION))	// MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname
2019
+		if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) {
2020
+			// MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname
1712 2021
 		{
1713 2022
 			$sql .= " ORDER BY u.firstname ASC";
2023
+		}
1714 2024
 		} else {
1715 2025
 			$sql .= " ORDER BY u.lastname ASC";
1716 2026
 		}
@@ -1729,8 +2039,12 @@  discard block
 block discarded – undo
1729 2039
 
1730 2040
 				// do not use maxwidthonsmartphone by default. Set it by caller so auto size to 100% will work when not defined
1731 2041
 				$out .= '<select class="flat'.($morecss ? ' '.$morecss : ' minwidth200').'" id="'.$htmlname.'" name="'.$htmlname.($multiple ? '[]' : '').'" '.($multiple ? 'multiple' : '').' '.($disabled ? ' disabled' : '').'>';
1732
-				if ($show_empty && !$multiple) $out .= '<option value="-1"'.((empty($selected) || in_array(-1, $selected)) ? ' selected' : '').'>&nbsp;</option>'."\n";
1733
-				if ($show_every) $out .= '<option value="-2"'.((in_array(-2, $selected)) ? ' selected' : '').'>-- '.$langs->trans("Everybody").' --</option>'."\n";
2042
+				if ($show_empty && !$multiple) {
2043
+					$out .= '<option value="-1"'.((empty($selected) || in_array(-1, $selected)) ? ' selected' : '').'>&nbsp;</option>'."\n";
2044
+				}
2045
+				if ($show_every) {
2046
+					$out .= '<option value="-2"'.((in_array(-2, $selected)) ? ' selected' : '').'>-- '.$langs->trans("Everybody").' --</option>'."\n";
2047
+				}
1734 2048
 
1735 2049
 				$userstatic = new User($this->db);
1736 2050
 
@@ -1747,7 +2061,9 @@  discard block
 block discarded – undo
1747 2061
 					$userstatic->admin = $obj->admin;
1748 2062
 
1749 2063
 					$disableline = '';
1750
-					if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) $disableline = ($enableonlytext ? $enableonlytext : '1');
2064
+					if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) {
2065
+						$disableline = ($enableonlytext ? $enableonlytext : '1');
2066
+					}
1751 2067
 
1752 2068
 					$labeltoshow = '';
1753 2069
 
@@ -1758,7 +2074,9 @@  discard block
 block discarded – undo
1758 2074
 						$fullNameMode = 1; //Firstname+lastname
1759 2075
 					}
1760 2076
 					$labeltoshow .= $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength);
1761
-					if (empty($obj->firstname) && empty($obj->lastname)) $labeltoshow .= $obj->login;
2077
+					if (empty($obj->firstname) && empty($obj->lastname)) {
2078
+						$labeltoshow .= $obj->login;
2079
+					}
1762 2080
 
1763 2081
 					// Complete name with more info
1764 2082
 					$moreinfo = '';
@@ -1794,7 +2112,9 @@  discard block
 block discarded – undo
1794 2112
 					$labeltoshow .= $moreinfo;
1795 2113
 
1796 2114
 					$out .= '<option value="'.$obj->rowid.'"';
1797
-					if ($disableline) $out .= ' disabled';
2115
+					if ($disableline) {
2116
+						$out .= ' disabled';
2117
+					}
1798 2118
 					if ((is_object($selected) && $selected->id == $obj->rowid) || (!is_object($selected) && in_array($obj->rowid, $selected))) {
1799 2119
 						$out .= ' selected';
1800 2120
 					}
@@ -1804,9 +2124,13 @@  discard block
 block discarded – undo
1804 2124
 					{
1805 2125
 						$outhtml .= $userstatic->getNomUrl(-3, '', 0, 1, 24, 1, 'login', '', 1).' ';
1806 2126
 					}
1807
-					if ($showstatus >= 0 && $obj->status == 0) $outhtml .= '<strike class="opacitymediumxxx">';
2127
+					if ($showstatus >= 0 && $obj->status == 0) {
2128
+						$outhtml .= '<strike class="opacitymediumxxx">';
2129
+					}
1808 2130
 					$outhtml .= $labeltoshow;
1809
-					if ($showstatus >= 0 && $obj->status == 0) $outhtml .= '</strike>';
2131
+					if ($showstatus >= 0 && $obj->status == 0) {
2132
+						$outhtml .= '</strike>';
2133
+					}
1810 2134
 					$out .= dol_escape_htmltag($outhtml);
1811 2135
 					$out .= '">';
1812 2136
 					$out .= $labeltoshow;
@@ -1825,7 +2149,9 @@  discard block
 block discarded – undo
1825 2149
 			dol_print_error($this->db);
1826 2150
 		}
1827 2151
 
1828
-		if ($outputmode) return $outarray;
2152
+		if ($outputmode) {
2153
+			return $outarray;
2154
+		}
1829 2155
 		return $out;
1830 2156
 	}
1831 2157
 
@@ -1870,11 +2196,15 @@  discard block
 block discarded – undo
1870 2196
 		$nbassignetouser = count($assignedtouser);
1871 2197
 
1872 2198
 		//if ($nbassignetouser && $action != 'view') $out .= '<br>';
1873
-		if ($nbassignetouser) $out .= '<ul class="attendees">';
2199
+		if ($nbassignetouser) {
2200
+			$out .= '<ul class="attendees">';
2201
+		}
1874 2202
 		$i = 0; $ownerid = 0;
1875 2203
 		foreach ($assignedtouser as $key => $value)
1876 2204
 		{
1877
-			if ($value['id'] == $ownerid) continue;
2205
+			if ($value['id'] == $ownerid) {
2206
+				continue;
2207
+			}
1878 2208
 
1879 2209
 			$out .= '<li>';
1880 2210
 			$userstatic->fetch($value['id']);
@@ -1900,7 +2230,9 @@  discard block
 block discarded – undo
1900 2230
 			$out .= '</li>';
1901 2231
 			$i++;
1902 2232
 		}
1903
-		if ($nbassignetouser) $out .= '</ul>';
2233
+		if ($nbassignetouser) {
2234
+			$out .= '</ul>';
2235
+		}
1904 2236
 
1905 2237
 		// Method with no ajax
1906 2238
 		if ($action != 'view')
@@ -1958,7 +2290,9 @@  discard block
 block discarded – undo
1958 2290
 
1959 2291
 		// check parameters
1960 2292
 		$price_level = (!empty($price_level) ? $price_level : 0);
1961
-		if (is_null($ajaxoptions)) $ajaxoptions = array();
2293
+		if (is_null($ajaxoptions)) {
2294
+			$ajaxoptions = array();
2295
+		}
1962 2296
 
1963 2297
 		if (strval($filtertype) === '' && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
1964 2298
 			if (!empty($conf->product->enabled) && empty($conf->service->enabled)) {
@@ -2069,8 +2403,9 @@  discard block
 block discarded – undo
2069 2403
                 ';
2070 2404
 			}
2071 2405
 
2072
-			if (empty($hidelabel)) $out .= $langs->trans("RefOrLabel").' : ';
2073
-			elseif ($hidelabel > 1) {
2406
+			if (empty($hidelabel)) {
2407
+				$out .= $langs->trans("RefOrLabel").' : ';
2408
+			} elseif ($hidelabel > 1) {
2074 2409
 				$placeholder = ' placeholder="'.$langs->trans("RefOrLabel").'"';
2075 2410
 				if ($hidelabel == 2) {
2076 2411
 					$out .= img_picto($langs->trans("Search"), 'search');
@@ -2084,8 +2419,11 @@  discard block
 block discarded – undo
2084 2419
 			$out .= $this->select_produits_list($selected, $htmlname, $filtertype, $limit, $price_level, '', $status, $finished, 0, $socid, $showempty, $forcecombo, $morecss, $hidepriceinlabel, $warehouseStatus);
2085 2420
 		}
2086 2421
 
2087
-		if (empty($nooutput)) print $out;
2088
-		else return $out;
2422
+		if (empty($nooutput)) {
2423
+			print $out;
2424
+		} else {
2425
+			return $out;
2426
+		}
2089 2427
 	}
2090 2428
 
2091 2429
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -2188,11 +2526,15 @@  discard block
 block discarded – undo
2188 2526
 		if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
2189 2527
 		{
2190 2528
 			$sql .= ", (SELECT pp.rowid FROM ".MAIN_DB_PREFIX."product_price as pp WHERE pp.fk_product = p.rowid";
2191
-			if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $sql .= " AND price_level=".$price_level;
2529
+			if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
2530
+				$sql .= " AND price_level=".$price_level;
2531
+			}
2192 2532
 			$sql .= " ORDER BY date_price";
2193 2533
 			$sql .= " DESC LIMIT 1) as price_rowid";
2194 2534
 			$sql .= ", (SELECT pp.price_by_qty FROM ".MAIN_DB_PREFIX."product_price as pp WHERE pp.fk_product = p.rowid"; // price_by_qty is 1 if some prices by qty exists in subtable
2195
-			if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $sql .= " AND price_level=".$price_level;
2535
+			if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
2536
+				$sql .= " AND price_level=".$price_level;
2537
+			}
2196 2538
 			$sql .= " ORDER BY date_price";
2197 2539
 			$sql .= " DESC LIMIT 1) as price_by_qty";
2198 2540
 			$selectFields .= ", price_rowid, price_by_qty";
@@ -2241,14 +2583,17 @@  discard block
 block discarded – undo
2241 2583
 		} elseif ($finished == 1)
2242 2584
 		{
2243 2585
 			$sql .= " AND p.finished = ".$finished;
2244
-			if ($status >= 0)  $sql .= " AND p.tosell = ".$status;
2586
+			if ($status >= 0) {
2587
+				$sql .= " AND p.tosell = ".$status;
2588
+			}
2245 2589
 		} elseif ($status >= 0)
2246 2590
 		{
2247 2591
 			$sql .= " AND p.tosell = ".$status;
2248 2592
 		}
2249 2593
 		// Filter by product type
2250
-		if (strval($filtertype) != '') $sql .= " AND p.fk_product_type = ".$filtertype;
2251
-		elseif (empty($conf->product->enabled)) { // when product module is disabled, show services only
2594
+		if (strval($filtertype) != '') {
2595
+			$sql .= " AND p.fk_product_type = ".$filtertype;
2596
+		} elseif (empty($conf->product->enabled)) { // when product module is disabled, show services only
2252 2597
 			$sql .= " AND p.fk_product_type = 1";
2253 2598
 		} elseif (empty($conf->service->enabled)) { // when service module is disabled, show products only
2254 2599
 			$sql .= " AND p.fk_product_type = 0";
@@ -2261,23 +2606,37 @@  discard block
 block discarded – undo
2261 2606
 			// For natural search
2262 2607
 			$scrit = explode(' ', $filterkey);
2263 2608
 			$i = 0;
2264
-			if (count($scrit) > 1) $sql .= "(";
2609
+			if (count($scrit) > 1) {
2610
+				$sql .= "(";
2611
+			}
2265 2612
 			foreach ($scrit as $crit)
2266 2613
 			{
2267
-				if ($i > 0) $sql .= " AND ";
2614
+				if ($i > 0) {
2615
+					$sql .= " AND ";
2616
+				}
2268 2617
 				$sql .= "(p.ref LIKE '".$this->db->escape($prefix.$crit)."%' OR p.label LIKE '".$this->db->escape($prefix.$crit)."%'";
2269
-				if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= " OR pl.label LIKE '".$this->db->escape($prefix.$crit)."%'";
2618
+				if (!empty($conf->global->MAIN_MULTILANGS)) {
2619
+					$sql .= " OR pl.label LIKE '".$this->db->escape($prefix.$crit)."%'";
2620
+				}
2270 2621
 				if (!empty($conf->global->PRODUCT_AJAX_SEARCH_ON_DESCRIPTION))
2271 2622
 				{
2272 2623
 					$sql .= " OR p.description LIKE '".$this->db->escape($prefix.$crit)."%'";
2273
-					if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= " OR pl.description LIKE '".$this->db->escape($prefix.$crit)."%'";
2624
+					if (!empty($conf->global->MAIN_MULTILANGS)) {
2625
+						$sql .= " OR pl.description LIKE '".$this->db->escape($prefix.$crit)."%'";
2626
+					}
2627
+				}
2628
+				if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) {
2629
+					$sql .= " OR pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit)."%'";
2274 2630
 				}
2275
-				if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) $sql .= " OR pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit)."%'";
2276 2631
 				$sql .= ")";
2277 2632
 				$i++;
2278 2633
 			}
2279
-			if (count($scrit) > 1) $sql .= ")";
2280
-			if (!empty($conf->barcode->enabled)) $sql .= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'";
2634
+			if (count($scrit) > 1) {
2635
+				$sql .= ")";
2636
+			}
2637
+			if (!empty($conf->barcode->enabled)) {
2638
+				$sql .= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'";
2639
+			}
2281 2640
 			$sql .= ')';
2282 2641
 		}
2283 2642
 		if (count($warehouseStatusArray))
@@ -2323,12 +2682,19 @@  discard block
 block discarded – undo
2323 2682
 			//if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
2324 2683
 			if (!empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT))
2325 2684
 			{
2326
-				if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
2327
-				else $textifempty .= $langs->trans("All");
2685
+				if ($showempty && !is_numeric($showempty)) {
2686
+					$textifempty = $langs->trans($showempty);
2687
+				} else {
2688
+					$textifempty .= $langs->trans("All");
2689
+				}
2328 2690
 			} else {
2329
-				if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
2691
+				if ($showempty && !is_numeric($showempty)) {
2692
+					$textifempty = $langs->trans($showempty);
2693
+				}
2694
+			}
2695
+			if ($showempty) {
2696
+				$out .= '<option value="0" selected>'.$textifempty.'</option>';
2330 2697
 			}
2331
-			if ($showempty) $out .= '<option value="0" selected>'.$textifempty.'</option>';
2332 2698
 
2333 2699
 			$i = 0;
2334 2700
 			while ($num && $i < $num)
@@ -2406,7 +2772,9 @@  discard block
 block discarded – undo
2406 2772
 
2407 2773
 			$this->db->free($result);
2408 2774
 
2409
-			if (empty($outputmode)) return $out;
2775
+			if (empty($outputmode)) {
2776
+				return $out;
2777
+			}
2410 2778
 			return $outarray;
2411 2779
 		} else {
2412 2780
 			dol_print_error($db);
@@ -2449,8 +2817,12 @@  discard block
 block discarded – undo
2449 2817
 		$maxlengtharticle = (empty($conf->global->PRODUCT_MAX_LENGTH_COMBO) ? 48 : $conf->global->PRODUCT_MAX_LENGTH_COMBO);
2450 2818
 
2451 2819
 		$label = $objp->label;
2452
-		if (!empty($objp->label_translated)) $label = $objp->label_translated;
2453
-		if (!empty($filterkey) && $filterkey != '') $label = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $label, 1);
2820
+		if (!empty($objp->label_translated)) {
2821
+			$label = $objp->label_translated;
2822
+		}
2823
+		if (!empty($filterkey) && $filterkey != '') {
2824
+			$label = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $label, 1);
2825
+		}
2454 2826
 
2455 2827
 		$outkey = $objp->rowid;
2456 2828
 		$outref = $objp->ref;
@@ -2464,7 +2836,9 @@  discard block
 block discarded – undo
2464 2836
 		$outdurationvalue = $outtype == Product::TYPE_SERVICE ?substr($objp->duration, 0, dol_strlen($objp->duration) - 1) : '';
2465 2837
 		$outdurationunit = $outtype == Product::TYPE_SERVICE ?substr($objp->duration, -1) : '';
2466 2838
 
2467
-		if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO))  require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
2839
+		if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) {
2840
+			require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
2841
+		}
2468 2842
 
2469 2843
 		// Units
2470 2844
 		$outvalUnits = '';
@@ -2513,22 +2887,35 @@  discard block
 block discarded – undo
2513 2887
 		if (!empty($conf->stock->enabled) && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)))
2514 2888
 		{
2515 2889
 			if (!empty($user->rights->stock->lire)) {
2516
-				if ($objp->stock > 0) $opt .= ' class="product_line_stock_ok"';
2517
-		   		elseif ($objp->stock <= 0) $opt .= ' class="product_line_stock_too_low"';
2890
+				if ($objp->stock > 0) {
2891
+					$opt .= ' class="product_line_stock_ok"';
2892
+				} elseif ($objp->stock <= 0) {
2893
+		   			$opt .= ' class="product_line_stock_too_low"';
2894
+		   		}
2518 2895
 			}
2519 2896
 		}
2520 2897
 		$opt .= '>';
2521 2898
 		$opt .= $objp->ref;
2522
-		if ($outbarcode) $opt .= ' ('.$outbarcode.')';
2899
+		if ($outbarcode) {
2900
+			$opt .= ' ('.$outbarcode.')';
2901
+		}
2523 2902
 		$opt .= ' - '.dol_trunc($label, $maxlengtharticle);
2524
-		if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) $opt .= ' ('.getCountry($outorigin, 1).')';
2903
+		if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) {
2904
+			$opt .= ' ('.getCountry($outorigin, 1).')';
2905
+		}
2525 2906
 
2526 2907
 		$objRef = $objp->ref;
2527
-		if (!empty($filterkey) && $filterkey != '') $objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRef, 1);
2908
+		if (!empty($filterkey) && $filterkey != '') {
2909
+			$objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRef, 1);
2910
+		}
2528 2911
 		$outval .= $objRef;
2529
-		if ($outbarcode) $outval .= ' ('.$outbarcode.')';
2912
+		if ($outbarcode) {
2913
+			$outval .= ' ('.$outbarcode.')';
2914
+		}
2530 2915
 		$outval .= ' - '.dol_trunc($label, $maxlengtharticle);
2531
-		if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) $outval .= ' ('.getCountry($outorigin, 1).')';
2916
+		if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) {
2917
+			$outval .= ' ('.getCountry($outorigin, 1).')';
2918
+		}
2532 2919
 
2533 2920
 		// Units
2534 2921
 		$opt .= $outvalUnits;
@@ -2661,9 +3048,11 @@  discard block
 block discarded – undo
2661 3048
 				}
2662 3049
 				$outval .= $langs->transnoentities("Stock").': '.price(price2num($objp->stock, 'MS'));
2663 3050
 				$outval .= '</span>';
2664
-				if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO))  // Warning, this option may slow down combo list generation
3051
+				if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) {
3052
+					// Warning, this option may slow down combo list generation
2665 3053
 				{
2666 3054
 					$langs->load("stocks");
3055
+				}
2667 3056
 
2668 3057
 					$tmpproduct = new Product($this->db);
2669 3058
 					$tmpproduct->fetch($objp->rowid, '', '', '', 1, 1, 1); // Load product without lang and prices arrays (we just need to make ->virtual_stock() after)
@@ -2774,10 +3163,14 @@  discard block
 block discarded – undo
2774 3163
 		if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2775 3164
 			$sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units";
2776 3165
 		}
2777
-		if (!empty($conf->barcode->enabled)) $sql .= ", pfp.barcode";
3166
+		if (!empty($conf->barcode->enabled)) {
3167
+			$sql .= ", pfp.barcode";
3168
+		}
2778 3169
 		$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
2779 3170
 		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON ( p.rowid = pfp.fk_product AND pfp.entity IN (".getEntity('product').") )";
2780
-		if ($socid) $sql .= " AND pfp.fk_soc = ".$socid;
3171
+		if ($socid) {
3172
+			$sql .= " AND pfp.fk_soc = ".$socid;
3173
+		}
2781 3174
 		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid";
2782 3175
 		// Units
2783 3176
 		if (!empty($conf->global->PRODUCT_USE_UNITS)) {
@@ -2785,8 +3178,12 @@  discard block
 block discarded – undo
2785 3178
 		}
2786 3179
 		$sql .= " WHERE p.entity IN (".getEntity('product').")";
2787 3180
 		$sql .= " AND p.tobuy = 1";
2788
-		if (strval($filtertype) != '') $sql .= " AND p.fk_product_type=".$this->db->escape($filtertype);
2789
-		if (!empty($filtre)) $sql .= " ".$filtre;
3181
+		if (strval($filtertype) != '') {
3182
+			$sql .= " AND p.fk_product_type=".$this->db->escape($filtertype);
3183
+		}
3184
+		if (!empty($filtre)) {
3185
+			$sql .= " ".$filtre;
3186
+		}
2790 3187
 		// Add criteria on ref/label
2791 3188
 		if ($filterkey != '')
2792 3189
 		{
@@ -2795,14 +3192,20 @@  discard block
 block discarded – undo
2795 3192
 			// For natural search
2796 3193
 			$scrit = explode(' ', $filterkey);
2797 3194
 			$i = 0;
2798
-			if (count($scrit) > 1) $sql .= "(";
3195
+			if (count($scrit) > 1) {
3196
+				$sql .= "(";
3197
+			}
2799 3198
 			foreach ($scrit as $crit)
2800 3199
 			{
2801
-				if ($i > 0) $sql .= " AND ";
3200
+				if ($i > 0) {
3201
+					$sql .= " AND ";
3202
+				}
2802 3203
 				$sql .= "(pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit)."%' OR p.ref LIKE '".$this->db->escape($prefix.$crit)."%' OR p.label LIKE '".$this->db->escape($prefix.$crit)."%')";
2803 3204
 				$i++;
2804 3205
 			}
2805
-			if (count($scrit) > 1) $sql .= ")";
3206
+			if (count($scrit) > 1) {
3207
+				$sql .= ")";
3208
+			}
2806 3209
 			if (!empty($conf->barcode->enabled)) {
2807 3210
 				$sql .= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'";
2808 3211
 				$sql .= " OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'";
@@ -2825,8 +3228,11 @@  discard block
 block discarded – undo
2825 3228
 
2826 3229
 			//$out.='<select class="flat" id="select'.$htmlname.'" name="'.$htmlname.'">';	// remove select to have id same with combo and ajax
2827 3230
 			$out .= '<select class="flat maxwidthonsmartphone'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'">';
2828
-			if (!$selected) $out .= '<option value="0" selected>&nbsp;</option>';
2829
-			else $out .= '<option value="0">&nbsp;</option>';
3231
+			if (!$selected) {
3232
+				$out .= '<option value="0" selected>&nbsp;</option>';
3233
+			} else {
3234
+				$out .= '<option value="0">&nbsp;</option>';
3235
+			}
2830 3236
 
2831 3237
 			$i = 0;
2832 3238
 			while ($i < $num)
@@ -2834,7 +3240,10 @@  discard block
 block discarded – undo
2834 3240
 				$objp = $this->db->fetch_object($result);
2835 3241
 
2836 3242
 				$outkey = $objp->idprodfournprice; // id in table of price
2837
-				if (!$outkey && $alsoproductwithnosupplierprice) $outkey = 'idprod_'.$objp->rowid; // id of product
3243
+				if (!$outkey && $alsoproductwithnosupplierprice) {
3244
+					$outkey = 'idprod_'.$objp->rowid;
3245
+				}
3246
+				// id of product
2838 3247
 
2839 3248
 				$outref = $objp->ref;
2840 3249
 				$outval = '';
@@ -2882,11 +3291,17 @@  discard block
 block discarded – undo
2882 3291
 				}
2883 3292
 
2884 3293
 				$objRef = $objp->ref;
2885
-				if ($filterkey && $filterkey != '') $objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRef, 1);
3294
+				if ($filterkey && $filterkey != '') {
3295
+					$objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRef, 1);
3296
+				}
2886 3297
 				$objRefFourn = $objp->ref_fourn;
2887
-				if ($filterkey && $filterkey != '') $objRefFourn = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRefFourn, 1);
3298
+				if ($filterkey && $filterkey != '') {
3299
+					$objRefFourn = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRefFourn, 1);
3300
+				}
2888 3301
 				$label = $objp->label;
2889
-				if ($filterkey && $filterkey != '') $label = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $label, 1);
3302
+				if ($filterkey && $filterkey != '') {
3303
+					$label = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $label, 1);
3304
+				}
2890 3305
 
2891 3306
 				$optlabel = $objp->ref;
2892 3307
 				if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) {
@@ -2973,9 +3388,11 @@  discard block
 block discarded – undo
2973 3388
 						$outvallabel .= " - ".$reputations[$objp->supplier_reputation];
2974 3389
 					}
2975 3390
 				} else {
2976
-					if (empty($alsoproductwithnosupplierprice))     // No supplier price defined for couple product/supplier
3391
+					if (empty($alsoproductwithnosupplierprice)) {
3392
+						// No supplier price defined for couple product/supplier
2977 3393
 					{
2978 3394
 						$optlabel .= " - <span class='opacitymedium'>".$langs->trans("NoPriceDefinedForThisSupplier").'</span>';
3395
+					}
2979 3396
 						$outvallabel .= ' - '.$langs->transnoentities("NoPriceDefinedForThisSupplier");
2980 3397
 					} else // No supplier price defined for product, even on other suppliers
2981 3398
 					{
@@ -2998,9 +3415,11 @@  discard block
 block discarded – undo
2998 3415
 						}
2999 3416
 						$optlabel .= $langs->transnoentities("Stock").':'.price(price2num($objp->stock, 'MS'));
3000 3417
 						$optlabel .= '</span>';
3001
-						if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO))  // Warning, this option may slow down combo list generation
3418
+						if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) {
3419
+							// Warning, this option may slow down combo list generation
3002 3420
 						{
3003 3421
 							$langs->load("stocks");
3422
+						}
3004 3423
 
3005 3424
 							$tmpproduct = new Product($this->db);
3006 3425
 							$tmpproduct->fetch($objp->rowid, '', '', '', 1, 1, 1); // Load product without lang and prices arrays (we just need to make ->virtual_stock() after)
@@ -3024,8 +3443,12 @@  discard block
 block discarded – undo
3024 3443
 				}
3025 3444
 
3026 3445
 				$opt = '<option value="'.$outkey.'"';
3027
-				if ($selected && $selected == $objp->idprodfournprice) $opt .= ' selected';
3028
-				if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) $opt .= ' disabled';
3446
+				if ($selected && $selected == $objp->idprodfournprice) {
3447
+					$opt .= ' selected';
3448
+				}
3449
+				if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) {
3450
+					$opt .= ' disabled';
3451
+				}
3029 3452
 				if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0)
3030 3453
 				{
3031 3454
 					$opt .= ' pbq="'.$objp->idprodfournprice.'" data-pbq="'.$objp->idprodfournprice.'" data-pbqqty="'.$objp->quantity.'" data-pbqup="'.$objp->unitprice.'" data-pbqpercent="'.$objp->remise_percent.'"';
@@ -3062,7 +3485,9 @@  discard block
 block discarded – undo
3062 3485
 			include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
3063 3486
 			$out .= ajax_combobox($htmlname);
3064 3487
 
3065
-			if (empty($outputmode)) return $out;
3488
+			if (empty($outputmode)) {
3489
+				return $out;
3490
+			}
3066 3491
 			return $outarray;
3067 3492
 		} else {
3068 3493
 			dol_print_error($this->db);
@@ -3160,7 +3585,9 @@  discard block
 block discarded – undo
3160 3585
 						$opt .= " - ";
3161 3586
 						$opt .= price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit");
3162 3587
 					}
3163
-					if ($objp->duration) $opt .= " - ".$objp->duration;
3588
+					if ($objp->duration) {
3589
+						$opt .= " - ".$objp->duration;
3590
+					}
3164 3591
 					$opt .= "</option>\n";
3165 3592
 
3166 3593
 					$form .= $opt;
@@ -3200,7 +3627,9 @@  discard block
 block discarded – undo
3200 3627
 		if ($resql)
3201 3628
 		{
3202 3629
 			print '<select class="flat" id="select_'.$htmlname.'" name="'.$htmlname.'">';
3203
-			if ($showempty) print '<option value="0">&nbsp;</option>';
3630
+			if ($showempty) {
3631
+				print '<option value="0">&nbsp;</option>';
3632
+			}
3204 3633
 			$num = $this->db->num_rows($resql);
3205 3634
 			$i = 0;
3206 3635
 			if ($num)
@@ -3238,7 +3667,10 @@  discard block
 block discarded – undo
3238 3667
 		global $langs;
3239 3668
 
3240 3669
 		$num = count($this->cache_conditions_paiements);
3241
-		if ($num > 0) return 0; // Cache already loaded
3670
+		if ($num > 0) {
3671
+			return 0;
3672
+		}
3673
+		// Cache already loaded
3242 3674
 
3243 3675
 		dol_syslog(__METHOD__, LOG_DEBUG);
3244 3676
 
@@ -3285,7 +3717,10 @@  discard block
 block discarded – undo
3285 3717
 		global $langs;
3286 3718
 
3287 3719
 		$num = count($this->cache_availability);
3288
-		if ($num > 0) return 0; // Cache already loaded
3720
+		if ($num > 0) {
3721
+			return 0;
3722
+		}
3723
+		// Cache already loaded
3289 3724
 
3290 3725
 		dol_syslog(__METHOD__, LOG_DEBUG);
3291 3726
 
@@ -3339,7 +3774,9 @@  discard block
 block discarded – undo
3339 3774
 		dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG);
3340 3775
 
3341 3776
 		print '<select id="'.$htmlname.'" class="flat" name="'.$htmlname.'">';
3342
-		if ($addempty) print '<option value="0">&nbsp;</option>';
3777
+		if ($addempty) {
3778
+			print '<option value="0">&nbsp;</option>';
3779
+		}
3343 3780
 		foreach ($this->cache_availability as $id => $arrayavailability)
3344 3781
 		{
3345 3782
 			if ($selected == $id)
@@ -3352,7 +3789,9 @@  discard block
 block discarded – undo
3352 3789
 			print '</option>';
3353 3790
 		}
3354 3791
 		print '</select>';
3355
-		if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
3792
+		if ($user->admin) {
3793
+			print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
3794
+		}
3356 3795
 		print ajax_combobox($htmlname);
3357 3796
 	}
3358 3797
 
@@ -3366,7 +3805,10 @@  discard block
 block discarded – undo
3366 3805
 		global $langs;
3367 3806
 
3368 3807
 		$num = count($this->cache_demand_reason);
3369
-		if ($num > 0) return 0; // Cache already loaded
3808
+		if ($num > 0) {
3809
+			return 0;
3810
+		}
3811
+		// Cache already loaded
3370 3812
 
3371 3813
 		$sql = "SELECT rowid, code, label";
3372 3814
 		$sql .= " FROM ".MAIN_DB_PREFIX.'c_input_reason';
@@ -3384,8 +3826,14 @@  discard block
 block discarded – undo
3384 3826
 
3385 3827
 				// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
3386 3828
 				$label = ($obj->label != '-' ? $obj->label : '');
3387
-				if ($langs->trans("DemandReasonType".$obj->code) != ("DemandReasonType".$obj->code)) $label = $langs->trans("DemandReasonType".$obj->code); // So translation key DemandReasonTypeSRC_XXX will work
3388
-				if ($langs->trans($obj->code) != $obj->code) $label = $langs->trans($obj->code); // So translation key SRC_XXX will work
3829
+				if ($langs->trans("DemandReasonType".$obj->code) != ("DemandReasonType".$obj->code)) {
3830
+					$label = $langs->trans("DemandReasonType".$obj->code);
3831
+				}
3832
+				// So translation key DemandReasonTypeSRC_XXX will work
3833
+				if ($langs->trans($obj->code) != $obj->code) {
3834
+					$label = $langs->trans($obj->code);
3835
+				}
3836
+				// So translation key SRC_XXX will work
3389 3837
 
3390 3838
 				$tmparray[$obj->rowid]['id']   = $obj->rowid;
3391 3839
 				$tmparray[$obj->rowid]['code'] = $obj->code;
@@ -3420,10 +3868,14 @@  discard block
 block discarded – undo
3420 3868
 		$this->loadCacheInputReason();
3421 3869
 
3422 3870
 		print '<select class="flat" id="select_'.$htmlname.'" name="'.$htmlname.'">';
3423
-		if ($addempty) print '<option value="0"'.(empty($selected) ? ' selected' : '').'>&nbsp;</option>';
3871
+		if ($addempty) {
3872
+			print '<option value="0"'.(empty($selected) ? ' selected' : '').'>&nbsp;</option>';
3873
+		}
3424 3874
 		foreach ($this->cache_demand_reason as $id => $arraydemandreason)
3425 3875
 		{
3426
-			if ($arraydemandreason['code'] == $exclude) continue;
3876
+			if ($arraydemandreason['code'] == $exclude) {
3877
+				continue;
3878
+			}
3427 3879
 
3428 3880
 			if ($selected && ($selected == $arraydemandreason['id'] || $selected == $arraydemandreason['code']))
3429 3881
 			{
@@ -3436,7 +3888,9 @@  discard block
 block discarded – undo
3436 3888
 			print '</option>';
3437 3889
 		}
3438 3890
 		print '</select>';
3439
-		if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
3891
+		if ($user->admin) {
3892
+			print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
3893
+		}
3440 3894
 		print ajax_combobox('select_'.$htmlname);
3441 3895
 	}
3442 3896
 
@@ -3452,7 +3906,10 @@  discard block
 block discarded – undo
3452 3906
 		global $langs;
3453 3907
 
3454 3908
 		$num = count($this->cache_types_paiements);
3455
-		if ($num > 0) return $num; // Cache already loaded
3909
+		if ($num > 0) {
3910
+			return $num;
3911
+		}
3912
+		// Cache already loaded
3456 3913
 
3457 3914
 		dol_syslog(__METHOD__, LOG_DEBUG);
3458 3915
 
@@ -3516,10 +3973,14 @@  discard block
 block discarded – undo
3516 3973
 		$this->load_cache_conditions_paiements();
3517 3974
 
3518 3975
 		// Set default value if not already set by caller
3519
-		if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID)) $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID;
3976
+		if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID)) {
3977
+			$selected = $conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID;
3978
+		}
3520 3979
 
3521 3980
 		print '<select id="'.$htmlname.'" class="flat selectpaymentterms'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">';
3522
-		if ($addempty) print '<option value="0">&nbsp;</option>';
3981
+		if ($addempty) {
3982
+			print '<option value="0">&nbsp;</option>';
3983
+		}
3523 3984
 		foreach ($this->cache_conditions_paiements as $id => $arrayconditions)
3524 3985
 		{
3525 3986
 			if ($selected == $id)
@@ -3532,7 +3993,9 @@  discard block
 block discarded – undo
3532 3993
 			print '</option>';
3533 3994
 		}
3534 3995
 		print '</select>';
3535
-		if ($user->admin && empty($noinfoadmin)) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
3996
+		if ($user->admin && empty($noinfoadmin)) {
3997
+			print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
3998
+		}
3536 3999
 		print ajax_combobox($htmlname);
3537 4000
 	}
3538 4001
 
@@ -3561,48 +4024,78 @@  discard block
 block discarded – undo
3561 4024
 		dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG);
3562 4025
 
3563 4026
 		$filterarray = array();
3564
-		if ($filtertype == 'CRDT')  	$filterarray = array(0, 2, 3);
3565
-		elseif ($filtertype == 'DBIT') 	$filterarray = array(1, 2, 3);
3566
-		elseif ($filtertype != '' && $filtertype != '-1') $filterarray = explode(',', $filtertype);
4027
+		if ($filtertype == 'CRDT') {
4028
+			$filterarray = array(0, 2, 3);
4029
+		} elseif ($filtertype == 'DBIT') {
4030
+			$filterarray = array(1, 2, 3);
4031
+		} elseif ($filtertype != '' && $filtertype != '-1') {
4032
+			$filterarray = explode(',', $filtertype);
4033
+		}
3567 4034
 
3568 4035
 		$this->load_cache_types_paiements();
3569 4036
 
3570 4037
 		// Set default value if not already set by caller
3571
-		if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TYPE_ID)) $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TYPE_ID;
4038
+		if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TYPE_ID)) {
4039
+			$selected = $conf->global->MAIN_DEFAULT_PAYMENT_TYPE_ID;
4040
+		}
3572 4041
 
3573 4042
 		print '<select id="select'.$htmlname.'" class="flat selectpaymenttypes'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">';
3574
-		if ($empty) print '<option value="">&nbsp;</option>';
4043
+		if ($empty) {
4044
+			print '<option value="">&nbsp;</option>';
4045
+		}
3575 4046
 		foreach ($this->cache_types_paiements as $id => $arraytypes)
3576 4047
 		{
3577 4048
 			// If not good status
3578
-			if ($active >= 0 && $arraytypes['active'] != $active) continue;
4049
+			if ($active >= 0 && $arraytypes['active'] != $active) {
4050
+				continue;
4051
+			}
3579 4052
 
3580 4053
 			// On passe si on a demande de filtrer sur des modes de paiments particuliers
3581
-			if (count($filterarray) && !in_array($arraytypes['type'], $filterarray)) continue;
4054
+			if (count($filterarray) && !in_array($arraytypes['type'], $filterarray)) {
4055
+				continue;
4056
+			}
3582 4057
 
3583 4058
 			// We discard empty line if showempty is on because an empty line has already been output.
3584
-			if ($empty && empty($arraytypes['code'])) continue;
4059
+			if ($empty && empty($arraytypes['code'])) {
4060
+				continue;
4061
+			}
3585 4062
 
3586
-			if ($format == 0) print '<option value="'.$id.'"';
3587
-			elseif ($format == 1) print '<option value="'.$arraytypes['code'].'"';
3588
-			elseif ($format == 2) print '<option value="'.$arraytypes['code'].'"';
3589
-			elseif ($format == 3) print '<option value="'.$id.'"';
4063
+			if ($format == 0) {
4064
+				print '<option value="'.$id.'"';
4065
+			} elseif ($format == 1) {
4066
+				print '<option value="'.$arraytypes['code'].'"';
4067
+			} elseif ($format == 2) {
4068
+				print '<option value="'.$arraytypes['code'].'"';
4069
+			} elseif ($format == 3) {
4070
+				print '<option value="'.$id.'"';
4071
+			}
3590 4072
 			// Print attribute selected or not
3591 4073
 			if ($format == 1 || $format == 2) {
3592
-				if ($selected == $arraytypes['code']) print ' selected';
4074
+				if ($selected == $arraytypes['code']) {
4075
+					print ' selected';
4076
+				}
3593 4077
 			} else {
3594
-				if ($selected == $id) print ' selected';
4078
+				if ($selected == $id) {
4079
+					print ' selected';
4080
+				}
3595 4081
 			}
3596 4082
 			print '>';
3597
-			if ($format == 0) $value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']);
3598
-			elseif ($format == 1) $value = $arraytypes['code'];
3599
-			elseif ($format == 2) $value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']);
3600
-			elseif ($format == 3) $value = $arraytypes['code'];
4083
+			if ($format == 0) {
4084
+				$value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']);
4085
+			} elseif ($format == 1) {
4086
+				$value = $arraytypes['code'];
4087
+			} elseif ($format == 2) {
4088
+				$value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']);
4089
+			} elseif ($format == 3) {
4090
+				$value = $arraytypes['code'];
4091
+			}
3601 4092
 			print $value ? $value : '&nbsp;';
3602 4093
 			print '</option>';
3603 4094
 		}
3604 4095
 		print '</select>';
3605
-		if ($user->admin && !$noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4096
+		if ($user->admin && !$noadmininfo) {
4097
+			print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4098
+		}
3606 4099
 		print ajax_combobox('select'.$htmlname);
3607 4100
 	}
3608 4101
 
@@ -3635,7 +4128,9 @@  discard block
 block discarded – undo
3635 4128
 			$return .= '</option>';
3636 4129
 		}
3637 4130
 		$return .= '</select>';
3638
-		if ($addjscombo) $return .= ajax_combobox('select_'.$htmlname);
4131
+		if ($addjscombo) {
4132
+			$return .= ajax_combobox('select_'.$htmlname);
4133
+		}
3639 4134
 
3640 4135
 		return $return;
3641 4136
 	}
@@ -3652,7 +4147,10 @@  discard block
 block discarded – undo
3652 4147
 		global $langs;
3653 4148
 
3654 4149
 		$num = count($this->cache_transport_mode);
3655
-		if ($num > 0) return $num; // Cache already loaded
4150
+		if ($num > 0) {
4151
+			return $num;
4152
+		}
4153
+		// Cache already loaded
3656 4154
 
3657 4155
 		dol_syslog(__METHOD__, LOG_DEBUG);
3658 4156
 
@@ -3684,8 +4182,7 @@  discard block
 block discarded – undo
3684 4182
 			$this->cache_transport_mode = dol_sort_array($this->cache_transport_mode, 'label', 'asc', 0, 0, 1);
3685 4183
 
3686 4184
 			return $num;
3687
-		}
3688
-		else {
4185
+		} else {
3689 4186
 			dol_print_error($this->db);
3690 4187
 			return -1;
3691 4188
 		}
@@ -3713,32 +4210,53 @@  discard block
 block discarded – undo
3713 4210
 		$this->load_cache_transport_mode();
3714 4211
 
3715 4212
 		print '<select id="select'.$htmlname.'" class="flat selectmodetransport'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">';
3716
-		if ($empty) print '<option value="">&nbsp;</option>';
4213
+		if ($empty) {
4214
+			print '<option value="">&nbsp;</option>';
4215
+		}
3717 4216
 		foreach ($this->cache_transport_mode as $id => $arraytypes)
3718 4217
 		{
3719 4218
 			// If not good status
3720
-			if ($active >= 0 && $arraytypes['active'] != $active) continue;
4219
+			if ($active >= 0 && $arraytypes['active'] != $active) {
4220
+				continue;
4221
+			}
3721 4222
 
3722 4223
 			// We discard empty line if showempty is on because an empty line has already been output.
3723
-			if ($empty && empty($arraytypes['code'])) continue;
4224
+			if ($empty && empty($arraytypes['code'])) {
4225
+				continue;
4226
+			}
3724 4227
 
3725
-			if ($format == 0) print '<option value="'.$id.'"';
3726
-			elseif ($format == 1) print '<option value="'.$arraytypes['code'].'"';
3727
-			elseif ($format == 2) print '<option value="'.$arraytypes['code'].'"';
3728
-			elseif ($format == 3) print '<option value="'.$id.'"';
4228
+			if ($format == 0) {
4229
+				print '<option value="'.$id.'"';
4230
+			} elseif ($format == 1) {
4231
+				print '<option value="'.$arraytypes['code'].'"';
4232
+			} elseif ($format == 2) {
4233
+				print '<option value="'.$arraytypes['code'].'"';
4234
+			} elseif ($format == 3) {
4235
+				print '<option value="'.$id.'"';
4236
+			}
3729 4237
 			// If text is selected, we compare with code, else with id
3730
-			if (preg_match('/[a-z]/i', $selected) && $selected == $arraytypes['code']) print ' selected';
3731
-			elseif ($selected == $id) print ' selected';
4238
+			if (preg_match('/[a-z]/i', $selected) && $selected == $arraytypes['code']) {
4239
+				print ' selected';
4240
+			} elseif ($selected == $id) {
4241
+				print ' selected';
4242
+			}
3732 4243
 			print '>';
3733
-			if ($format == 0) $value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']);
3734
-			elseif ($format == 1) $value = $arraytypes['code'];
3735
-			elseif ($format == 2) $value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']);
3736
-			elseif ($format == 3) $value = $arraytypes['code'];
4244
+			if ($format == 0) {
4245
+				$value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']);
4246
+			} elseif ($format == 1) {
4247
+				$value = $arraytypes['code'];
4248
+			} elseif ($format == 2) {
4249
+				$value = ($maxlength ?dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']);
4250
+			} elseif ($format == 3) {
4251
+				$value = $arraytypes['code'];
4252
+			}
3737 4253
 			print $value ? $value : '&nbsp;';
3738 4254
 			print '</option>';
3739 4255
 		}
3740 4256
 		print '</select>';
3741
-		if ($user->admin && !$noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4257
+		if ($user->admin && !$noadmininfo) {
4258
+			print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4259
+		}
3742 4260
 	}
3743 4261
 
3744 4262
 	/**
@@ -3761,7 +4279,9 @@  discard block
 block discarded – undo
3761 4279
 		$sql = "SELECT rowid, code, libelle as label";
3762 4280
 		$sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode";
3763 4281
 		$sql .= " WHERE active > 0";
3764
-		if ($filtre) $sql .= " AND ".$filtre;
4282
+		if ($filtre) {
4283
+			$sql .= " AND ".$filtre;
4284
+		}
3765 4285
 		$sql .= " ORDER BY libelle ASC";
3766 4286
 
3767 4287
 		dol_syslog(get_class($this)."::selectShippingMode", LOG_DEBUG);
@@ -3786,7 +4306,9 @@  discard block
 block discarded – undo
3786 4306
 					$i++;
3787 4307
 				}
3788 4308
 				print "</select>";
3789
-				if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4309
+				if ($user->admin) {
4310
+					print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4311
+				}
3790 4312
 
3791 4313
 				print ajax_combobox('select'.$htmlname);
3792 4314
 			} else {
@@ -3906,15 +4428,19 @@  discard block
 block discarded – undo
3906 4428
 		$resql = $this->db->query($sql);
3907 4429
 		if ($resql && $this->db->num_rows($resql) > 0)
3908 4430
 		{
3909
-			if ($showempty) $return .= '<option value="none"></option>';
4431
+			if ($showempty) {
4432
+				$return .= '<option value="none"></option>';
4433
+			}
3910 4434
 
3911 4435
 			while ($res = $this->db->fetch_object($resql))
3912 4436
 			{
3913 4437
 				$unitLabel = $res->label;
3914
-				if (!empty($langs->tab_translate['unit'.$res->code]))	// check if Translation is available before
4438
+				if (!empty($langs->tab_translate['unit'.$res->code])) {
4439
+					// check if Translation is available before
3915 4440
 				{
3916 4441
 					$unitLabel = $langs->trans('unit'.$res->code) != $res->label ? $langs->trans('unit'.$res->code) : $res->label;
3917 4442
 				}
4443
+				}
3918 4444
 
3919 4445
 				if ($selected == $res->rowid)
3920 4446
 				{
@@ -3956,8 +4482,12 @@  discard block
 block discarded – undo
3956 4482
 		$sql = "SELECT rowid, label, bank, clos as status, currency_code";
3957 4483
 		$sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
3958 4484
 		$sql .= " WHERE entity IN (".getEntity('bank_account').")";
3959
-		if ($status != 2) $sql .= " AND clos = ".(int) $status;
3960
-		if ($filtre) $sql .= " AND ".$filtre;
4485
+		if ($status != 2) {
4486
+			$sql .= " AND clos = ".(int) $status;
4487
+		}
4488
+		if ($filtre) {
4489
+			$sql .= " AND ".$filtre;
4490
+		}
3961 4491
 		$sql .= " ORDER BY label";
3962 4492
 
3963 4493
 		dol_syslog(get_class($this)."::select_comptes", LOG_DEBUG);
@@ -3984,24 +4514,34 @@  discard block
 block discarded – undo
3984 4514
 						$out .= '<option value="'.$obj->rowid.'">';
3985 4515
 					}
3986 4516
 					$out .= trim($obj->label);
3987
-					if ($showcurrency) $out .= ' ('.$obj->currency_code.')';
3988
-					if ($status == 2 && $obj->status == 1) $out .= ' ('.$langs->trans("Closed").')';
4517
+					if ($showcurrency) {
4518
+						$out .= ' ('.$obj->currency_code.')';
4519
+					}
4520
+					if ($status == 2 && $obj->status == 1) {
4521
+						$out .= ' ('.$langs->trans("Closed").')';
4522
+					}
3989 4523
 					$out .= '</option>';
3990 4524
 					$i++;
3991 4525
 				}
3992 4526
 				$out .= "</select>";
3993 4527
 				$out .= ajax_combobox('select'.$htmlname);
3994 4528
 			} else {
3995
-				if ($status == 0) $out .= '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>';
3996
-				else $out .= '<span class="opacitymedium">'.$langs->trans("NoBankAccountFound").'</span>';
4529
+				if ($status == 0) {
4530
+					$out .= '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>';
4531
+				} else {
4532
+					$out .= '<span class="opacitymedium">'.$langs->trans("NoBankAccountFound").'</span>';
4533
+				}
3997 4534
 			}
3998 4535
 		} else {
3999 4536
 			dol_print_error($this->db);
4000 4537
 		}
4001 4538
 
4002 4539
 		// Output or return
4003
-		if (empty($nooutput)) print $out;
4004
-		else return $out;
4540
+		if (empty($nooutput)) {
4541
+			print $out;
4542
+		} else {
4543
+			return $out;
4544
+		}
4005 4545
 
4006 4546
 		return $num;
4007 4547
 	}
@@ -4028,8 +4568,12 @@  discard block
 block discarded – undo
4028 4568
 		$sql = "SELECT rowid, name, fk_country, status, entity";
4029 4569
 		$sql .= " FROM ".MAIN_DB_PREFIX."establishment";
4030 4570
 		$sql .= " WHERE 1=1";
4031
-		if ($status != 2) $sql .= " AND status = ".(int) $status;
4032
-		if ($filtre) $sql .= " AND ".$filtre;
4571
+		if ($status != 2) {
4572
+			$sql .= " AND status = ".(int) $status;
4573
+		}
4574
+		if ($filtre) {
4575
+			$sql .= " AND ".$filtre;
4576
+		}
4033 4577
 		$sql .= " ORDER BY name";
4034 4578
 
4035 4579
 		dol_syslog(get_class($this)."::select_establishment", LOG_DEBUG);
@@ -4056,14 +4600,19 @@  discard block
 block discarded – undo
4056 4600
 						print '<option value="'.$obj->rowid.'">';
4057 4601
 					}
4058 4602
 					print trim($obj->name);
4059
-					if ($status == 2 && $obj->status == 1) print ' ('.$langs->trans("Closed").')';
4603
+					if ($status == 2 && $obj->status == 1) {
4604
+						print ' ('.$langs->trans("Closed").')';
4605
+					}
4060 4606
 					print '</option>';
4061 4607
 					$i++;
4062 4608
 				}
4063 4609
 				print "</select>";
4064 4610
 			} else {
4065
-				if ($status == 0) print '<span class="opacitymedium">'.$langs->trans("NoActiveEstablishmentDefined").'</span>';
4066
-				else print '<span class="opacitymedium">'.$langs->trans("NoEstablishmentFound").'</span>';
4611
+				if ($status == 0) {
4612
+					print '<span class="opacitymedium">'.$langs->trans("NoActiveEstablishmentDefined").'</span>';
4613
+				} else {
4614
+					print '<span class="opacitymedium">'.$langs->trans("NoEstablishmentFound").'</span>';
4615
+				}
4067 4616
 			}
4068 4617
 		} else {
4069 4618
 			dol_print_error($this->db);
@@ -4087,7 +4636,9 @@  discard block
 block discarded – undo
4087 4636
 			print '<input type="hidden" name="action" value="setbankaccount">';
4088 4637
 			print '<input type="hidden" name="token" value="'.newToken().'">';
4089 4638
 			$nbaccountfound = $this->select_comptes($selected, $htmlname, 0, '', $addempty);
4090
-			if ($nbaccountfound > 0) print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
4639
+			if ($nbaccountfound > 0) {
4640
+				print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
4641
+			}
4091 4642
 			print '</form>';
4092 4643
 		} else {
4093 4644
 			$langs->load('banks');
@@ -4096,7 +4647,9 @@  discard block
 block discarded – undo
4096 4647
 				require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
4097 4648
 				$bankstatic = new Account($this->db);
4098 4649
 				$result = $bankstatic->fetch($selected);
4099
-				if ($result) print $bankstatic->getNomUrl(1);
4650
+				if ($result) {
4651
+					print $bankstatic->getNomUrl(1);
4652
+				}
4100 4653
 			} else {
4101 4654
 				print "&nbsp;";
4102 4655
 			}
@@ -4152,11 +4705,15 @@  discard block
 block discarded – undo
4152 4705
 				while ($i < $num)
4153 4706
 				{
4154 4707
 					$objp = $this->db->fetch_object($result);
4155
-					if ($objp) $cate_arbo[$objp->rowid] = array('id'=>$objp->rowid, 'fulllabel'=>$objp->label);
4708
+					if ($objp) {
4709
+						$cate_arbo[$objp->rowid] = array('id'=>$objp->rowid, 'fulllabel'=>$objp->label);
4710
+					}
4156 4711
 					$i++;
4157 4712
 				}
4158 4713
 				$this->db->free($result);
4159
-			} else dol_print_error($this->db);
4714
+			} else {
4715
+				dol_print_error($this->db);
4716
+			}
4160 4717
 		} else {
4161 4718
 			$cat = new Categorie($this->db);
4162 4719
 			$cate_arbo = $cat->get_full_arbo($type, $markafterid, $include);
@@ -4166,8 +4723,9 @@  discard block
 block discarded – undo
4166 4723
 		$outarray = array();
4167 4724
 		if (is_array($cate_arbo))
4168 4725
 		{
4169
-			if (!count($cate_arbo)) $output .= '<option value="-1" disabled>'.$langs->trans("NoCategoriesDefined").'</option>';
4170
-			else {
4726
+			if (!count($cate_arbo)) {
4727
+				$output .= '<option value="-1" disabled>'.$langs->trans("NoCategoriesDefined").'</option>';
4728
+			} else {
4171 4729
 				$output .= '<option value="-1">&nbsp;</option>';
4172 4730
 				foreach ($cate_arbo as $key => $value)
4173 4731
 				{
@@ -4186,7 +4744,9 @@  discard block
 block discarded – undo
4186 4744
 		$output .= '</select>';
4187 4745
 		$output .= "\n";
4188 4746
 
4189
-		if ($outputmode) return $outarray;
4747
+		if ($outputmode) {
4748
+			return $outarray;
4749
+		}
4190 4750
 		return $output;
4191 4751
 	}
4192 4752
 
@@ -4249,7 +4809,9 @@  discard block
 block discarded – undo
4249 4809
 
4250 4810
 		// Clean parameters
4251 4811
 		$newselectedchoice = empty($selectedchoice) ? "no" : $selectedchoice;
4252
-		if ($conf->browser->layout == 'phone') $width = '95%';
4812
+		if ($conf->browser->layout == 'phone') {
4813
+			$width = '95%';
4814
+		}
4253 4815
 
4254 4816
 		// Set height automatically if not defined
4255 4817
 		if (empty($height)) {
@@ -4293,7 +4855,9 @@  discard block
 block discarded – undo
4293 4855
 					} elseif ($input['type'] == 'select')
4294 4856
 					{
4295 4857
 						$more .= '<div class="tagtr"><div class="tagtd'.(empty($input['tdclass']) ? '' : (' '.$input['tdclass'])).'">';
4296
-						if (!empty($input['label'])) $more .= $input['label'].'</div><div class="tagtd left">';
4858
+						if (!empty($input['label'])) {
4859
+							$more .= $input['label'].'</div><div class="tagtd left">';
4860
+						}
4297 4861
 						$more .= $this->selectarray($input['name'], $input['values'], $input['default'], 1, 0, 0, $moreattr, 0, 0, 0, '', $morecss);
4298 4862
 						$more .= '</div></div>'."\n";
4299 4863
 					} elseif ($input['type'] == 'checkbox')
@@ -4301,9 +4865,15 @@  discard block
 block discarded – undo
4301 4865
 						$more .= '<div class="tagtr">';
4302 4866
 						$more .= '<div class="tagtd'.(empty($input['tdclass']) ? '' : (' '.$input['tdclass'])).'">'.$input['label'].' </div><div class="tagtd">';
4303 4867
 						$more .= '<input type="checkbox" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$moreattr;
4304
-						if (!is_bool($input['value']) && $input['value'] != 'false' && $input['value'] != '0') $more .= ' checked';
4305
-						if (is_bool($input['value']) && $input['value']) $more .= ' checked';
4306
-						if (isset($input['disabled'])) $more .= ' disabled';
4868
+						if (!is_bool($input['value']) && $input['value'] != 'false' && $input['value'] != '0') {
4869
+							$more .= ' checked';
4870
+						}
4871
+						if (is_bool($input['value']) && $input['value']) {
4872
+							$more .= ' checked';
4873
+						}
4874
+						if (isset($input['disabled'])) {
4875
+							$more .= ' disabled';
4876
+						}
4307 4877
 						$more .= ' /></div>';
4308 4878
 						$more .= '</div>'."\n";
4309 4879
 					} elseif ($input['type'] == 'radio')
@@ -4312,11 +4882,18 @@  discard block
 block discarded – undo
4312 4882
 						foreach ($input['values'] as $selkey => $selval)
4313 4883
 						{
4314 4884
 							$more .= '<div class="tagtr">';
4315
-							if ($i == 0) $more .= '<div class="tagtd'.(empty($input['tdclass']) ? ' tdtop' : (' tdtop '.$input['tdclass'])).'">'.$input['label'].'</div>';
4316
-							else $more .= '<div clas="tagtd'.(empty($input['tdclass']) ? '' : (' "'.$input['tdclass'])).'">&nbsp;</div>';
4885
+							if ($i == 0) {
4886
+								$more .= '<div class="tagtd'.(empty($input['tdclass']) ? ' tdtop' : (' tdtop '.$input['tdclass'])).'">'.$input['label'].'</div>';
4887
+							} else {
4888
+								$more .= '<div clas="tagtd'.(empty($input['tdclass']) ? '' : (' "'.$input['tdclass'])).'">&nbsp;</div>';
4889
+							}
4317 4890
 							$more .= '<div class="tagtd'.($i == 0 ? ' tdtop' : '').'"><input type="radio" class="flat'.$morecss.'" id="'.$input['name'].$selkey.'" name="'.$input['name'].'" value="'.$selkey.'"'.$moreattr;
4318
-							if ($input['disabled']) $more .= ' disabled';
4319
-							if (isset($input['default']) && $input['default'] === $selkey) $more .= ' checked="checked"';
4891
+							if ($input['disabled']) {
4892
+								$more .= ' disabled';
4893
+							}
4894
+							if (isset($input['default']) && $input['default'] === $selkey) {
4895
+								$more .= ' checked="checked"';
4896
+							}
4320 4897
 							$more .= ' /> ';
4321 4898
 							$more .= '<label for="'.$input['name'].$selkey.'">'.$selval.'</label>';
4322 4899
 							$more .= '</div></div>'."\n";
@@ -4336,7 +4913,9 @@  discard block
 block discarded – undo
4336 4913
 					} elseif ($input['type'] == 'other')
4337 4914
 					{
4338 4915
 						$more .= '<div class="tagtr"><div class="tagtd'.(empty($input['tdclass']) ? '' : (' '.$input['tdclass'])).'">';
4339
-						if (!empty($input['label'])) $more .= $input['label'].'</div><div class="tagtd">';
4916
+						if (!empty($input['label'])) {
4917
+							$more .= $input['label'].'</div><div class="tagtd">';
4918
+						}
4340 4919
 						$more .= $input['value'];
4341 4920
 						$more .= '</div></div>'."\n";
4342 4921
 					} elseif ($input['type'] == 'onecolumn')
@@ -4354,8 +4933,12 @@  discard block
 block discarded – undo
4354 4933
 		// JQUI method dialog is broken with jmobile, we use standard HTML.
4355 4934
 		// Note: When using dol_use_jmobile or no js, you must also check code for button use a GET url with action=xxx and check that you also output the confirm code when action=xxx
4356 4935
 		// See page product/card.php for example
4357
-		if (!empty($conf->dol_use_jmobile)) $useajax = 0;
4358
-		if (empty($conf->use_javascript_ajax)) $useajax = 0;
4936
+		if (!empty($conf->dol_use_jmobile)) {
4937
+			$useajax = 0;
4938
+		}
4939
+		if (empty($conf->use_javascript_ajax)) {
4940
+			$useajax = 0;
4941
+		}
4359 4942
 
4360 4943
 		if ($useajax)
4361 4944
 		{
@@ -4377,8 +4960,12 @@  discard block
 block discarded – undo
4377 4960
 				foreach ($formquestion as $key => $input)
4378 4961
 				{
4379 4962
 					//print "xx ".$key." rr ".is_array($input)."<br>\n";
4380
-					if (is_array($input) && isset($input['name'])) array_push($inputok, $input['name']);
4381
-					if (isset($input['inputko']) && $input['inputko'] == 1) array_push($inputko, $input['name']);
4963
+					if (is_array($input) && isset($input['name'])) {
4964
+						array_push($inputok, $input['name']);
4965
+					}
4966
+					if (isset($input['inputko']) && $input['inputko'] == 1) {
4967
+						array_push($inputko, $input['name']);
4968
+					}
4382 4969
 				}
4383 4970
 			}
4384 4971
 			// Show JQuery confirm box.
@@ -4466,7 +5053,9 @@  discard block
 block discarded – undo
4466 5053
 		} else {
4467 5054
 			$formconfirm .= "\n<!-- begin formconfirm page=".dol_escape_htmltag($page)." -->\n";
4468 5055
 
4469
-			if (empty($disableformtag)) $formconfirm .= '<form method="POST" action="'.$page.'" class="notoptoleftroright">'."\n";
5056
+			if (empty($disableformtag)) {
5057
+				$formconfirm .= '<form method="POST" action="'.$page.'" class="notoptoleftroright">'."\n";
5058
+			}
4470 5059
 
4471 5060
 			$formconfirm .= '<input type="hidden" name="action" value="'.$action.'">'."\n";
4472 5061
 			$formconfirm .= '<input type="hidden" name="token" value="'.newToken().'">'."\n";
@@ -4500,7 +5089,9 @@  discard block
 block discarded – undo
4500 5089
 
4501 5090
 			$formconfirm .= '</table>'."\n";
4502 5091
 
4503
-			if (empty($disableformtag)) $formconfirm .= "</form>\n";
5092
+			if (empty($disableformtag)) {
5093
+				$formconfirm .= "</form>\n";
5094
+			}
4504 5095
 			$formconfirm .= '<br>';
4505 5096
 
4506 5097
 			if (empty($conf->use_javascript_ajax)) {
@@ -4720,11 +5311,16 @@  discard block
 block discarded – undo
4720 5311
 			$ret .= '<td class="left"><input type="submit" class="button smallpaddingimp" value="'.$langs->trans("Modify").'"></td>';
4721 5312
 			$ret .= '</tr></table></form>';
4722 5313
 		} else {
4723
-			if ($displayhour) $ret .= dol_print_date($selected, 'dayhour');
4724
-			else $ret .= dol_print_date($selected, 'day');
5314
+			if ($displayhour) {
5315
+				$ret .= dol_print_date($selected, 'dayhour');
5316
+			} else {
5317
+				$ret .= dol_print_date($selected, 'day');
5318
+			}
4725 5319
 		}
4726 5320
 
4727
-		if (empty($nooutput)) print $ret;
5321
+		if (empty($nooutput)) {
5322
+			print $ret;
5323
+		}
4728 5324
 		return $ret;
4729 5325
 	}
4730 5326
 
@@ -4823,8 +5419,7 @@  discard block
 block discarded – undo
4823 5419
 			$this->selectTransportMode($selected, $htmlname, 2, $addempty, 0, 0, $active);
4824 5420
 			print '<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans("Modify").'">';
4825 5421
 			print '</form>';
4826
-		}
4827
-		else {
5422
+		} else {
4828 5423
 			if ($selected)
4829 5424
 			{
4830 5425
 				$this->load_cache_transport_mode();
@@ -4893,7 +5488,9 @@  discard block
 block discarded – undo
4893 5488
 			if (!empty($rate))
4894 5489
 			{
4895 5490
 				print price($rate, 1, $langs, 1, 0);
4896
-				if ($currency && $rate != 1) print ' &nbsp; ('.price($rate, 1, $langs, 1, 0).' '.$currency.' = 1 '.$conf->currency.')';
5491
+				if ($currency && $rate != 1) {
5492
+					print ' &nbsp; ('.price($rate, 1, $langs, 1, 0).' '.$currency.' = 1 '.$conf->currency.')';
5493
+				}
4897 5494
 			} else {
4898 5495
 				print 1;
4899 5496
 			}
@@ -4930,24 +5527,42 @@  discard block
 block discarded – undo
4930 5527
 			if (!empty($discount_type)) {
4931 5528
 				if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
4932 5529
 				{
4933
-					if (!$filter || $filter == "fk_invoice_supplier_source IS NULL") $translationKey = 'HasAbsoluteDiscountFromSupplier'; // If we want deposit to be substracted to payments only and not to total of final invoice
4934
-					else $translationKey = 'HasCreditNoteFromSupplier';
5530
+					if (!$filter || $filter == "fk_invoice_supplier_source IS NULL") {
5531
+						$translationKey = 'HasAbsoluteDiscountFromSupplier';
5532
+					}
5533
+					// If we want deposit to be substracted to payments only and not to total of final invoice
5534
+					else {
5535
+						$translationKey = 'HasCreditNoteFromSupplier';
5536
+					}
4935 5537
 				} else {
4936
-					if (!$filter || $filter == "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") $translationKey = 'HasAbsoluteDiscountFromSupplier';
4937
-					else $translationKey = 'HasCreditNoteFromSupplier';
5538
+					if (!$filter || $filter == "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") {
5539
+						$translationKey = 'HasAbsoluteDiscountFromSupplier';
5540
+					} else {
5541
+						$translationKey = 'HasCreditNoteFromSupplier';
5542
+					}
4938 5543
 				}
4939 5544
 			} else {
4940 5545
 				if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
4941 5546
 				{
4942
-					if (!$filter || $filter == "fk_facture_source IS NULL") $translationKey = 'CompanyHasAbsoluteDiscount'; // If we want deposit to be substracted to payments only and not to total of final invoice
4943
-					else $translationKey = 'CompanyHasCreditNote';
5547
+					if (!$filter || $filter == "fk_facture_source IS NULL") {
5548
+						$translationKey = 'CompanyHasAbsoluteDiscount';
5549
+					}
5550
+					// If we want deposit to be substracted to payments only and not to total of final invoice
5551
+					else {
5552
+						$translationKey = 'CompanyHasCreditNote';
5553
+					}
4944 5554
 				} else {
4945
-					if (!$filter || $filter == "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") $translationKey = 'CompanyHasAbsoluteDiscount';
4946
-					else $translationKey = 'CompanyHasCreditNote';
5555
+					if (!$filter || $filter == "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") {
5556
+						$translationKey = 'CompanyHasAbsoluteDiscount';
5557
+					} else {
5558
+						$translationKey = 'CompanyHasCreditNote';
5559
+					}
4947 5560
 				}
4948 5561
 			}
4949 5562
 			print $langs->trans($translationKey, price($amount, 0, $langs, 0, 0, -1, $conf->currency));
4950
-			if (empty($hidelist)) print ': ';
5563
+			if (empty($hidelist)) {
5564
+				print ': ';
5565
+			}
4951 5566
 			print '</div>';
4952 5567
 			if (empty($hidelist))
4953 5568
 			{
@@ -4958,15 +5573,19 @@  discard block
 block discarded – undo
4958 5573
 				} else {
4959 5574
 					$newfilter .= ' AND fk_facture IS NULL AND fk_facture_line IS NULL'; // Customer discounts available
4960 5575
 				}
4961
-				if ($filter) $newfilter .= ' AND ('.$filter.')';
5576
+				if ($filter) {
5577
+					$newfilter .= ' AND ('.$filter.')';
5578
+				}
4962 5579
 				$nbqualifiedlines = $this->select_remises($selected, $htmlname, $newfilter, $socid, $maxvalue);
4963 5580
 				if ($nbqualifiedlines > 0)
4964 5581
 				{
4965 5582
 					print ' &nbsp; <input type="submit" class="button smallpaddingimp" value="'.dol_escape_htmltag($langs->trans("UseLine")).'"';
4966
-					if (!empty($discount_type) && $filter && $filter != "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')")
4967
-						print ' title="'.$langs->trans("UseCreditNoteInInvoicePayment").'"';
4968
-					if (empty($discount_type) && $filter && $filter != "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')")
4969
-						print ' title="'.$langs->trans("UseCreditNoteInInvoicePayment").'"';
5583
+					if (!empty($discount_type) && $filter && $filter != "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") {
5584
+											print ' title="'.$langs->trans("UseCreditNoteInInvoicePayment").'"';
5585
+					}
5586
+					if (empty($discount_type) && $filter && $filter != "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") {
5587
+											print ' title="'.$langs->trans("UseCreditNoteInInvoicePayment").'"';
5588
+					}
4970 5589
 
4971 5590
 					print '>';
4972 5591
 				}
@@ -5076,8 +5695,11 @@  discard block
 block discarded – undo
5076 5695
 			}
5077 5696
 		}
5078 5697
 
5079
-		if ($nooutput) return $out;
5080
-		else print $out;
5698
+		if ($nooutput) {
5699
+			return $out;
5700
+		} else {
5701
+			print $out;
5702
+		}
5081 5703
 	}
5082 5704
 
5083 5705
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -5111,7 +5733,10 @@  discard block
 block discarded – undo
5111 5733
 
5112 5734
 		$out = '';
5113 5735
 
5114
-		if ($selected == 'euro' || $selected == 'euros') $selected = 'EUR'; // Pour compatibilite
5736
+		if ($selected == 'euro' || $selected == 'euros') {
5737
+			$selected = 'EUR';
5738
+		}
5739
+		// Pour compatibilite
5115 5740
 
5116 5741
 		$out .= '<select class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.'" id="'.$htmlname.'">';
5117 5742
 		foreach ($langs->cache_currencies as $code_iso => $currency)
@@ -5134,7 +5759,9 @@  discard block
 block discarded – undo
5134 5759
 			$out .= '</option>';
5135 5760
 		}
5136 5761
 		$out .= '</select>';
5137
-		if ($user->admin) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
5762
+		if ($user->admin) {
5763
+			$out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
5764
+		}
5138 5765
 
5139 5766
 		// Make select dynamic
5140 5767
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
@@ -5163,16 +5790,22 @@  discard block
 block discarded – undo
5163 5790
 
5164 5791
 		$sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
5165 5792
 		$sql .= " WHERE entity IN ('".getEntity('mutlicurrency')."')";
5166
-		if ($filter) $sql .= " AND ".$filter;
5793
+		if ($filter) {
5794
+			$sql .= " AND ".$filter;
5795
+		}
5167 5796
 		$resql = $this->db->query($sql);
5168 5797
 		if ($resql)
5169 5798
 		{
5170
-			while ($obj = $this->db->fetch_object($resql)) $TCurrency[$obj->code] = $obj->code;
5799
+			while ($obj = $this->db->fetch_object($resql)) {
5800
+				$TCurrency[$obj->code] = $obj->code;
5801
+			}
5171 5802
 		}
5172 5803
 
5173 5804
 		$out = '';
5174 5805
 		$out .= '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
5175
-		if ($useempty) $out .= '<option value="">&nbsp;</option>';
5806
+		if ($useempty) {
5807
+			$out .= '<option value="">&nbsp;</option>';
5808
+		}
5176 5809
 		// If company current currency not in table, we add it into list. Should always be available.
5177 5810
 		if (!in_array($conf->currency, $TCurrency) && !$excludeConfCurrency)
5178 5811
 		{
@@ -5184,8 +5817,11 @@  discard block
 block discarded – undo
5184 5817
 			{
5185 5818
 				if (isset($TCurrency[$code_iso]))
5186 5819
 				{
5187
-					if (!empty($selected) && $selected == $code_iso) $out .= '<option value="'.$code_iso.'" selected="selected">';
5188
-					else $out .= '<option value="'.$code_iso.'">';
5820
+					if (!empty($selected) && $selected == $code_iso) {
5821
+						$out .= '<option value="'.$code_iso.'" selected="selected">';
5822
+					} else {
5823
+						$out .= '<option value="'.$code_iso.'">';
5824
+					}
5189 5825
 
5190 5826
 					$out .= $currency['label'];
5191 5827
 					$out .= ' ('.$langs->getCurrencySymbol($code_iso).')';
@@ -5215,7 +5851,10 @@  discard block
 block discarded – undo
5215 5851
 		global $langs;
5216 5852
 
5217 5853
 		$num = count($this->cache_vatrates);
5218
-		if ($num > 0) return $num; // Cache already loaded
5854
+		if ($num > 0) {
5855
+			return $num;
5856
+		}
5857
+		// Cache already loaded
5219 5858
 
5220 5859
 		dol_syslog(__METHOD__, LOG_DEBUG);
5221 5860
 
@@ -5247,10 +5886,18 @@  discard block
 block discarded – undo
5247 5886
 					$this->cache_vatrates[$i]['label'] = $obj->taux.'%'.($obj->code ? ' ('.$obj->code.')' : ''); // Label must contains only 0-9 , . % or *
5248 5887
 					$this->cache_vatrates[$i]['labelallrates'] = $obj->taux.'/'.($obj->localtax1 ? $obj->localtax1 : '0').'/'.($obj->localtax2 ? $obj->localtax2 : '0').($obj->code ? ' ('.$obj->code.')' : ''); // Must never be used as key, only label
5249 5888
 					$positiverates = '';
5250
-					if ($obj->taux) $positiverates .= ($positiverates ? '/' : '').$obj->taux;
5251
-					if ($obj->localtax1) $positiverates .= ($positiverates ? '/' : '').$obj->localtax1;
5252
-					if ($obj->localtax2) $positiverates .= ($positiverates ? '/' : '').$obj->localtax2;
5253
-					if (empty($positiverates)) $positiverates = '0';
5889
+					if ($obj->taux) {
5890
+						$positiverates .= ($positiverates ? '/' : '').$obj->taux;
5891
+					}
5892
+					if ($obj->localtax1) {
5893
+						$positiverates .= ($positiverates ? '/' : '').$obj->localtax1;
5894
+					}
5895
+					if ($obj->localtax2) {
5896
+						$positiverates .= ($positiverates ? '/' : '').$obj->localtax2;
5897
+					}
5898
+					if (empty($positiverates)) {
5899
+						$positiverates = '0';
5900
+					}
5254 5901
 					$this->cache_vatrates[$i]['labelpositiverates'] = $positiverates.($obj->code ? ' ('.$obj->code.')' : ''); // Must never be used as key, only label
5255 5902
 				}
5256 5903
 
@@ -5332,28 +5979,36 @@  discard block
 block discarded – undo
5332 5979
 		} else {
5333 5980
 			$code_country = "'".$mysoc->country_code."'"; // Pour compatibilite ascendente
5334 5981
 		}
5335
-		if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC))    // If option to have vat for end customer for services is on
5982
+		if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) {
5983
+			// If option to have vat for end customer for services is on
5336 5984
 		{
5337 5985
 			require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
5986
+		}
5338 5987
 			if (!isInEEC($societe_vendeuse) && (!is_object($societe_acheteuse) || (isInEEC($societe_acheteuse) && !$societe_acheteuse->isACompany())))
5339 5988
 			{
5340 5989
 				// We also add the buyer
5341 5990
 				if (is_numeric($type))
5342 5991
 				{
5343
-					if ($type == 1) // We know product is a service
5992
+					if ($type == 1) {
5993
+						// We know product is a service
5344 5994
 					{
5345 5995
 						$code_country .= ",'".$societe_acheteuse->country_code."'";
5346 5996
 					}
5347
-				} elseif (!$idprod)  // We don't know type of product
5997
+					}
5998
+				} elseif (!$idprod) {
5999
+					// We don't know type of product
5348 6000
 				{
5349 6001
 					$code_country .= ",'".$societe_acheteuse->country_code."'";
6002
+				}
5350 6003
 				} else {
5351 6004
 					$prodstatic = new Product($this->db);
5352 6005
 					$prodstatic->fetch($idprod);
5353
-					if ($prodstatic->type == Product::TYPE_SERVICE)   // We know product is a service
6006
+					if ($prodstatic->type == Product::TYPE_SERVICE) {
6007
+						// We know product is a service
5354 6008
 					{
5355 6009
 						$code_country .= ",'".$societe_acheteuse->country_code."'";
5356 6010
 					}
6011
+					}
5357 6012
 				}
5358 6013
 			}
5359 6014
 		}
@@ -5373,15 +6028,20 @@  discard block
 block discarded – undo
5373 6028
 					$defaultcode = $reg[1];
5374 6029
 					$defaulttx = preg_replace('/\s*\(.*\)/', '', $defaulttx);
5375 6030
 				}
5376
-				if (empty($defaulttx)) $defaultnpr = 0;
6031
+				if (empty($defaulttx)) {
6032
+					$defaultnpr = 0;
6033
+				}
5377 6034
 			}
5378 6035
 
5379 6036
 			// Si taux par defaut n'a pu etre determine, on prend dernier de la liste.
5380 6037
 			// Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant
5381 6038
 			if ($defaulttx < 0 || dol_strlen($defaulttx) == 0)
5382 6039
 			{
5383
-				if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) $defaulttx = $this->cache_vatrates[$num - 1]['txtva'];
5384
-				else $defaulttx = ($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS == 'none' ? '' : $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS);
6040
+				if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) {
6041
+					$defaulttx = $this->cache_vatrates[$num - 1]['txtva'];
6042
+				} else {
6043
+					$defaulttx = ($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS == 'none' ? '' : $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS);
6044
+				}
5385 6045
 			}
5386 6046
 
5387 6047
 			// Disabled if seller is not subject to VAT
@@ -5397,28 +6057,38 @@  discard block
 block discarded – undo
5397 6057
 				}
5398 6058
 			}
5399 6059
 
5400
-			if (!$options_only) $return .= '<select class="flat minwidth75imp" id="'.$htmlname.'" name="'.$htmlname.'"'.($disabled ? ' disabled' : '').$title.'>';
6060
+			if (!$options_only) {
6061
+				$return .= '<select class="flat minwidth75imp" id="'.$htmlname.'" name="'.$htmlname.'"'.($disabled ? ' disabled' : '').$title.'>';
6062
+			}
5401 6063
 
5402 6064
 			$selectedfound = false;
5403 6065
 			foreach ($this->cache_vatrates as $rate)
5404 6066
 			{
5405 6067
 				// Keep only 0 if seller is not subject to VAT
5406
-				if ($disabled && $rate['txtva'] != 0) continue;
6068
+				if ($disabled && $rate['txtva'] != 0) {
6069
+					continue;
6070
+				}
5407 6071
 
5408 6072
 				// Define key to use into select list
5409 6073
 				$key = $rate['txtva'];
5410 6074
 				$key .= $rate['nprtva'] ? '*' : '';
5411
-				if ($mode > 0 && $rate['code']) $key .= ' ('.$rate['code'].')';
5412
-				if ($mode < 0) $key = $rate['rowid'];
6075
+				if ($mode > 0 && $rate['code']) {
6076
+					$key .= ' ('.$rate['code'].')';
6077
+				}
6078
+				if ($mode < 0) {
6079
+					$key = $rate['rowid'];
6080
+				}
5413 6081
 
5414 6082
 				$return .= '<option value="'.$key.'"';
5415 6083
 				if (!$selectedfound)
5416 6084
 				{
5417
-					if ($defaultcode) // If defaultcode is defined, we used it in priority to select combo option instead of using rate+npr flag
6085
+					if ($defaultcode) {
6086
+						// If defaultcode is defined, we used it in priority to select combo option instead of using rate+npr flag
5418 6087
 					{
5419 6088
 						if ($defaultcode == $rate['code'])
5420 6089
 						{
5421 6090
 							$return .= ' selected';
6091
+					}
5422 6092
 							$selectedfound = true;
5423 6093
 						}
5424 6094
 					} elseif ($rate['txtva'] == $defaulttx && $rate['nprtva'] == $defaultnpr)
@@ -5441,7 +6111,9 @@  discard block
 block discarded – undo
5441 6111
 				$return .= '</option>';
5442 6112
 			}
5443 6113
 
5444
-			if (!$options_only) $return .= '</select>';
6114
+			if (!$options_only) {
6115
+				$return .= '</select>';
6116
+			}
5445 6117
 		} else {
5446 6118
 			$return .= $this->error;
5447 6119
 		}
@@ -5541,12 +6213,20 @@  discard block
 block discarded – undo
5541 6213
 
5542 6214
 		$retstring = '';
5543 6215
 
5544
-		if ($prefix == '') $prefix = 're';
5545
-		if ($h == '') $h = 0;
5546
-		if ($m == '') $m = 0;
6216
+		if ($prefix == '') {
6217
+			$prefix = 're';
6218
+		}
6219
+		if ($h == '') {
6220
+			$h = 0;
6221
+		}
6222
+		if ($m == '') {
6223
+			$m = 0;
6224
+		}
5547 6225
 		$emptydate = 0;
5548 6226
 		$emptyhours = 0;
5549
-		if ($stepminutes <= 0 || $stepminutes > 30) $stepminutes = 1;
6227
+		if ($stepminutes <= 0 || $stepminutes > 30) {
6228
+			$stepminutes = 1;
6229
+		}
5550 6230
 		if ($empty == 1) { $emptydate = 1; $emptyhours = 1; }
5551 6231
 		if ($empty == 2) { $emptydate = 0; $emptyhours = 1; }
5552 6232
 		$orig_set_time = $set_time;
@@ -5559,10 +6239,12 @@  discard block
 block discarded – undo
5559 6239
 
5560 6240
 		// Analysis of the pre-selection date
5561 6241
 		$reg = array();
5562
-		if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/', $set_time, $reg))	// deprecated usage
6242
+		if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/', $set_time, $reg)) {
6243
+			// deprecated usage
5563 6244
 		{
5564 6245
 			// Date format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS'
5565 6246
 			$syear	= (!empty($reg[1]) ? $reg[1] : '');
6247
+		}
5566 6248
 			$smonth = (!empty($reg[2]) ? $reg[2] : '');
5567 6249
 			$sday	= (!empty($reg[3]) ? $reg[3] : '');
5568 6250
 			$shour	= (!empty($reg[4]) ? $reg[4] : '');
@@ -5592,8 +6274,12 @@  discard block
 block discarded – undo
5592 6274
 			$smin = !isset($conf->global->MAIN_DEFAULT_DATE_MIN) ? ($h == -1 ? '59' : '') : $conf->global->MAIN_DEFAULT_DATE_MIN;
5593 6275
 			$ssec = !isset($conf->global->MAIN_DEFAULT_DATE_SEC) ? ($h == -1 ? '59' : '') : $conf->global->MAIN_DEFAULT_DATE_SEC;
5594 6276
 		}
5595
-		if ($h == 3) $shour = '';
5596
-		if ($m == 3) $smin = '';
6277
+		if ($h == 3) {
6278
+			$shour = '';
6279
+		}
6280
+		if ($m == 3) {
6281
+			$smin = '';
6282
+		}
5597 6283
 
5598 6284
 		// You can set MAIN_POPUP_CALENDAR to 'eldy' or 'jquery'
5599 6285
 		$usecalendar = 'combo';
@@ -5630,7 +6316,9 @@  discard block
 block discarded – undo
5630 6316
 						$base = DOL_URL_ROOT.'/core/';
5631 6317
 						$retstring .= ' onClick="showDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\',\''.$langs->defaultlang.'\');"';
5632 6318
 						$retstring .= '>'.img_object($langs->trans("SelectDate"), 'calendarday', 'class="datecallink"').'</button>';
5633
-					} else $retstring .= '<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons">'.img_object($langs->trans("Disabled"), 'calendarday', 'class="datecallink"').'</button>';
6319
+					} else {
6320
+						$retstring .= '<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons">'.img_object($langs->trans("Disabled"), 'calendarday', 'class="datecallink"').'</button>';
6321
+					}
5634 6322
 
5635 6323
 					$retstring .= '<input type="hidden" id="'.$prefix.'day"   name="'.$prefix.'day"   value="'.$sday.'">'."\n";
5636 6324
 					$retstring .= '<input type="hidden" id="'.$prefix.'month" name="'.$prefix.'month" value="'.$smonth.'">'."\n";
@@ -5762,31 +6450,43 @@  discard block
 block discarded – undo
5762 6450
 				$openinghours = explode(',', $openinghours);
5763 6451
 				$hourstart = $openinghours[0];
5764 6452
 				$hourend = $openinghours[1];
5765
-				if ($hourend < $hourstart) $hourend = $hourstart;
6453
+				if ($hourend < $hourstart) {
6454
+					$hourend = $hourstart;
6455
+				}
5766 6456
 			}
5767 6457
 			// Show hour
5768 6458
 			$retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth50 '.($fullday ? $fullday.'hour' : '').'" id="'.$prefix.'hour" name="'.$prefix.'hour">';
5769
-			if ($emptyhours) $retstring .= '<option value="-1">&nbsp;</option>';
6459
+			if ($emptyhours) {
6460
+				$retstring .= '<option value="-1">&nbsp;</option>';
6461
+			}
5770 6462
 			for ($hour = $hourstart; $hour < $hourend; $hour++)
5771 6463
 			{
5772
-				if (strlen($hour) < 2) $hour = "0".$hour;
6464
+				if (strlen($hour) < 2) {
6465
+					$hour = "0".$hour;
6466
+				}
5773 6467
 				$retstring .= '<option value="'.$hour.'"'.(($hour == $shour) ? ' selected' : '').'>'.$hour;
5774 6468
 				//$retstring .= (empty($conf->dol_optimize_smallscreen) ? '' : 'H');
5775 6469
 				$retstring .= '</option>';
5776 6470
 			}
5777 6471
 			$retstring .= '</select>';
5778 6472
 			//if ($m && empty($conf->dol_optimize_smallscreen)) $retstring .= ":";
5779
-			if ($m) $retstring .= ":";
6473
+			if ($m) {
6474
+				$retstring .= ":";
6475
+			}
5780 6476
 		}
5781 6477
 
5782 6478
 		if ($m)
5783 6479
 		{
5784 6480
 			// Show minutes
5785 6481
 			$retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth50 '.($fullday ? $fullday.'min' : '').'" id="'.$prefix.'min" name="'.$prefix.'min">';
5786
-			if ($emptyhours) $retstring .= '<option value="-1">&nbsp;</option>';
6482
+			if ($emptyhours) {
6483
+				$retstring .= '<option value="-1">&nbsp;</option>';
6484
+			}
5787 6485
 			for ($min = 0; $min < 60; $min += $stepminutes)
5788 6486
 			{
5789
-				if (strlen($min) < 2) $min = "0".$min;
6487
+				if (strlen($min) < 2) {
6488
+					$min = "0".$min;
6489
+				}
5790 6490
 				$retstring .= '<option value="'.$min.'"'.(($min == $smin) ? ' selected' : '').'>'.$min.(empty($conf->dol_optimize_smallscreen) ? '' : '').'</option>';
5791 6491
 			}
5792 6492
 			$retstring .= '</select>';
@@ -5803,7 +6503,8 @@  discard block
 block discarded – undo
5803 6503
 		{
5804 6504
 			// Script which will be inserted in the onClick of the "Now" link
5805 6505
 			$reset_scripts = "";
5806
-			if ($addnowlink == 2) // local computer time
6506
+			if ($addnowlink == 2) {
6507
+				// local computer time
5807 6508
 			{
5808 6509
 				// pad add leading 0 on numbers
5809 6510
 				$reset_scripts .= "Number.prototype.pad = function(size) {
@@ -5813,11 +6514,14 @@  discard block
 block discarded – undo
5813 6514
                     };
5814 6515
                     var d = new Date();";
5815 6516
 			}
6517
+			}
5816 6518
 
5817 6519
 			// Generate the date part, depending on the use or not of the javascript calendar
5818
-			if ($addnowlink == 1) // server time expressed in user time setup
6520
+			if ($addnowlink == 1) {
6521
+				// server time expressed in user time setup
5819 6522
 			{
5820 6523
 				$reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day', 'tzuser').'\');';
6524
+			}
5821 6525
 				$reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d', 'tzuser').'\');';
5822 6526
 				$reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m', 'tzuser').'\');';
5823 6527
 				$reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y', 'tzuser').'\');';
@@ -5849,7 +6553,9 @@  discard block
 block discarded – undo
5849 6553
 			// Update the hour part
5850 6554
 			if ($h)
5851 6555
 			{
5852
-				if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
6556
+				if ($fullday) {
6557
+					$reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
6558
+				}
5853 6559
 				//$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); ';
5854 6560
 				if ($addnowlink == 1)
5855 6561
 				{
@@ -5861,12 +6567,16 @@  discard block
 block discarded – undo
5861 6567
 					$reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();';
5862 6568
 				}
5863 6569
 
5864
-				if ($fullday) $reset_scripts .= ' } ';
6570
+				if ($fullday) {
6571
+					$reset_scripts .= ' } ';
6572
+				}
5865 6573
 			}
5866 6574
 			// Update the minute part
5867 6575
 			if ($m)
5868 6576
 			{
5869
-				if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
6577
+				if ($fullday) {
6578
+					$reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
6579
+				}
5870 6580
 				//$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); ';
5871 6581
 				if ($addnowlink == 1)
5872 6582
 				{
@@ -5877,7 +6587,9 @@  discard block
 block discarded – undo
5877 6587
 					$reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(d.getMinutes().pad());';
5878 6588
 					$reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();';
5879 6589
 				}
5880
-				if ($fullday) $reset_scripts .= ' } ';
6590
+				if ($fullday) {
6591
+					$reset_scripts .= ' } ';
6592
+				}
5881 6593
 			}
5882 6594
 			// If reset_scripts is not empty, print the link with the reset_scripts in the onClick
5883 6595
 			if ($reset_scripts && empty($conf->dol_optimize_smallscreen))
@@ -5902,16 +6614,24 @@  discard block
 block discarded – undo
5902 6614
 			// Update the hour part
5903 6615
 			if ($h)
5904 6616
 			{
5905
-				if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
6617
+				if ($fullday) {
6618
+					$reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
6619
+				}
5906 6620
 				$reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H').'\');';
5907
-				if ($fullday) $reset_scripts .= ' } ';
6621
+				if ($fullday) {
6622
+					$reset_scripts .= ' } ';
6623
+				}
5908 6624
 			}
5909 6625
 			// Update the minute part
5910 6626
 			if ($m)
5911 6627
 			{
5912
-				if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
6628
+				if ($fullday) {
6629
+					$reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
6630
+				}
5913 6631
 				$reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M').'\');';
5914
-				if ($fullday) $reset_scripts .= ' } ';
6632
+				if ($fullday) {
6633
+					$reset_scripts .= ' } ';
6634
+				}
5915 6635
 			}
5916 6636
 			// If reset_scripts is not empty, print the link with the reset_scripts in the onClick
5917 6637
 			if ($reset_scripts && empty($conf->dol_optimize_smallscreen))
@@ -5926,7 +6646,9 @@  discard block
 block discarded – undo
5926 6646
 		if ($conf->use_javascript_ajax && $adddateof)
5927 6647
 		{
5928 6648
 			$tmparray = dol_getdate($adddateof);
5929
-			if (empty($labeladddateof)) $labeladddateof = $langs->trans("DateInvoice");
6649
+			if (empty($labeladddateof)) {
6650
+				$labeladddateof = $langs->trans("DateInvoice");
6651
+			}
5930 6652
 			$retstring .= ' - <button class="dpInvisibleButtons datenowlink" id="dateofinvoice" type="button" name="_dateofinvoice" value="now" onclick="jQuery(\'#re\').val(\''.dol_print_date($adddateof, 'day').'\');jQuery(\'#reday\').val(\''.$tmparray['mday'].'\');jQuery(\'#remonth\').val(\''.$tmparray['mon'].'\');jQuery(\'#reyear\').val(\''.$tmparray['year'].'\');">'.$labeladddateof.'</a>';
5931 6653
 		}
5932 6654
 
@@ -6008,9 +6730,11 @@  discard block
 block discarded – undo
6008 6730
 
6009 6731
 		if ($typehour == 'select') {
6010 6732
 			$retstring .= '<select class="flat" id="select_'.$prefix.'hour" name="'.$prefix.'hour"'.($disabled ? ' disabled' : '').'>';
6011
-			for ($hour = 0; $hour < 25; $hour++)	// For a duration, we allow 24 hours
6733
+			for ($hour = 0; $hour < 25; $hour++) {
6734
+				// For a duration, we allow 24 hours
6012 6735
 			{
6013 6736
 				$retstring .= '<option value="'.$hour.'"';
6737
+			}
6014 6738
 				if ($hourSelected == $hour)
6015 6739
 				{
6016 6740
 					$retstring .= " selected";
@@ -6024,12 +6748,18 @@  discard block
 block discarded – undo
6024 6748
 			return 'BadValueForParameterTypeHour';
6025 6749
 		}
6026 6750
 
6027
-		if ($typehour != 'text') $retstring .= ' '.$langs->trans('HourShort');
6028
-		else $retstring .= '<span class="hideonsmartphone">:</span>';
6751
+		if ($typehour != 'text') {
6752
+			$retstring .= ' '.$langs->trans('HourShort');
6753
+		} else {
6754
+			$retstring .= '<span class="hideonsmartphone">:</span>';
6755
+		}
6029 6756
 
6030 6757
 		// Minutes
6031
-		if ($minunderhours) $retstring .= '<br>';
6032
-		else $retstring .= '<span class="hideonsmartphone">&nbsp;</span>';
6758
+		if ($minunderhours) {
6759
+			$retstring .= '<br>';
6760
+		} else {
6761
+			$retstring .= '<span class="hideonsmartphone">&nbsp;</span>';
6762
+		}
6033 6763
 
6034 6764
 		if ($typehour == 'select' || $typehour == 'textselect')
6035 6765
 		{
@@ -6037,7 +6767,9 @@  discard block
 block discarded – undo
6037 6767
 			for ($min = 0; $min <= 55; $min = $min + 5)
6038 6768
 			{
6039 6769
 				$retstring .= '<option value="'.$min.'"';
6040
-				if ($minSelected == $min) $retstring .= ' selected';
6770
+				if ($minSelected == $min) {
6771
+					$retstring .= ' selected';
6772
+				}
6041 6773
 				$retstring .= '>'.$min.'</option>';
6042 6774
 			}
6043 6775
 			$retstring .= "</select>";
@@ -6046,11 +6778,15 @@  discard block
 block discarded – undo
6046 6778
 			$retstring .= '<input placeholder="'.$langs->trans('MinuteShort').'" type="number" min="0" name="'.$prefix.'min"'.($disabled ? ' disabled' : '').' class="flat maxwidth50 inputminute" value="'.(($minSelected != '') ? ((int) $minSelected) : '').'">';
6047 6779
 		}
6048 6780
 
6049
-		if ($typehour != 'text') $retstring .= ' '.$langs->trans('MinuteShort');
6781
+		if ($typehour != 'text') {
6782
+			$retstring .= ' '.$langs->trans('MinuteShort');
6783
+		}
6050 6784
 
6051 6785
 		//$retstring.="&nbsp;";
6052 6786
 
6053
-		if (!empty($nooutput)) return $retstring;
6787
+		if (!empty($nooutput)) {
6788
+			return $retstring;
6789
+		}
6054 6790
 
6055 6791
 		print $retstring;
6056 6792
 		return;
@@ -6111,8 +6847,12 @@  discard block
 block discarded – undo
6111 6847
 
6112 6848
 		//var_dump($objecttmp->filter);
6113 6849
 		$prefixforautocompletemode = $objecttmp->element;
6114
-		if ($prefixforautocompletemode == 'societe') $prefixforautocompletemode = 'company';
6115
-		if ($prefixforautocompletemode == 'product') $prefixforautocompletemode = 'produit';
6850
+		if ($prefixforautocompletemode == 'societe') {
6851
+			$prefixforautocompletemode = 'company';
6852
+		}
6853
+		if ($prefixforautocompletemode == 'product') {
6854
+			$prefixforautocompletemode = 'produit';
6855
+		}
6116 6856
 		$confkeyforautocompletemode = strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT
6117 6857
 
6118 6858
 		dol_syslog(get_class($this)."::selectForForms object->filter=".$objecttmp->filter, LOG_DEBUG);
@@ -6136,7 +6876,9 @@  discard block
 block discarded – undo
6136 6876
 			// Activate the auto complete using ajax call.
6137 6877
 			$out .= ajax_autocompleter($preselectedvalue, $htmlname, $urlforajaxcall, $urloption, $conf->global->$confkeyforautocompletemode, 0, array());
6138 6878
 			$out .= '<style type="text/css">.ui-autocomplete { z-index: 250; }</style>';
6139
-			if ($placeholder) $placeholder = ' placeholder="'.$placeholder.'"';
6879
+			if ($placeholder) {
6880
+				$placeholder = ' placeholder="'.$placeholder.'"';
6881
+			}
6140 6882
 			$out .= '<input type="text" class="'.$morecss.'"'.($disabled ? ' disabled="disabled"' : '').' name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' />';
6141 6883
 		} else {
6142 6884
 			// Immediate load of table record. Note: filter is inside $objecttmp->filter
@@ -6157,9 +6899,13 @@  discard block
 block discarded – undo
6157 6899
 		global $db;
6158 6900
 
6159 6901
 		//dol_syslog("Convert matches ".$matches[1]);
6160
-		if (empty($matches[1])) return '';
6902
+		if (empty($matches[1])) {
6903
+			return '';
6904
+		}
6161 6905
 		$tmp = explode(':', $matches[1]);
6162
-		if (count($tmp) < 3) return '';
6906
+		if (count($tmp) < 3) {
6907
+			return '';
6908
+		}
6163 6909
 
6164 6910
 		$tmpescaped = $tmp[2];
6165 6911
 		$regbis = array();
@@ -6197,18 +6943,28 @@  discard block
 block discarded – undo
6197 6943
 		//print "$objecttmp->filter, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled";
6198 6944
 
6199 6945
 		$prefixforautocompletemode = $objecttmp->element;
6200
-		if ($prefixforautocompletemode == 'societe') $prefixforautocompletemode = 'company';
6946
+		if ($prefixforautocompletemode == 'societe') {
6947
+			$prefixforautocompletemode = 'company';
6948
+		}
6201 6949
 		$confkeyforautocompletemode = strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT
6202 6950
 
6203
-		if (!empty($objecttmp->fields))	// For object that declare it, it is better to use declared fields (like societe, contact, ...)
6951
+		if (!empty($objecttmp->fields)) {
6952
+			// For object that declare it, it is better to use declared fields (like societe, contact, ...)
6204 6953
 		{
6205 6954
 			$tmpfieldstoshow = '';
6955
+		}
6206 6956
 			foreach ($objecttmp->fields as $key => $val)
6207 6957
 			{
6208
-				if (!dol_eval($val['enabled'], 1, 1)) continue;
6209
-				if ($val['showoncombobox']) $tmpfieldstoshow .= ($tmpfieldstoshow ? ',' : '').'t.'.$key;
6958
+				if (!dol_eval($val['enabled'], 1, 1)) {
6959
+					continue;
6960
+				}
6961
+				if ($val['showoncombobox']) {
6962
+					$tmpfieldstoshow .= ($tmpfieldstoshow ? ',' : '').'t.'.$key;
6963
+				}
6964
+			}
6965
+			if ($tmpfieldstoshow) {
6966
+				$fieldstoshow = $tmpfieldstoshow;
6210 6967
 			}
6211
-			if ($tmpfieldstoshow) $fieldstoshow = $tmpfieldstoshow;
6212 6968
 		} else {
6213 6969
 			// For backward compatibility
6214 6970
 			$objecttmp->fields['ref'] = array('type'=>'varchar(30)', 'label'=>'Ref', 'showoncombobox'=>1);
@@ -6236,20 +6992,30 @@  discard block
 block discarded – undo
6236 6992
 			$tmparray = explode('@', $objecttmp->ismultientitymanaged);
6237 6993
 			$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.$tmparray[1].' as parenttable ON parenttable.rowid = t.'.$tmparray[0];
6238 6994
 		}
6239
-		if ($objecttmp->ismultientitymanaged == 'fk_soc@societe')
6240
-			if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
6995
+		if ($objecttmp->ismultientitymanaged == 'fk_soc@societe') {
6996
+					if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
6997
+		}
6241 6998
 		$sql .= " WHERE 1=1";
6242
-		if (isset($objecttmp->ismultientitymanaged) && $objecttmp->ismultientitymanaged == 1) $sql .= " AND t.entity IN (".getEntity($objecttmp->table_element).")";
6999
+		if (isset($objecttmp->ismultientitymanaged) && $objecttmp->ismultientitymanaged == 1) {
7000
+			$sql .= " AND t.entity IN (".getEntity($objecttmp->table_element).")";
7001
+		}
6243 7002
 		if (isset($objecttmp->ismultientitymanaged) && !is_numeric($objecttmp->ismultientitymanaged)) {
6244 7003
 			$sql .= ' AND parenttable.entity = t.'.$tmparray[0];
6245 7004
 		}
6246 7005
 		if ($objecttmp->ismultientitymanaged == 1 && !empty($user->socid)) {
6247
-			if ($objecttmp->element == 'societe') $sql .= " AND t.rowid = ".$user->socid;
6248
-			else $sql .= " AND t.fk_soc = ".$user->socid;
7006
+			if ($objecttmp->element == 'societe') {
7007
+				$sql .= " AND t.rowid = ".$user->socid;
7008
+			} else {
7009
+				$sql .= " AND t.fk_soc = ".$user->socid;
7010
+			}
7011
+		}
7012
+		if ($searchkey != '') {
7013
+			$sql .= natural_search(explode(',', $fieldstoshow), $searchkey);
6249 7014
 		}
6250
-		if ($searchkey != '') $sql .= natural_search(explode(',', $fieldstoshow), $searchkey);
6251 7015
 		if ($objecttmp->ismultientitymanaged == 'fk_soc@societe') {
6252
-			if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
7016
+			if (!$user->rights->societe->client->voir && !$user->socid) {
7017
+				$sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
7018
+			}
6253 7019
 		}
6254 7020
 		if ($objecttmp->filter) {	 // Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
6255 7021
 			/*if (! DolibarrApi::_checkFilters($objecttmp->filter))
@@ -6276,10 +7042,15 @@  discard block
 block discarded – undo
6276 7042
 			//if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
6277 7043
 			if (!empty($conf->global->$confkeyforautocompletemode))
6278 7044
 			{
6279
-				if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
6280
-				else $textifempty .= $langs->trans("All");
7045
+				if ($showempty && !is_numeric($showempty)) {
7046
+					$textifempty = $langs->trans($showempty);
7047
+				} else {
7048
+					$textifempty .= $langs->trans("All");
7049
+				}
7050
+			}
7051
+			if ($showempty) {
7052
+				$out .= '<option value="-1">'.$textifempty.'</option>'."\n";
6281 7053
 			}
6282
-			if ($showempty) $out .= '<option value="-1">'.$textifempty.'</option>'."\n";
6283 7054
 
6284 7055
 			$num = $this->db->num_rows($resql);
6285 7056
 			$i = 0;
@@ -6307,7 +7078,9 @@  discard block
 block discarded – undo
6307 7078
 					}
6308 7079
 
6309 7080
 					$i++;
6310
-					if (($i % 10) == 0) $out .= "\n";
7081
+					if (($i % 10) == 0) {
7082
+						$out .= "\n";
7083
+					}
6311 7084
 				}
6312 7085
 			}
6313 7086
 
@@ -6323,7 +7096,9 @@  discard block
 block discarded – undo
6323 7096
 
6324 7097
 		$this->result = array('nbofelement'=>$num);
6325 7098
 
6326
-		if ($outputmode) return $outarray;
7099
+		if ($outputmode) {
7100
+			return $outarray;
7101
+		}
6327 7102
 		return $out;
6328 7103
 	}
6329 7104
 
@@ -6360,7 +7135,9 @@  discard block
 block discarded – undo
6360 7135
 		//if (preg_match('/^multi/',$htmlname)) $jsbeautify = 1;
6361 7136
 		$jsbeautify = 1;
6362 7137
 
6363
-		if ($value_as_key) $array = array_combine($array, $array);
7138
+		if ($value_as_key) {
7139
+			$array = array_combine($array, $array);
7140
+		}
6364 7141
 
6365 7142
 		$out = '';
6366 7143
 
@@ -6382,8 +7159,13 @@  discard block
 block discarded – undo
6382 7159
 		if ($show_empty)
6383 7160
 		{
6384 7161
 			$textforempty = ' ';
6385
-			if (!empty($conf->use_javascript_ajax)) $textforempty = '&nbsp;'; // If we use ajaxcombo, we need &nbsp; here to avoid to have an empty element that is too small.
6386
-			if (!is_numeric($show_empty)) $textforempty = $show_empty;
7162
+			if (!empty($conf->use_javascript_ajax)) {
7163
+				$textforempty = '&nbsp;';
7164
+			}
7165
+			// If we use ajaxcombo, we need &nbsp; here to avoid to have an empty element that is too small.
7166
+			if (!is_numeric($show_empty)) {
7167
+				$textforempty = $show_empty;
7168
+			}
6387 7169
 			$out .= '<option class="optiongrey" '.($moreparamonempty ? $moreparamonempty.' ' : '').'value="'.($show_empty < 0 ? $show_empty : -1).'"'.($id == $show_empty ? ' selected' : '').'>'.$textforempty.'</option>'."\n";
6388 7170
 		}
6389 7171
 
@@ -6394,14 +7176,20 @@  discard block
 block discarded – undo
6394 7176
 			{
6395 7177
 				foreach ($array as $key => $value)
6396 7178
 				{
6397
-					if (!is_array($value)) $array[$key] = $langs->trans($value);
6398
-					else $array[$key]['label'] = $langs->trans($value['label']);
7179
+					if (!is_array($value)) {
7180
+						$array[$key] = $langs->trans($value);
7181
+					} else {
7182
+						$array[$key]['label'] = $langs->trans($value['label']);
7183
+					}
6399 7184
 				}
6400 7185
 			}
6401 7186
 
6402 7187
 			// Sort
6403
-			if ($sort == 'ASC') asort($array);
6404
-			elseif ($sort == 'DESC') arsort($array);
7188
+			if ($sort == 'ASC') {
7189
+				asort($array);
7190
+			} elseif ($sort == 'DESC') {
7191
+				arsort($array);
7192
+			}
6405 7193
 
6406 7194
 			foreach ($array as $key => $tmpvalue)
6407 7195
 			{
@@ -6425,28 +7213,46 @@  discard block
 block discarded – undo
6425 7213
 
6426 7214
 				if ($key_in_label)
6427 7215
 				{
6428
-					if (empty($nohtmlescape)) $selectOptionValue = dol_escape_htmltag($key.' - '.($maxlen ?dol_trunc($value, $maxlen) : $value));
6429
-					else $selectOptionValue = $key.' - '.($maxlen ?dol_trunc($value, $maxlen) : $value);
7216
+					if (empty($nohtmlescape)) {
7217
+						$selectOptionValue = dol_escape_htmltag($key.' - '.($maxlen ?dol_trunc($value, $maxlen) : $value));
7218
+					} else {
7219
+						$selectOptionValue = $key.' - '.($maxlen ?dol_trunc($value, $maxlen) : $value);
7220
+					}
6430 7221
 				} else {
6431
-					if (empty($nohtmlescape)) $selectOptionValue = dol_escape_htmltag($maxlen ?dol_trunc($value, $maxlen) : $value);
6432
-					else $selectOptionValue = $maxlen ?dol_trunc($value, $maxlen) : $value;
6433
-					if ($value == '' || $value == '-') $selectOptionValue = '&nbsp;';
7222
+					if (empty($nohtmlescape)) {
7223
+						$selectOptionValue = dol_escape_htmltag($maxlen ?dol_trunc($value, $maxlen) : $value);
7224
+					} else {
7225
+						$selectOptionValue = $maxlen ?dol_trunc($value, $maxlen) : $value;
7226
+					}
7227
+					if ($value == '' || $value == '-') {
7228
+						$selectOptionValue = '&nbsp;';
7229
+					}
6434 7230
 				}
6435 7231
 
6436 7232
 				$out .= '<option value="'.$key.'"';
6437 7233
 				$out .= $style.$disabled;
6438 7234
 				if (is_array($id)) {
6439
-					if (in_array($key, $id) && !$disabled) $out .= ' selected'; // To preselect a value
7235
+					if (in_array($key, $id) && !$disabled) {
7236
+						$out .= ' selected';
7237
+					}
7238
+					// To preselect a value
6440 7239
 				} else {
6441 7240
 					$id = (string) $id; // if $id = 0, then $id = '0'
6442
-					if ($id != '' && $id == $key && !$disabled) $out .= ' selected'; // To preselect a value
7241
+					if ($id != '' && $id == $key && !$disabled) {
7242
+						$out .= ' selected';
7243
+					}
7244
+					// To preselect a value
7245
+				}
7246
+				if ($nohtmlescape) {
7247
+					$out .= ' data-html="'.dol_escape_htmltag($selectOptionValue).'"';
6443 7248
 				}
6444
-				if ($nohtmlescape) $out .= ' data-html="'.dol_escape_htmltag($selectOptionValue).'"';
6445 7249
 				if (is_array($tmpvalue))
6446 7250
 				{
6447 7251
 					foreach ($tmpvalue as $keyforvalue => $valueforvalue)
6448 7252
 					{
6449
-						if (preg_match('/^data-/', $keyforvalue)) $out .= ' '.$keyforvalue.'="'.$valueforvalue.'"';
7253
+						if (preg_match('/^data-/', $keyforvalue)) {
7254
+							$out .= ' '.$keyforvalue.'="'.$valueforvalue.'"';
7255
+						}
6450 7256
 					}
6451 7257
 				}
6452 7258
 				$out .= '>';
@@ -6485,7 +7291,9 @@  discard block
 block discarded – undo
6485 7291
 		global $delayedhtmlcontent;
6486 7292
 
6487 7293
 		// TODO Use an internal dolibarr component instead of select2
6488
-		if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) return '';
7294
+		if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) {
7295
+			return '';
7296
+		}
6489 7297
 
6490 7298
 		$out = '<select type="text" class="'.$htmlname.($morecss ? ' '.$morecss : '').'" '.($moreparam ? $moreparam.' ' : '').'name="'.$htmlname.'"></select>';
6491 7299
 
@@ -6585,7 +7393,9 @@  discard block
 block discarded – undo
6585 7393
 		global $delayedhtmlcontent;
6586 7394
 
6587 7395
 		// TODO Use an internal dolibarr component instead of select2
6588
-		if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) return '';
7396
+		if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) {
7397
+			return '';
7398
+		}
6589 7399
 
6590 7400
 		$out = '<select type="text" class="'.$htmlname.($morecss ? ' '.$morecss : '').'" '.($moreparam ? $moreparam.' ' : '').'name="'.$htmlname.'"><option></option></select>';
6591 7401
 
@@ -6701,8 +7511,11 @@  discard block
 block discarded – undo
6701 7511
 		$out = '';
6702 7512
 
6703 7513
 		if ($addjscombo < 0) {
6704
-			if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $addjscombo = 1;
6705
-			else $addjscombo = 0;
7514
+			if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
7515
+				$addjscombo = 1;
7516
+			} else {
7517
+				$addjscombo = 0;
7518
+			}
6706 7519
 		}
6707 7520
 
6708 7521
 		// Add code for jquery to use multiselect
@@ -6994,25 +7807,46 @@  discard block
 block discarded – undo
6994 7807
 				// To work with non standard path
6995 7808
 				if ($objecttype == 'facture') {
6996 7809
 					$tplpath = 'compta/'.$element;
6997
-					if (empty($conf->facture->enabled)) continue; // Do not show if module disabled
7810
+					if (empty($conf->facture->enabled)) {
7811
+						continue;
7812
+					}
7813
+					// Do not show if module disabled
6998 7814
 				} elseif ($objecttype == 'facturerec') {
6999 7815
 					$tplpath = 'compta/facture';
7000 7816
 					$tplname = 'linkedobjectblockForRec';
7001
-					if (empty($conf->facture->enabled)) continue; // Do not show if module disabled
7817
+					if (empty($conf->facture->enabled)) {
7818
+						continue;
7819
+					}
7820
+					// Do not show if module disabled
7002 7821
 				} elseif ($objecttype == 'propal') {
7003 7822
 					$tplpath = 'comm/'.$element;
7004
-					if (empty($conf->propal->enabled)) continue; // Do not show if module disabled
7823
+					if (empty($conf->propal->enabled)) {
7824
+						continue;
7825
+					}
7826
+					// Do not show if module disabled
7005 7827
 				} elseif ($objecttype == 'supplier_proposal') {
7006
-					if (empty($conf->supplier_proposal->enabled)) continue; // Do not show if module disabled
7828
+					if (empty($conf->supplier_proposal->enabled)) {
7829
+						continue;
7830
+					}
7831
+					// Do not show if module disabled
7007 7832
 				} elseif ($objecttype == 'shipping' || $objecttype == 'shipment') {
7008 7833
 					$tplpath = 'expedition';
7009
-					if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled
7834
+					if (empty($conf->expedition->enabled)) {
7835
+						continue;
7836
+					}
7837
+					// Do not show if module disabled
7010 7838
 				} elseif ($objecttype == 'reception') {
7011 7839
 					$tplpath = 'reception';
7012
-					if (empty($conf->reception->enabled)) continue; // Do not show if module disabled
7840
+					if (empty($conf->reception->enabled)) {
7841
+						continue;
7842
+					}
7843
+					// Do not show if module disabled
7013 7844
 				} elseif ($objecttype == 'delivery') {
7014 7845
 					$tplpath = 'delivery';
7015
-					if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled
7846
+					if (empty($conf->expedition->enabled)) {
7847
+						continue;
7848
+					}
7849
+					// Do not show if module disabled
7016 7850
 				} elseif ($objecttype == 'invoice_supplier') {
7017 7851
 					$tplpath = 'fourn/facture';
7018 7852
 				} elseif ($objecttype == 'order_supplier') {
@@ -7031,9 +7865,11 @@  discard block
 block discarded – undo
7031 7865
 				$dirtpls = array_merge($conf->modules_parts['tpl'], array('/'.$tplpath.'/tpl'));
7032 7866
 				foreach ($dirtpls as $reldir)
7033 7867
 				{
7034
-					if ($nboftypesoutput == ($nbofdifferenttypes - 1))    // No more type to show after
7868
+					if ($nboftypesoutput == ($nbofdifferenttypes - 1)) {
7869
+						// No more type to show after
7035 7870
 					{
7036 7871
 						global $noMoreLinkedObjectBlockAfter;
7872
+					}
7037 7873
 						$noMoreLinkedObjectBlockAfter = 1;
7038 7874
 					}
7039 7875
 
@@ -7082,19 +7918,25 @@  discard block
 block discarded – undo
7082 7918
 		$linktoelemlist = '';
7083 7919
 		$listofidcompanytoscan = '';
7084 7920
 
7085
-		if (!is_object($object->thirdparty)) $object->fetch_thirdparty();
7921
+		if (!is_object($object->thirdparty)) {
7922
+			$object->fetch_thirdparty();
7923
+		}
7086 7924
 
7087 7925
 		$possiblelinks = array();
7088 7926
 		if (is_object($object->thirdparty) && !empty($object->thirdparty->id) && $object->thirdparty->id > 0)
7089 7927
 		{
7090 7928
 			$listofidcompanytoscan = $object->thirdparty->id;
7091
-			if (($object->thirdparty->parent > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO)) $listofidcompanytoscan .= ','.$object->thirdparty->parent;
7929
+			if (($object->thirdparty->parent > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO)) {
7930
+				$listofidcompanytoscan .= ','.$object->thirdparty->parent;
7931
+			}
7092 7932
 			if (($object->fk_project > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PROJECT_THIRDPARY_IN_LINKTO))
7093 7933
 			{
7094 7934
 				include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
7095 7935
 				$tmpproject = new Project($this->db);
7096 7936
 				$tmpproject->fetch($object->fk_project);
7097
-				if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id)) $listofidcompanytoscan .= ','.$tmpproject->socid;
7937
+				if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id)) {
7938
+					$listofidcompanytoscan .= ','.$tmpproject->socid;
7939
+				}
7098 7940
 				unset($tmpproject);
7099 7941
 			}
7100 7942
 
@@ -7117,9 +7959,12 @@  discard block
 block discarded – undo
7117 7959
 		$hookmanager->initHooks(array('commonobject'));
7118 7960
 		$parameters = array('listofidcompanytoscan' => $listofidcompanytoscan);
7119 7961
 
7120
-		if (!empty($listofidcompanytoscan))  // If empty, we don't have criteria to scan the object we can link to
7962
+		if (!empty($listofidcompanytoscan)) {
7963
+			// If empty, we don't have criteria to scan the object we can link to
7121 7964
 		{
7122
-			$reshook = $hookmanager->executeHooks('showLinkToObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
7965
+			$reshook = $hookmanager->executeHooks('showLinkToObjectBlock', $parameters, $object, $action);
7966
+		}
7967
+		// Note that $action and $object may have been modified by hook
7123 7968
 		}
7124 7969
 
7125 7970
 		if (empty($reshook))
@@ -7140,7 +7985,9 @@  discard block
 block discarded – undo
7140 7985
 		{
7141 7986
 			$num = 0;
7142 7987
 
7143
-			if (empty($possiblelink['enabled'])) continue;
7988
+			if (empty($possiblelink['enabled'])) {
7989
+				continue;
7990
+			}
7144 7991
 
7145 7992
 			if (!empty($possiblelink['perms']) && (empty($restrictlinksto) || in_array($key, $restrictlinksto)) && (empty($excludelinksto) || !in_array($key, $excludelinksto)))
7146 7993
 			{
@@ -7196,9 +8043,13 @@  discard block
 block discarded – undo
7196 8043
 				}
7197 8044
 
7198 8045
 				//$linktoelem.=($linktoelem?' &nbsp; ':'');
7199
-				if ($num > 0) $linktoelemlist .= '<li><a href="#linkto'.$key.'" class="linkto dropdowncloseonclick" rel="'.$key.'">'.$langs->trans($possiblelink['label']).' ('.$num.')</a></li>';
8046
+				if ($num > 0) {
8047
+					$linktoelemlist .= '<li><a href="#linkto'.$key.'" class="linkto dropdowncloseonclick" rel="'.$key.'">'.$langs->trans($possiblelink['label']).' ('.$num.')</a></li>';
8048
+				}
7200 8049
 				//else $linktoelem.=$langs->trans($possiblelink['label']);
7201
-				else $linktoelemlist .= '<li><span class="linktodisabled">'.$langs->trans($possiblelink['label']).' (0)</span></li>';
8050
+				else {
8051
+					$linktoelemlist .= '<li><span class="linktodisabled">'.$langs->trans($possiblelink['label']).' (0)</span></li>';
8052
+				}
7202 8053
 			}
7203 8054
 		}
7204 8055
 
@@ -7207,7 +8058,9 @@  discard block
 block discarded – undo
7207 8058
 			$linktoelem = '
7208 8059
     		<dl class="dropdown" id="linktoobjectname">
7209 8060
     		';
7210
-			if (!empty($conf->use_javascript_ajax)) $linktoelem .= '<dt><a href="#linktoobjectname">'.$langs->trans("LinkTo").'...</a></dt>';
8061
+			if (!empty($conf->use_javascript_ajax)) {
8062
+				$linktoelem .= '<dt><a href="#linktoobjectname">'.$langs->trans("LinkTo").'...</a></dt>';
8063
+			}
7211 8064
 			$linktoelem .= '<dd>
7212 8065
     		<div class="multiselectlinkto">
7213 8066
     		<ul class="ulselectedfields">'.$linktoelemlist.'
@@ -7261,7 +8114,9 @@  discard block
 block discarded – undo
7261 8114
 		$disabled = ($disabled ? ' disabled' : '');
7262 8115
 
7263 8116
 		$resultyesno = '<select class="flat width75" id="'.$htmlname.'" name="'.$htmlname.'"'.$disabled.'>'."\n";
7264
-		if ($useempty) $resultyesno .= '<option value="-1"'.(($value < 0) ? ' selected' : '').'>&nbsp;</option>'."\n";
8117
+		if ($useempty) {
8118
+			$resultyesno .= '<option value="-1"'.(($value < 0) ? ' selected' : '').'>&nbsp;</option>'."\n";
8119
+		}
7265 8120
 		if (("$value" == 'yes') || ($value == 1))
7266 8121
 		{
7267 8122
 			$resultyesno .= '<option value="'.$yes.'" selected>'.$langs->trans("Yes").'</option>'."\n";
@@ -7350,8 +8205,12 @@  discard block
 block discarded – undo
7350 8205
 		global $langs, $conf, $hookmanager, $extralanguages;
7351 8206
 
7352 8207
 		$ret = '';
7353
-		if (empty($fieldid))  $fieldid = 'rowid';
7354
-		if (empty($fieldref)) $fieldref = 'ref';
8208
+		if (empty($fieldid)) {
8209
+			$fieldid = 'rowid';
8210
+		}
8211
+		if (empty($fieldref)) {
8212
+			$fieldref = 'ref';
8213
+		}
7355 8214
 
7356 8215
 		// Add where from hooks
7357 8216
 		if (is_object($hookmanager))
@@ -7370,9 +8229,11 @@  discard block
 block discarded – undo
7370 8229
 			// Special case for project/task page
7371 8230
 			if ($paramid == 'project_ref')
7372 8231
 			{
7373
-				if (preg_match('/\/tasks\/(task|contact|note|document)\.php/', $navurl))     // TODO Remove this when nav with project_ref on task pages are ok
8232
+				if (preg_match('/\/tasks\/(task|contact|note|document)\.php/', $navurl)) {
8233
+					// TODO Remove this when nav with project_ref on task pages are ok
7374 8234
 				{
7375 8235
 					$navurl = preg_replace('/\/tasks\/(task|contact|time|note|document)\.php/', '/tasks.php', $navurl);
8236
+				}
7376 8237
 					$paramid = 'ref';
7377 8238
 				}
7378 8239
 			}
@@ -7398,7 +8259,9 @@  discard block
 block discarded – undo
7398 8259
 		$ret .= '<!-- Start banner content --><div style="vertical-align: middle">';
7399 8260
 
7400 8261
 		// Right part of banner
7401
-		if ($morehtmlright) $ret .= '<div class="inline-block floatleft">'.$morehtmlright.'</div>';
8262
+		if ($morehtmlright) {
8263
+			$ret .= '<div class="inline-block floatleft">'.$morehtmlright.'</div>';
8264
+		}
7402 8265
 
7403 8266
 		if ($previous_ref || $next_ref || $morehtml)
7404 8267
 		{
@@ -7420,20 +8283,33 @@  discard block
 block discarded – undo
7420 8283
 
7421 8284
 		$parameters = array();
7422 8285
 		$reshook = $hookmanager->executeHooks('moreHtmlStatus', $parameters, $object); // Note that $action and $object may have been modified by hook
7423
-		if (empty($reshook)) $morehtmlstatus .= $hookmanager->resPrint;
7424
-		else $morehtmlstatus = $hookmanager->resPrint;
7425
-		if ($morehtmlstatus) $ret .= '<div class="statusref">'.$morehtmlstatus.'</div>';
8286
+		if (empty($reshook)) {
8287
+			$morehtmlstatus .= $hookmanager->resPrint;
8288
+		} else {
8289
+			$morehtmlstatus = $hookmanager->resPrint;
8290
+		}
8291
+		if ($morehtmlstatus) {
8292
+			$ret .= '<div class="statusref">'.$morehtmlstatus.'</div>';
8293
+		}
7426 8294
 
7427 8295
 		$parameters = array();
7428 8296
 		$reshook = $hookmanager->executeHooks('moreHtmlRef', $parameters, $object); // Note that $action and $object may have been modified by hook
7429
-		if (empty($reshook)) $morehtmlref .= $hookmanager->resPrint;
7430
-		elseif ($reshook > 0) $morehtmlref = $hookmanager->resPrint;
8297
+		if (empty($reshook)) {
8298
+			$morehtmlref .= $hookmanager->resPrint;
8299
+		} elseif ($reshook > 0) {
8300
+			$morehtmlref = $hookmanager->resPrint;
8301
+		}
7431 8302
 
7432 8303
 		// Left part of banner
7433 8304
 		if ($morehtmlleft)
7434 8305
 		{
7435
-			if ($conf->browser->layout == 'phone') $ret .= '<!-- morehtmlleft --><div class="floatleft">'.$morehtmlleft.'</div>'; // class="center" to have photo in middle
7436
-			else $ret .= '<!-- morehtmlleft --><div class="inline-block floatleft">'.$morehtmlleft.'</div>';
8306
+			if ($conf->browser->layout == 'phone') {
8307
+				$ret .= '<!-- morehtmlleft --><div class="floatleft">'.$morehtmlleft.'</div>';
8308
+			}
8309
+			// class="center" to have photo in middle
8310
+			else {
8311
+				$ret .= '<!-- morehtmlleft --><div class="inline-block floatleft">'.$morehtmlleft.'</div>';
8312
+			}
7437 8313
 		}
7438 8314
 
7439 8315
 		//if ($conf->browser->layout == 'phone') $ret.='<div class="clearboth"></div>';
@@ -7446,7 +8322,9 @@  discard block
 block discarded – undo
7446 8322
 
7447 8323
 			// List of extra languages
7448 8324
 			$arrayoflangcode = array();
7449
-			if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) $arrayoflangcode[] = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE;
8325
+			if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) {
8326
+				$arrayoflangcode[] = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE;
8327
+			}
7450 8328
 
7451 8329
 			if (is_array($arrayoflangcode) && count($arrayoflangcode)) {
7452 8330
 				if (!is_object($extralanguages)) {
@@ -7530,14 +8408,18 @@  discard block
 block discarded – undo
7530 8408
 		global $conf;
7531 8409
 
7532 8410
 		//Check if barcode is filled in the card
7533
-		if (empty($object->barcode)) return '';
8411
+		if (empty($object->barcode)) {
8412
+			return '';
8413
+		}
7534 8414
 
7535 8415
 		// Complete object if not complete
7536 8416
 		if (empty($object->barcode_type_code) || empty($object->barcode_type_coder))
7537 8417
 		{
7538 8418
 			$result = $object->fetch_barcode();
7539 8419
 			//Check if fetch_barcode() failed
7540
-			if ($result < 1) return '<!-- ErrorFetchBarcode -->';
8420
+			if ($result < 1) {
8421
+				return '<!-- ErrorFetchBarcode -->';
8422
+			}
7541 8423
 		}
7542 8424
 
7543 8425
 		// Barcode image
@@ -7575,9 +8457,15 @@  discard block
 block discarded – undo
7575 8457
 		{
7576 8458
 			$dir = $conf->societe->multidir_output[$entity];
7577 8459
 			if (!empty($object->logo)) {
7578
-				if ((string) $imagesize == 'mini') $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'logos/'.getImageFileNameForSize($object->logo, '_mini'); // getImageFileNameForSize include the thumbs
7579
-				elseif ((string) $imagesize == 'small') $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'logos/'.getImageFileNameForSize($object->logo, '_small');
7580
-				else $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'logos/'.$object->logo;
8460
+				if ((string) $imagesize == 'mini') {
8461
+					$file = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'logos/'.getImageFileNameForSize($object->logo, '_mini');
8462
+				}
8463
+				// getImageFileNameForSize include the thumbs
8464
+				elseif ((string) $imagesize == 'small') {
8465
+					$file = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'logos/'.getImageFileNameForSize($object->logo, '_small');
8466
+				} else {
8467
+					$file = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'logos/'.$object->logo;
8468
+				}
7581 8469
 				$originalfile = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'logos/'.$object->logo;
7582 8470
 			}
7583 8471
 			$email = $object->email;
@@ -7585,9 +8473,13 @@  discard block
 block discarded – undo
7585 8473
 			$dir = $conf->societe->multidir_output[$entity].'/contact';
7586 8474
 			if (!empty($object->photo))
7587 8475
 			{
7588
-				if ((string) $imagesize == 'mini') $file = get_exdir(0, 0, 0, 0, $object, 'contact').'photos/'.getImageFileNameForSize($object->photo, '_mini');
7589
-				elseif ((string) $imagesize == 'small') $file = get_exdir(0, 0, 0, 0, $object, 'contact').'photos/'.getImageFileNameForSize($object->photo, '_small');
7590
-				else $file = get_exdir(0, 0, 0, 0, $object, 'contact').'photos/'.$object->photo;
8476
+				if ((string) $imagesize == 'mini') {
8477
+					$file = get_exdir(0, 0, 0, 0, $object, 'contact').'photos/'.getImageFileNameForSize($object->photo, '_mini');
8478
+				} elseif ((string) $imagesize == 'small') {
8479
+					$file = get_exdir(0, 0, 0, 0, $object, 'contact').'photos/'.getImageFileNameForSize($object->photo, '_small');
8480
+				} else {
8481
+					$file = get_exdir(0, 0, 0, 0, $object, 'contact').'photos/'.$object->photo;
8482
+				}
7591 8483
 				$originalfile = get_exdir(0, 0, 0, 0, $object, 'contact').'photos/'.$object->photo;
7592 8484
 			}
7593 8485
 			$email = $object->email;
@@ -7596,24 +8488,38 @@  discard block
 block discarded – undo
7596 8488
 			$dir = $conf->user->dir_output;
7597 8489
 			if (!empty($object->photo))
7598 8490
 			{
7599
-				if ((string) $imagesize == 'mini') $file = get_exdir(0, 0, 0, 0, $object, 'user').getImageFileNameForSize($object->photo, '_mini');
7600
-				elseif ((string) $imagesize == 'small') $file = get_exdir(0, 0, 0, 0, $object, 'user').getImageFileNameForSize($object->photo, '_small');
7601
-				else $file = get_exdir(0, 0, 0, 0, $object, 'user').$object->photo;
8491
+				if ((string) $imagesize == 'mini') {
8492
+					$file = get_exdir(0, 0, 0, 0, $object, 'user').getImageFileNameForSize($object->photo, '_mini');
8493
+				} elseif ((string) $imagesize == 'small') {
8494
+					$file = get_exdir(0, 0, 0, 0, $object, 'user').getImageFileNameForSize($object->photo, '_small');
8495
+				} else {
8496
+					$file = get_exdir(0, 0, 0, 0, $object, 'user').$object->photo;
8497
+				}
7602 8498
 				$originalfile = get_exdir(0, 0, 0, 0, $object, 'user').$object->photo;
7603 8499
 			}
7604
-			if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile = $object->id.".jpg"; // For backward compatibility
8500
+			if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) {
8501
+				$altfile = $object->id.".jpg";
8502
+			}
8503
+			// For backward compatibility
7605 8504
 			$email = $object->email;
7606 8505
 			$capture = 'user';
7607 8506
 		} elseif ($modulepart == 'memberphoto')	{
7608 8507
 			$dir = $conf->adherent->dir_output;
7609 8508
 			if (!empty($object->photo))
7610 8509
 			{
7611
-				if ((string) $imagesize == 'mini') $file = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.getImageFileNameForSize($object->photo, '_mini');
7612
-				elseif ((string) $imagesize == 'small') $file = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.getImageFileNameForSize($object->photo, '_small');
7613
-				else $file = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.$object->photo;
8510
+				if ((string) $imagesize == 'mini') {
8511
+					$file = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.getImageFileNameForSize($object->photo, '_mini');
8512
+				} elseif ((string) $imagesize == 'small') {
8513
+					$file = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.getImageFileNameForSize($object->photo, '_small');
8514
+				} else {
8515
+					$file = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.$object->photo;
8516
+				}
7614 8517
 				$originalfile = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.$object->photo;
7615 8518
 			}
7616
-			if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile = $object->id.".jpg"; // For backward compatibility
8519
+			if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) {
8520
+				$altfile = $object->id.".jpg";
8521
+			}
8522
+			// For backward compatibility
7617 8523
 			$email = $object->email;
7618 8524
 			$capture = 'user';
7619 8525
 		} else {
@@ -7621,16 +8527,25 @@  discard block
 block discarded – undo
7621 8527
 			$dir = $conf->$modulepart->dir_output;
7622 8528
 			if (!empty($object->photo))
7623 8529
 			{
7624
-				if ((string) $imagesize == 'mini') $file = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.getImageFileNameForSize($object->photo, '_mini');
7625
-				elseif ((string) $imagesize == 'small') $file = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.getImageFileNameForSize($object->photo, '_small');
7626
-				else $file = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.$object->photo;
8530
+				if ((string) $imagesize == 'mini') {
8531
+					$file = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.getImageFileNameForSize($object->photo, '_mini');
8532
+				} elseif ((string) $imagesize == 'small') {
8533
+					$file = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.getImageFileNameForSize($object->photo, '_small');
8534
+				} else {
8535
+					$file = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.$object->photo;
8536
+				}
7627 8537
 				$originalfile = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.$object->photo;
7628 8538
 			}
7629
-			if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile = $object->id.".jpg"; // For backward compatibility
8539
+			if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) {
8540
+				$altfile = $object->id.".jpg";
8541
+			}
8542
+			// For backward compatibility
7630 8543
 			$email = $object->email;
7631 8544
 		}
7632 8545
 
7633
-		if ($forcecapture) $capture = $forcecapture;
8546
+		if ($forcecapture) {
8547
+			$capture = $forcecapture;
8548
+		}
7634 8549
 
7635 8550
 		if ($dir)
7636 8551
 		{
@@ -7638,19 +8553,29 @@  discard block
 block discarded – undo
7638 8553
 			{
7639 8554
 				if ($addlinktofullsize) {
7640 8555
 					$urladvanced = getAdvancedPreviewUrl($modulepart, $originalfile, 0, '&entity='.$entity);
7641
-					if ($urladvanced) $ret .= '<a href="'.$urladvanced.'">';
7642
-					else $ret .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">';
8556
+					if ($urladvanced) {
8557
+						$ret .= '<a href="'.$urladvanced.'">';
8558
+					} else {
8559
+						$ret .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">';
8560
+					}
7643 8561
 				}
7644 8562
 				$ret .= '<img alt="Photo" class="photo'.$modulepart.($cssclass ? ' '.$cssclass : '').' photologo'.(preg_replace('/[^a-z]/i', '_', $file)).'" '.($width ? ' width="'.$width.'"' : '').($height ? ' height="'.$height.'"' : '').' src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($file).'&cache='.$cache.'">';
7645
-				if ($addlinktofullsize) $ret .= '</a>';
8563
+				if ($addlinktofullsize) {
8564
+					$ret .= '</a>';
8565
+				}
7646 8566
 			} elseif ($altfile && file_exists($dir."/".$altfile)) {
7647 8567
 				if ($addlinktofullsize) {
7648 8568
 					$urladvanced = getAdvancedPreviewUrl($modulepart, $originalfile, 0, '&entity='.$entity);
7649
-					if ($urladvanced) $ret .= '<a href="'.$urladvanced.'">';
7650
-					else $ret .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">';
8569
+					if ($urladvanced) {
8570
+						$ret .= '<a href="'.$urladvanced.'">';
8571
+					} else {
8572
+						$ret .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">';
8573
+					}
7651 8574
 				}
7652 8575
 				$ret .= '<img class="photo'.$modulepart.($cssclass ? ' '.$cssclass : '').'" alt="Photo alt" id="photologo'.(preg_replace('/[^a-z]/i', '_', $file)).'" class="'.$cssclass.'" '.($width ? ' width="'.$width.'"' : '').($height ? ' height="'.$height.'"' : '').' src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($altfile).'&cache='.$cache.'">';
7653
-				if ($addlinktofullsize) $ret .= '</a>';
8576
+				if ($addlinktofullsize) {
8577
+					$ret .= '</a>';
8578
+				}
7654 8579
 			} else {
7655 8580
 				$nophoto = '/public/theme/common/nophoto.png';
7656 8581
 				if (in_array($modulepart, array('userphoto', 'contact', 'memberphoto'))) {	// For module that are "physical" users
@@ -7658,8 +8583,12 @@  discard block
 block discarded – undo
7658 8583
 						$nophoto = '/public/theme/common/company.png';
7659 8584
 					} else {
7660 8585
 						$nophoto = '/public/theme/common/user_anonymous.png';
7661
-						if ($object->gender == 'man') $nophoto = '/public/theme/common/user_man.png';
7662
-						if ($object->gender == 'woman') $nophoto = '/public/theme/common/user_woman.png';
8586
+						if ($object->gender == 'man') {
8587
+							$nophoto = '/public/theme/common/user_man.png';
8588
+						}
8589
+						if ($object->gender == 'woman') {
8590
+							$nophoto = '/public/theme/common/user_woman.png';
8591
+						}
7663 8592
 					}
7664 8593
 				}
7665 8594
 
@@ -7677,13 +8606,19 @@  discard block
 block discarded – undo
7677 8606
 
7678 8607
 			if ($caneditfield)
7679 8608
 			{
7680
-				if ($object->photo) $ret .= "<br>\n";
8609
+				if ($object->photo) {
8610
+					$ret .= "<br>\n";
8611
+				}
7681 8612
 				$ret .= '<table class="nobordernopadding centpercent">';
7682
-				if ($object->photo) $ret .= '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
8613
+				if ($object->photo) {
8614
+					$ret .= '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
8615
+				}
7683 8616
 				$ret .= '<tr><td class="tdoverflow"><input type="file" class="flat maxwidth200onsmartphone" name="photo" id="photoinput" accept="image/*"'.($capture ? ' capture="'.$capture.'"' : '').'></td></tr>';
7684 8617
 				$ret .= '</table>';
7685 8618
 			}
7686
-		} else dol_print_error('', 'Call of showphoto with wrong parameters modulepart='.$modulepart);
8619
+		} else {
8620
+			dol_print_error('', 'Call of showphoto with wrong parameters modulepart='.$modulepart);
8621
+		}
7687 8622
 
7688 8623
 		return $ret;
7689 8624
 	}
@@ -7711,11 +8646,17 @@  discard block
 block discarded – undo
7711 8646
 		global $conf, $user, $langs;
7712 8647
 
7713 8648
 		// Permettre l'exclusion de groupes
7714
-		if (is_array($exclude))	$excludeGroups = implode("','", $exclude);
8649
+		if (is_array($exclude)) {
8650
+			$excludeGroups = implode("','", $exclude);
8651
+		}
7715 8652
 		// Permettre l'inclusion de groupes
7716
-		if (is_array($include))	$includeGroups = implode("','", $include);
8653
+		if (is_array($include)) {
8654
+			$includeGroups = implode("','", $include);
8655
+		}
7717 8656
 
7718
-		if (!is_array($selected)) $selected = array($selected);
8657
+		if (!is_array($selected)) {
8658
+			$selected = array($selected);
8659
+		}
7719 8660
 
7720 8661
 		$out = '';
7721 8662
 
@@ -7729,13 +8670,20 @@  discard block
 block discarded – undo
7729 8670
 		if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity)
7730 8671
 		{
7731 8672
 			$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entity as e ON e.rowid=ug.entity";
7732
-			if ($force_entity) $sql .= " WHERE ug.entity IN (0, ".$force_entity.")";
7733
-			else $sql .= " WHERE ug.entity IS NOT NULL";
8673
+			if ($force_entity) {
8674
+				$sql .= " WHERE ug.entity IN (0, ".$force_entity.")";
8675
+			} else {
8676
+				$sql .= " WHERE ug.entity IS NOT NULL";
8677
+			}
7734 8678
 		} else {
7735 8679
 			$sql .= " WHERE ug.entity IN (0, ".$conf->entity.")";
7736 8680
 		}
7737
-		if (is_array($exclude) && $excludeGroups) $sql .= " AND ug.rowid NOT IN ('".$excludeGroups."')";
7738
-		if (is_array($include) && $includeGroups) $sql .= " AND ug.rowid IN ('".$includeGroups."')";
8681
+		if (is_array($exclude) && $excludeGroups) {
8682
+			$sql .= " AND ug.rowid NOT IN ('".$excludeGroups."')";
8683
+		}
8684
+		if (is_array($include) && $includeGroups) {
8685
+			$sql .= " AND ug.rowid IN ('".$includeGroups."')";
8686
+		}
7739 8687
 		$sql .= " ORDER BY ug.nom ASC";
7740 8688
 
7741 8689
 		dol_syslog(get_class($this)."::select_dolgroups", LOG_DEBUG);
@@ -7752,16 +8700,22 @@  discard block
 block discarded – undo
7752 8700
 			$i = 0;
7753 8701
 			if ($num)
7754 8702
 			{
7755
-				if ($show_empty && !$multiple) $out .= '<option value="-1"'.(in_array(-1, $selected) ? ' selected' : '').'>&nbsp;</option>'."\n";
8703
+				if ($show_empty && !$multiple) {
8704
+					$out .= '<option value="-1"'.(in_array(-1, $selected) ? ' selected' : '').'>&nbsp;</option>'."\n";
8705
+				}
7756 8706
 
7757 8707
 				while ($i < $num)
7758 8708
 				{
7759 8709
 					$obj = $this->db->fetch_object($resql);
7760 8710
 					$disableline = 0;
7761
-					if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) $disableline = 1;
8711
+					if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) {
8712
+						$disableline = 1;
8713
+					}
7762 8714
 
7763 8715
 					$out .= '<option value="'.$obj->rowid.'"';
7764
-					if ($disableline) $out .= ' disabled';
8716
+					if ($disableline) {
8717
+						$out .= ' disabled';
8718
+					}
7765 8719
 					if ((is_object($selected[0]) && $selected[0]->id == $obj->rowid) || (!is_object($selected[0]) && in_array($obj->rowid, $selected)))
7766 8720
 					{
7767 8721
 						$out .= ' selected';
@@ -7778,7 +8732,9 @@  discard block
 block discarded – undo
7778 8732
 					$i++;
7779 8733
 				}
7780 8734
 			} else {
7781
-				if ($show_empty) $out .= '<option value="-1"'.(in_array(-1, $selected) ? ' selected' : '').'></option>'."\n";
8735
+				if ($show_empty) {
8736
+					$out .= '<option value="-1"'.(in_array(-1, $selected) ? ' selected' : '').'></option>'."\n";
8737
+				}
7782 8738
 				$out .= '<option value="" disabled>'.$langs->trans("NoUserGroupDefined").'</option>';
7783 8739
 			}
7784 8740
 			$out .= '</select>';
@@ -7819,7 +8775,9 @@  discard block
 block discarded – undo
7819 8775
 
7820 8776
 		$out = '';
7821 8777
 
7822
-		if (!empty($conf->use_javascript_ajax)) $out .= '<div class="inline-block checkallactions"><input type="checkbox" id="'.$cssclass.'s" name="'.$cssclass.'s" class="checkallactions"></div>';
8778
+		if (!empty($conf->use_javascript_ajax)) {
8779
+			$out .= '<div class="inline-block checkallactions"><input type="checkbox" id="'.$cssclass.'s" name="'.$cssclass.'s" class="checkallactions"></div>';
8780
+		}
7823 8781
 		$out .= '<script>
7824 8782
             $(document).ready(function() {
7825 8783
                 $("#' . $cssclass.'s").click(function() {
@@ -7832,7 +8790,9 @@  discard block
 block discarded – undo
7832 8790
                         console.log("We uncheck all");
7833 8791
                 		$(".'.$cssclass.'").prop(\'checked\', false).trigger(\'change\');
7834 8792
                     }'."\n";
7835
-				if ($calljsfunction) $out .= 'if (typeof initCheckForSelect == \'function\') { initCheckForSelect(0, "'.$massactionname.'", "'.$cssclass.'"); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }';
8793
+				if ($calljsfunction) {
8794
+					$out .= 'if (typeof initCheckForSelect == \'function\') { initCheckForSelect(0, "'.$massactionname.'", "'.$cssclass.'"); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }';
8795
+				}
7836 8796
 		$out .= '         });
7837 8797
         	        $(".' . $cssclass.'").change(function() {
7838 8798
 					$(this).closest("tr").toggleClass("highlight", this.checked);
@@ -7882,14 +8842,18 @@  discard block
 block discarded – undo
7882 8842
 		$out = '';
7883 8843
 		$sql = 'SELECT rowid, label FROM '.MAIN_DB_PREFIX.'c_exp_tax_cat WHERE active = 1';
7884 8844
 		$sql .= ' AND entity IN (0,'.getEntity('exp_tax_cat').')';
7885
-		if (!empty($excludeid)) $sql .= ' AND rowid NOT IN ('.implode(',', $excludeid).')';
8845
+		if (!empty($excludeid)) {
8846
+			$sql .= ' AND rowid NOT IN ('.implode(',', $excludeid).')';
8847
+		}
7886 8848
 		$sql .= ' ORDER BY label';
7887 8849
 
7888 8850
 		$resql = $db->query($sql);
7889 8851
 		if ($resql)
7890 8852
 		{
7891 8853
 			$out = '<select id="select_'.$htmlname.'" name="'.$htmlname.'" class="'.$htmlname.' flat minwidth75imp maxwidth200">';
7892
-			if ($useempty) $out .= '<option value="0">&nbsp;</option>';
8854
+			if ($useempty) {
8855
+				$out .= '<option value="0">&nbsp;</option>';
8856
+			}
7893 8857
 
7894 8858
 			while ($obj = $db->fetch_object($resql))
7895 8859
 			{
@@ -7898,7 +8862,9 @@  discard block
 block discarded – undo
7898 8862
 			$out .= '</select>';
7899 8863
 			$out .= ajax_combobox('select_'.$htmlname);
7900 8864
 
7901
-			if (!empty($htmlname) && $user->admin && $info_admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
8865
+			if (!empty($htmlname) && $user->admin && $info_admin) {
8866
+				$out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
8867
+			}
7902 8868
 
7903 8869
 			if (!empty($target))
7904 8870
 			{
@@ -7914,7 +8880,9 @@  discard block
 block discarded – undo
7914 8880
 								$("select[name='.$target.']").on("change", function() {
7915 8881
 									var current_val = $(this).val();
7916 8882
 									if (current_val == '.$obj->id.') {';
7917
-						if (!empty($default_selected) || !empty($selected)) $out .= '$("select[name='.$htmlname.']").val("'.($default_selected > 0 ? $default_selected : $selected).'");';
8883
+						if (!empty($default_selected) || !empty($selected)) {
8884
+							$out .= '$("select[name='.$htmlname.']").val("'.($default_selected > 0 ? $default_selected : $selected).'");';
8885
+						}
7918 8886
 
7919 8887
 						$out .= '
7920 8888
 										$("select[name='.$htmlname.']").change();
@@ -7977,7 +8945,9 @@  discard block
 block discarded – undo
7977 8945
 		if ($resql)
7978 8946
 		{
7979 8947
 			$out = '<select id="select_'.$htmlname.'" name="'.$htmlname.'" class="'.$htmlname.' flat minwidth75imp">';
7980
-			if ($useempty) $out .= '<option value="0"></option>';
8948
+			if ($useempty) {
8949
+				$out .= '<option value="0"></option>';
8950
+			}
7981 8951
 
7982 8952
 			while ($obj = $db->fetch_object($resql))
7983 8953
 			{
@@ -8013,11 +8983,17 @@  discard block
 block discarded – undo
8013 8983
 		if ($resql)
8014 8984
 		{
8015 8985
 			$out = '<select id="select_'.$htmlname.'" name="'.$htmlname.'" class="'.$htmlname.' flat minwidth75imp">';
8016
-			if ($useempty) $out .= '<option value="0"></option>';
8017
-			if ($allchoice) $out .= '<option value="-1">'.$langs->trans('AllExpenseReport').'</option>';
8986
+			if ($useempty) {
8987
+				$out .= '<option value="0"></option>';
8988
+			}
8989
+			if ($allchoice) {
8990
+				$out .= '<option value="-1">'.$langs->trans('AllExpenseReport').'</option>';
8991
+			}
8018 8992
 
8019 8993
 			$field = 'code';
8020
-			if ($useid) $field = 'id';
8994
+			if ($useid) {
8995
+				$field = 'id';
8996
+			}
8021 8997
 
8022 8998
 			while ($obj = $db->fetch_object($resql))
8023 8999
 			{
@@ -8064,7 +9040,9 @@  discard block
 block discarded – undo
8064 9040
 		$out = '';
8065 9041
 
8066 9042
 		$hideunselectables = false;
8067
-		if (!empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;
9043
+		if (!empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) {
9044
+			$hideunselectables = true;
9045
+		}
8068 9046
 
8069 9047
 		if (empty($projectsListId))
8070 9048
 		{
@@ -8106,8 +9084,11 @@  discard block
 block discarded – undo
8106 9084
 			}
8107 9085
 			if (!empty($show_empty)) {
8108 9086
 				$out .= '<option value="0" class="optiongrey">';
8109
-				if (!is_numeric($show_empty)) $out .= $show_empty;
8110
-				else $out .= '&nbsp;';
9087
+				if (!is_numeric($show_empty)) {
9088
+					$out .= $show_empty;
9089
+				} else {
9090
+					$out .= '&nbsp;';
9091
+				}
8111 9092
 				$out .= '</option>';
8112 9093
 			}
8113 9094
 			$num = $this->db->num_rows($resql);
@@ -8133,7 +9114,10 @@  discard block
 block discarded – undo
8133 9114
 						if ($showproject == 'all')
8134 9115
 						{
8135 9116
 							$labeltoshow .= dol_trunc($obj->ref, 18); // Invoice ref
8136
-							if ($obj->name) $labeltoshow .= ' - '.$obj->name; // Soc name
9117
+							if ($obj->name) {
9118
+								$labeltoshow .= ' - '.$obj->name;
9119
+							}
9120
+							// Soc name
8137 9121
 
8138 9122
 							$disabled = 0;
8139 9123
 							if ($obj->fk_statut == Project::STATUS_DRAFT)
@@ -8142,7 +9126,9 @@  discard block
 block discarded – undo
8142 9126
 								$labeltoshow .= ' - '.$langs->trans("Draft");
8143 9127
 							} elseif ($obj->fk_statut == Project::STATUS_CLOSED)
8144 9128
 							{
8145
-								if ($discard_closed == 2) $disabled = 1;
9129
+								if ($discard_closed == 2) {
9130
+									$disabled = 1;
9131
+								}
8146 9132
 								$labeltoshow .= ' - '.$langs->trans("Closed");
8147 9133
 							} elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid))
8148 9134
 							{
@@ -8162,7 +9148,9 @@  discard block
 block discarded – undo
8162 9148
 								$resultat = '';
8163 9149
 							} else {
8164 9150
 								$resultat = '<option value="'.$obj->rowid.'"';
8165
-								if ($disabled) $resultat .= ' disabled';
9151
+								if ($disabled) {
9152
+									$resultat .= ' disabled';
9153
+								}
8166 9154
 								//if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
8167 9155
 								//else $labeltoshow.=' ('.$langs->trans("Private").')';
8168 9156
 								$resultat .= '>';
@@ -8219,8 +9207,12 @@  discard block
 block discarded – undo
8219 9207
 		// For compatibility with forms that show themself the search criteria in addition of this component, we output the fields
8220 9208
 		foreach ($arrayofcriterias as $criterias) {
8221 9209
 			foreach ($criterias as $criteriafamilykey => $criteriafamilyval) {
8222
-				if (in_array('search_'.$criteriafamilykey, $arrayofinputfieldsalreadyoutput)) continue;
8223
-				if (in_array($criteriafamilykey, array('rowid', 'ref_ext', 'entity', 'extraparams'))) continue;
9210
+				if (in_array('search_'.$criteriafamilykey, $arrayofinputfieldsalreadyoutput)) {
9211
+					continue;
9212
+				}
9213
+				if (in_array($criteriafamilykey, array('rowid', 'ref_ext', 'entity', 'extraparams'))) {
9214
+					continue;
9215
+				}
8224 9216
 				if (in_array($criteriafamilyval['type'], array('date', 'datetime', 'timestamp'))) {
8225 9217
 					$ret .= '<input type="hidden" name="search_'.$criteriafamilykey.'_start">';
8226 9218
 					$ret .= '<input type="hidden" name="search_'.$criteriafamilykey.'_startyear">';
@@ -8262,7 +9254,9 @@  discard block
 block discarded – undo
8262 9254
 		$formmail = new FormMail($db);
8263 9255
 		$result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs);
8264 9256
 
8265
-		if ($default) $TModels[0] = $langs->trans('DefaultMailModel');
9257
+		if ($default) {
9258
+			$TModels[0] = $langs->trans('DefaultMailModel');
9259
+		}
8266 9260
 		if ($result > 0) {
8267 9261
 			foreach ($formmail->lines_model as $model) {
8268 9262
 				$TModels[$model->id] = $model->label;
@@ -8278,7 +9272,9 @@  discard block
 block discarded – undo
8278 9272
 
8279 9273
 		$retstring .= "</select>";
8280 9274
 
8281
-		if ($addjscombo) $retstring .= ajax_combobox('select_'.$prefix.'model_mail');
9275
+		if ($addjscombo) {
9276
+			$retstring .= ajax_combobox('select_'.$prefix.'model_mail');
9277
+		}
8282 9278
 
8283 9279
 		return $retstring;
8284 9280
 	}
Please login to merge, or discard this patch.
htdocs/core/lib/prelevement.lib.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -85,11 +85,11 @@
 block discarded – undo
85 85
 function prelevement_check_config($type = 'direct-debit')
86 86
 {
87 87
 	global $conf, $db;
88
-	if ($type == 'bank-transfer'){
88
+	if ($type == 'bank-transfer') {
89 89
 		if (empty($conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT)) return -1;
90 90
 		//if (empty($conf->global->PRELEVEMENT_ICS)) return -1;
91 91
 		if (empty($conf->global->PAYMENTBYBANKTRANSFER_USER)) return -1;
92
-	}else {
92
+	} else {
93 93
 		if (empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) return -1;
94 94
 		//if (empty($conf->global->PRELEVEMENT_ICS)) return -1;
95 95
 		if (empty($conf->global->PRELEVEMENT_USER)) return -1;
Please login to merge, or discard this patch.
Braces   +13 added lines, -5 removed lines patch added patch discarded remove patch
@@ -86,13 +86,21 @@
 block discarded – undo
86 86
 {
87 87
 	global $conf, $db;
88 88
 	if ($type == 'bank-transfer'){
89
-		if (empty($conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT)) return -1;
89
+		if (empty($conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT)) {
90
+			return -1;
91
+		}
90 92
 		//if (empty($conf->global->PRELEVEMENT_ICS)) return -1;
91
-		if (empty($conf->global->PAYMENTBYBANKTRANSFER_USER)) return -1;
92
-	}else {
93
-		if (empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) return -1;
93
+		if (empty($conf->global->PAYMENTBYBANKTRANSFER_USER)) {
94
+			return -1;
95
+		}
96
+	} else {
97
+		if (empty($conf->global->PRELEVEMENT_ID_BANKACCOUNT)) {
98
+			return -1;
99
+		}
94 100
 		//if (empty($conf->global->PRELEVEMENT_ICS)) return -1;
95
-		if (empty($conf->global->PRELEVEMENT_USER)) return -1;
101
+		if (empty($conf->global->PRELEVEMENT_USER)) {
102
+			return -1;
103
+		}
96 104
 	}
97 105
 	return 0;
98 106
 }
Please login to merge, or discard this patch.
htdocs/fichinter/class/fichinterrec.class.php 1 patch
Braces   +41 added lines, -18 removed lines patch added patch discarded remove patch
@@ -239,13 +239,14 @@  discard block
 block discarded – undo
239 239
 						$fichintsrc->lines[$i]->fk_unit
240 240
 					);
241 241
 
242
-					if ($result_insert < 0)
243
-						$error++;
242
+					if ($result_insert < 0) {
243
+											$error++;
244
+					}
244 245
 				}
245 246
 
246
-				if ($error)
247
-					$this->db->rollback();
248
-				else {
247
+				if ($error) {
248
+									$this->db->rollback();
249
+				} else {
249 250
 					$this->db->commit();
250 251
 					return $this->id;
251 252
 				}
@@ -277,8 +278,11 @@  discard block
 block discarded – undo
277 278
 		$sql .= ', f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.auto_validate';
278 279
 		$sql .= ', f.note_private, f.note_public, f.fk_user_author';
279 280
 		$sql .= ' FROM '.MAIN_DB_PREFIX.'fichinter_rec as f';
280
-		if ($rowid > 0) $sql .= ' WHERE f.rowid='.$rowid;
281
-		elseif ($ref) $sql .= " WHERE f.titre='".$this->db->escape($ref)."'";
281
+		if ($rowid > 0) {
282
+			$sql .= ' WHERE f.rowid='.$rowid;
283
+		} elseif ($ref) {
284
+			$sql .= " WHERE f.titre='".$this->db->escape($ref)."'";
285
+		}
282 286
 
283 287
 		dol_syslog(get_class($this)."::fetch rowid=".$rowid, LOG_DEBUG);
284 288
 
@@ -421,7 +425,9 @@  discard block
 block discarded – undo
421 425
 	 */
422 426
 	public function delete($rowid = 0, $notrigger = 0, $idwarehouse = -1)
423 427
 	{
424
-		if (empty($rowid)) $rowid = $this->id;
428
+		if (empty($rowid)) {
429
+			$rowid = $this->id;
430
+		}
425 431
 
426 432
 		dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG);
427 433
 
@@ -481,14 +487,20 @@  discard block
 block discarded – undo
481 487
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
482 488
 
483 489
 		// Check parameters
484
-		if ($type < 0) return -1;
490
+		if ($type < 0) {
491
+			return -1;
492
+		}
485 493
 
486 494
 		if ($this->brouillon) {
487 495
 			// Clean parameters
488 496
 			$remise_percent = price2num($remise_percent);
489 497
 			$qty = price2num($qty);
490
-			if (!$qty) $qty = 1;
491
-			if (!$info_bits) $info_bits = 0;
498
+			if (!$qty) {
499
+				$qty = 1;
500
+			}
501
+			if (!$info_bits) {
502
+				$info_bits = 0;
503
+			}
492 504
 			$pu_ht = price2num($pu_ht);
493 505
 			$pu_ttc = price2num($pu_ttc);
494 506
 			if (!preg_match('/\((.*)\)/', $txtva)) {
@@ -623,7 +635,9 @@  discard block
 block discarded – undo
623 635
 
624 636
 		$url = DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$this->id;
625 637
 
626
-		if ($short) return $url;
638
+		if ($short) {
639
+			return $url;
640
+		}
627 641
 
628 642
 		$picto = 'intervention';
629 643
 
@@ -709,7 +723,9 @@  discard block
 block discarded – undo
709 723
 		dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG);
710 724
 		if ($this->db->query($sql)) {
711 725
 			$this->frequency = $frequency;
712
-			if (!empty($unit)) $this->unit_frequency = $unit;
726
+			if (!empty($unit)) {
727
+				$this->unit_frequency = $unit;
728
+			}
713 729
 			return 1;
714 730
 		} else {
715 731
 			dol_print_error($this->db);
@@ -732,13 +748,17 @@  discard block
 block discarded – undo
732 748
 		}
733 749
 		$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
734 750
 		$sql .= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "null");
735
-		if ($increment_nb_gen_done > 0) $sql .= ', nb_gen_done = nb_gen_done + 1';
751
+		if ($increment_nb_gen_done > 0) {
752
+			$sql .= ', nb_gen_done = nb_gen_done + 1';
753
+		}
736 754
 		$sql .= ' WHERE rowid = '.$this->id;
737 755
 
738 756
 		dol_syslog(get_class($this)."::setNextDate", LOG_DEBUG);
739 757
 		if ($this->db->query($sql)) {
740 758
 			$this->date_when = $date;
741
-			if ($increment_nb_gen_done > 0) $this->nb_gen_done++;
759
+			if ($increment_nb_gen_done > 0) {
760
+				$this->nb_gen_done++;
761
+			}
742 762
 			return 1;
743 763
 		} else {
744 764
 			dol_print_error($this->db);
@@ -759,7 +779,9 @@  discard block
 block discarded – undo
759 779
 			return -1;
760 780
 		}
761 781
 
762
-		if (empty($nb)) $nb = 0;
782
+		if (empty($nb)) {
783
+			$nb = 0;
784
+		}
763 785
 
764 786
 		$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
765 787
 		$sql .= ' SET nb_gen_max = '.$nb;
@@ -818,8 +840,9 @@  discard block
 block discarded – undo
818 840
 		$sql .= ' SET nb_gen_done = nb_gen_done + 1';
819 841
 		$sql .= ' , date_last_gen = now()';
820 842
 		// si on et arrivé à la fin des génération
821
-		if ($this->nb_gen_max == $this->nb_gen_done + 1)
822
-			$sql .= ' , statut = 1';
843
+		if ($this->nb_gen_max == $this->nb_gen_done + 1) {
844
+					$sql .= ' , statut = 1';
845
+		}
823 846
 
824 847
 		$sql .= ' WHERE rowid = '.$this->id;
825 848
 
Please login to merge, or discard this patch.
htdocs/adherents/list.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -408,7 +408,7 @@
 block discarded – undo
408 408
 if ($user->rights->adherent->creer) $arrayofmassactions['close'] = $langs->trans("Resiliate");
409 409
 if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
410 410
 if ($user->rights->societe->creer) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
411
-if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array();
411
+if (in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) $arrayofmassactions = array();
412 412
 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
413 413
 
414 414
 $newcardbutton = '';
Please login to merge, or discard this patch.
Braces   +348 added lines, -116 removed lines patch added patch discarded remove patch
@@ -69,13 +69,21 @@  discard block
 block discarded – undo
69 69
 $optioncss = GETPOST('optioncss', 'alpha');
70 70
 
71 71
 $filter = GETPOST("filter", 'alpha');
72
-if ($filter) $search_filter = $filter; // For backward compatibility
72
+if ($filter) {
73
+	$search_filter = $filter;
74
+}
75
+// For backward compatibility
73 76
 $statut = GETPOST("statut", 'alpha');
74
-if ($statut != '') $search_status = $statut; // For backward compatibility
77
+if ($statut != '') {
78
+	$search_status = $statut;
79
+}
80
+// For backward compatibility
75 81
 
76 82
 $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
77 83
 
78
-if ($search_status < -1) $search_status = '';
84
+if ($search_status < -1) {
85
+	$search_status = '';
86
+}
79 87
 
80 88
 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
81 89
 $sortfield = GETPOST("sortfield", 'alpha');
@@ -117,7 +125,9 @@  discard block
 block discarded – undo
117 125
 	'd.note_public'=>'NotePublic',
118 126
 	'd.note_private'=>'NotePrivate',
119 127
 );
120
-if ($db->type == 'pgsql') unset($fieldstosearchall['d.rowid']);
128
+if ($db->type == 'pgsql') {
129
+	unset($fieldstosearchall['d.rowid']);
130
+}
121 131
 $arrayfields = array(
122 132
 	'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
123 133
 	'd.civility'=>array('label'=>$langs->trans("Civility"), 'checked'=>0),
@@ -158,7 +168,9 @@  discard block
 block discarded – undo
158 168
 
159 169
 $parameters = array('socid'=>$socid);
160 170
 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
161
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
171
+if ($reshook < 0) {
172
+	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
173
+}
162 174
 
163 175
 if (empty($reshook)) {
164 176
 	// Selection of new fields
@@ -212,7 +224,9 @@  discard block
 block discarded – undo
212 224
 			if ($result < 0 && !count($tmpmember->errors)) {
213 225
 				setEventMessages($tmpmember->error, $tmpmember->errors, 'errors');
214 226
 			} else {
215
-				if ($result > 0) $nbclose++;
227
+				if ($result > 0) {
228
+					$nbclose++;
229
+				}
216 230
 			}
217 231
 		}
218 232
 
@@ -256,8 +270,9 @@  discard block
 block discarded – undo
256 270
 $sql .= " t.libelle as type, t.subscription,";
257 271
 $sql .= " state.code_departement as state_code, state.nom as state_name,";
258 272
 // Add fields from extrafields
259
-if (!empty($extrafields->attributes[$object->table_element]['label']))
273
+if (!empty($extrafields->attributes[$object->table_element]['label'])) {
260 274
 	foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
275
+}
261 276
 // Add fields from hooks
262 277
 $parameters = array();
263 278
 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
@@ -276,16 +291,34 @@  discard block
 block discarded – undo
276 291
 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on (s.rowid = d.fk_soc)";
277 292
 $sql .= ", ".MAIN_DB_PREFIX."adherent_type as t";
278 293
 $sql .= " WHERE d.fk_adherent_type = t.rowid ";
279
-if ($catid > 0)    $sql .= " AND cm.fk_categorie = ".$db->escape($catid);
280
-if ($catid == -2)  $sql .= " AND cm.fk_categorie IS NULL";
281
-if ($search_categ > 0)   $sql .= " AND cm.fk_categorie = ".$db->escape($search_categ);
282
-if ($search_categ == -2) $sql .= " AND cm.fk_categorie IS NULL";
294
+if ($catid > 0) {
295
+	$sql .= " AND cm.fk_categorie = ".$db->escape($catid);
296
+}
297
+if ($catid == -2) {
298
+	$sql .= " AND cm.fk_categorie IS NULL";
299
+}
300
+if ($search_categ > 0) {
301
+	$sql .= " AND cm.fk_categorie = ".$db->escape($search_categ);
302
+}
303
+if ($search_categ == -2) {
304
+	$sql .= " AND cm.fk_categorie IS NULL";
305
+}
283 306
 $sql .= " AND d.entity IN (".getEntity('adherent').")";
284
-if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
285
-if ($search_type > 0) $sql .= " AND t.rowid=".$db->escape($search_type);
286
-if ($search_filter == 'withoutsubscription') $sql .= " AND (datefin IS NULL OR t.subscription = 0)";
287
-if ($search_filter == 'uptodate') $sql .= " AND (datefin >= '".$db->idate($now)."' OR t.subscription = 0)";
288
-if ($search_filter == 'outofdate') $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)";
307
+if ($sall) {
308
+	$sql .= natural_search(array_keys($fieldstosearchall), $sall);
309
+}
310
+if ($search_type > 0) {
311
+	$sql .= " AND t.rowid=".$db->escape($search_type);
312
+}
313
+if ($search_filter == 'withoutsubscription') {
314
+	$sql .= " AND (datefin IS NULL OR t.subscription = 0)";
315
+}
316
+if ($search_filter == 'uptodate') {
317
+	$sql .= " AND (datefin >= '".$db->idate($now)."' OR t.subscription = 0)";
318
+}
319
+if ($search_filter == 'outofdate') {
320
+	$sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)";
321
+}
289 322
 if ($search_status != '') {
290 323
 	// Peut valoir un nombre ou liste de nombre separes par virgules
291 324
 	$sql .= " AND d.statut in (".$db->sanitize($db->escape($search_status)).")";
@@ -293,21 +326,51 @@  discard block
 block discarded – undo
293 326
 if ($search_ref) {
294 327
 	$sql .= natural_search("d.ref", $search_ref);
295 328
 }
296
-if ($search_civility) $sql .= natural_search("d.civility", $search_civility);
297
-if ($search_firstname) $sql .= natural_search("d.firstname", $search_firstname);
298
-if ($search_lastname) $sql .= natural_search(array("d.firstname", "d.lastname", "d.societe"), $search_lastname);
299
-if ($search_gender != '' && $search_gender != '-1') $sql .= natural_search("d.gender", $search_gender);
300
-if ($search_login) $sql .= natural_search("d.login", $search_login);
301
-if ($search_company) $sql .= natural_search("s.nom", $search_company);
302
-if ($search_email) $sql .= natural_search("d.email", $search_email);
303
-if ($search_address) $sql .= natural_search("d.address", $search_address);
304
-if ($search_town)     $sql .= natural_search("d.town", $search_town);
305
-if ($search_zip)      $sql .= natural_search("d.zip", $search_zip);
306
-if ($search_state)    $sql .= natural_search("state.nom", $search_state);
307
-if ($search_phone)      $sql .= natural_search("d.phone", $search_phone);
308
-if ($search_phone_perso)      $sql .= natural_search("d.phone_perso", $search_phone_perso);
309
-if ($search_phone_mobile)      $sql .= natural_search("d.phone_mobile", $search_phone_mobile);
310
-if ($search_country) $sql .= " AND d.country IN (".$search_country.')';
329
+if ($search_civility) {
330
+	$sql .= natural_search("d.civility", $search_civility);
331
+}
332
+if ($search_firstname) {
333
+	$sql .= natural_search("d.firstname", $search_firstname);
334
+}
335
+if ($search_lastname) {
336
+	$sql .= natural_search(array("d.firstname", "d.lastname", "d.societe"), $search_lastname);
337
+}
338
+if ($search_gender != '' && $search_gender != '-1') {
339
+	$sql .= natural_search("d.gender", $search_gender);
340
+}
341
+if ($search_login) {
342
+	$sql .= natural_search("d.login", $search_login);
343
+}
344
+if ($search_company) {
345
+	$sql .= natural_search("s.nom", $search_company);
346
+}
347
+if ($search_email) {
348
+	$sql .= natural_search("d.email", $search_email);
349
+}
350
+if ($search_address) {
351
+	$sql .= natural_search("d.address", $search_address);
352
+}
353
+if ($search_town) {
354
+	$sql .= natural_search("d.town", $search_town);
355
+}
356
+if ($search_zip) {
357
+	$sql .= natural_search("d.zip", $search_zip);
358
+}
359
+if ($search_state) {
360
+	$sql .= natural_search("state.nom", $search_state);
361
+}
362
+if ($search_phone) {
363
+	$sql .= natural_search("d.phone", $search_phone);
364
+}
365
+if ($search_phone_perso) {
366
+	$sql .= natural_search("d.phone_perso", $search_phone_perso);
367
+}
368
+if ($search_phone_mobile) {
369
+	$sql .= natural_search("d.phone_mobile", $search_phone_mobile);
370
+}
371
+if ($search_country) {
372
+	$sql .= " AND d.country IN (".$search_country.')';
373
+}
311 374
 
312 375
 // Add where from extra fields
313 376
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
@@ -323,8 +386,11 @@  discard block
 block discarded – undo
323 386
 $nbtotalofrecords = '';
324 387
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
325 388
 	$resql = $db->query($sql);
326
-	if ($resql) $nbtotalofrecords = $db->num_rows($resql);
327
-	else dol_print_error($db);
389
+	if ($resql) {
390
+		$nbtotalofrecords = $db->num_rows($resql);
391
+	} else {
392
+		dol_print_error($db);
393
+	}
328 394
 	if (($page * $limit) > $nbtotalofrecords) {	// if total resultset is smaller then paging size (filtering), goto and load page 0
329 395
 		$page = 0;
330 396
 		$offset = 0;
@@ -373,30 +439,78 @@  discard block
 block discarded – undo
373 439
 }
374 440
 
375 441
 $param = '';
376
-if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
377
-if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
378
-if ($sall != "") $param .= "&sall=".urlencode($sall);
379
-if ($search_ref)   $param .= "&search_ref=".urlencode($search_ref);
380
-if ($search_civility) $param .= "&search_civility=".urlencode($search_civility);
381
-if ($search_firstname) $param .= "&search_firstname=".urlencode($search_firstname);
382
-if ($search_lastname)  $param .= "&search_lastname=".urlencode($search_lastname);
383
-if ($search_gender)  $param .= "&search_gender=".urlencode($search_gender);
384
-if ($search_login)   $param .= "&search_login=".urlencode($search_login);
385
-if ($search_email)   $param .= "&search_email=".urlencode($search_email);
386
-if ($search_categ)   $param .= "&search_categ=".urlencode($search_categ);
387
-if ($search_company) $param .= "&search_company=".urlencode($search_company);
388
-if ($search_address != '') $param .= "&search_address=".urlencode($search_address);
389
-if ($search_town != '') $param .= "&search_town=".urlencode($search_town);
390
-if ($search_zip != '') $param .= "&search_zip=".urlencode($search_zip);
391
-if ($search_state != '') $param .= "&search_state=".urlencode($search_state);
392
-if ($search_country != '') $param .= "&search_country=".urlencode($search_country);
393
-if ($search_phone != '') $param .= "&search_phone=".urlencode($search_phone);
394
-if ($search_phone_perso != '') $param .= "&search_phone_perso=".urlencode($search_phone_perso);
395
-if ($search_phone_mobile != '') $param .= "&search_phone_mobile=".urlencode($search_phone_mobile);
396
-if ($search_filter && $search_filter != '-1') $param .= "&search_filter=".urlencode($search_filter);
397
-if ($search_status != "" && $search_status != '-1') $param .= "&search_status=".urlencode($search_status);
398
-if ($search_type > 0)       $param .= "&search_type=".urlencode($search_type);
399
-if ($optioncss != '')       $param .= '&optioncss='.urlencode($optioncss);
442
+if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
443
+	$param .= '&contextpage='.urlencode($contextpage);
444
+}
445
+if ($limit > 0 && $limit != $conf->liste_limit) {
446
+	$param .= '&limit='.urlencode($limit);
447
+}
448
+if ($sall != "") {
449
+	$param .= "&sall=".urlencode($sall);
450
+}
451
+if ($search_ref) {
452
+	$param .= "&search_ref=".urlencode($search_ref);
453
+}
454
+if ($search_civility) {
455
+	$param .= "&search_civility=".urlencode($search_civility);
456
+}
457
+if ($search_firstname) {
458
+	$param .= "&search_firstname=".urlencode($search_firstname);
459
+}
460
+if ($search_lastname) {
461
+	$param .= "&search_lastname=".urlencode($search_lastname);
462
+}
463
+if ($search_gender) {
464
+	$param .= "&search_gender=".urlencode($search_gender);
465
+}
466
+if ($search_login) {
467
+	$param .= "&search_login=".urlencode($search_login);
468
+}
469
+if ($search_email) {
470
+	$param .= "&search_email=".urlencode($search_email);
471
+}
472
+if ($search_categ) {
473
+	$param .= "&search_categ=".urlencode($search_categ);
474
+}
475
+if ($search_company) {
476
+	$param .= "&search_company=".urlencode($search_company);
477
+}
478
+if ($search_address != '') {
479
+	$param .= "&search_address=".urlencode($search_address);
480
+}
481
+if ($search_town != '') {
482
+	$param .= "&search_town=".urlencode($search_town);
483
+}
484
+if ($search_zip != '') {
485
+	$param .= "&search_zip=".urlencode($search_zip);
486
+}
487
+if ($search_state != '') {
488
+	$param .= "&search_state=".urlencode($search_state);
489
+}
490
+if ($search_country != '') {
491
+	$param .= "&search_country=".urlencode($search_country);
492
+}
493
+if ($search_phone != '') {
494
+	$param .= "&search_phone=".urlencode($search_phone);
495
+}
496
+if ($search_phone_perso != '') {
497
+	$param .= "&search_phone_perso=".urlencode($search_phone_perso);
498
+}
499
+if ($search_phone_mobile != '') {
500
+	$param .= "&search_phone_mobile=".urlencode($search_phone_mobile);
501
+}
502
+if ($search_filter && $search_filter != '-1') {
503
+	$param .= "&search_filter=".urlencode($search_filter);
504
+}
505
+if ($search_status != "" && $search_status != '-1') {
506
+	$param .= "&search_status=".urlencode($search_status);
507
+}
508
+if ($search_type > 0) {
509
+	$param .= "&search_type=".urlencode($search_type);
510
+}
511
+if ($optioncss != '') {
512
+	$param .= '&optioncss='.urlencode($optioncss);
513
+}
400 514
 // Add $param from extra fields
401 515
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
402 516
 
@@ -405,10 +519,18 @@  discard block
 block discarded – undo
405 519
 	//'presend'=>$langs->trans("SendByMail"),
406 520
 	//'builddoc'=>$langs->trans("PDFMerge"),
407 521
 );
408
-if ($user->rights->adherent->creer) $arrayofmassactions['close'] = $langs->trans("Resiliate");
409
-if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
410
-if ($user->rights->societe->creer) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
411
-if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array();
522
+if ($user->rights->adherent->creer) {
523
+	$arrayofmassactions['close'] = $langs->trans("Resiliate");
524
+}
525
+if ($user->rights->adherent->supprimer) {
526
+	$arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
527
+}
528
+if ($user->rights->societe->creer) {
529
+	$arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
530
+}
531
+if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) {
532
+	$arrayofmassactions = array();
533
+}
412 534
 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
413 535
 
414 536
 $newcardbutton = '';
@@ -417,7 +539,9 @@  discard block
 block discarded – undo
417 539
 }
418 540
 
419 541
 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
420
-if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
542
+if ($optioncss != '') {
543
+	print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
544
+}
421 545
 print '<input type="hidden" name="token" value="'.newToken().'">';
422 546
 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
423 547
 print '<input type="hidden" name="action" value="list">';
@@ -434,7 +558,9 @@  discard block
 block discarded – undo
434 558
 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
435 559
 
436 560
 if ($sall) {
437
-	foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
561
+	foreach ($fieldstosearchall as $key => $val) {
562
+		$fieldstosearchall[$key] = $langs->trans($val);
563
+	}
438 564
 	print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
439 565
 }
440 566
 
@@ -449,8 +575,11 @@  discard block
 block discarded – undo
449 575
 }
450 576
 $parameters = array();
451 577
 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
452
-if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
453
-else $moreforfilter = $hookmanager->resPrint;
578
+if (empty($reshook)) {
579
+	$moreforfilter .= $hookmanager->resPrint;
580
+} else {
581
+	$moreforfilter = $hookmanager->resPrint;
582
+}
454 583
 if (!empty($moreforfilter)) {
455 584
 	print '<div class="liste_titre liste_titre_bydiv centpercent">';
456 585
 	print $moreforfilter;
@@ -459,7 +588,9 @@  discard block
 block discarded – undo
459 588
 
460 589
 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
461 590
 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
462
-if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
591
+if ($massactionbutton) {
592
+	$selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
593
+}
463 594
 
464 595
 print '<div class="div-table-responsive">';
465 596
 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
@@ -610,26 +741,66 @@  discard block
 block discarded – undo
610 741
 print "</tr>\n";
611 742
 
612 743
 print '<tr class="liste_titre">';
613
-if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID))       print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder);
614
-if (!empty($arrayfields['d.ref']['checked']))            print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], 'd.ref', '', $param, '', $sortfield, $sortorder);
615
-if (!empty($arrayfields['d.civility']['checked']))       print_liste_field_titre($arrayfields['d.civility']['label'], $_SERVER["PHP_SELF"], 'd.civility', '', $param, '', $sortfield, $sortorder);
616
-if (!empty($arrayfields['d.firstname']['checked']))      print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], 'd.firstname', '', $param, '', $sortfield, $sortorder);
617
-if (!empty($arrayfields['d.lastname']['checked']))       print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], 'd.lastname', '', $param, '', $sortfield, $sortorder);
618
-if (!empty($arrayfields['d.gender']['checked']))         print_liste_field_titre($arrayfields['d.gender']['label'], $_SERVER['PHP_SELF'], 'd.gender', $param, "", "", $sortfield, $sortorder);
619
-if (!empty($arrayfields['d.company']['checked']))        print_liste_field_titre($arrayfields['d.company']['label'], $_SERVER["PHP_SELF"], 'd.societe', '', $param, '', $sortfield, $sortorder);
620
-if (!empty($arrayfields['d.login']['checked']))          print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], 'd.login', '', $param, '', $sortfield, $sortorder);
621
-if (!empty($arrayfields['d.morphy']['checked']))         print_liste_field_titre($arrayfields['d.morphy']['label'], $_SERVER["PHP_SELF"], 'd.morphy', '', $param, '', $sortfield, $sortorder);
622
-if (!empty($arrayfields['t.libelle']['checked']))        print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], 't.libelle', '', $param, '', $sortfield, $sortorder);
623
-if (!empty($arrayfields['d.address']['checked']))        print_liste_field_titre($arrayfields['d.address']['label'], $_SERVER["PHP_SELF"], 'd.address', '', $param, '', $sortfield, $sortorder);
624
-if (!empty($arrayfields['d.zip']['checked']))            print_liste_field_titre($arrayfields['d.zip']['label'], $_SERVER["PHP_SELF"], 'd.zip', '', $param, '', $sortfield, $sortorder);
625
-if (!empty($arrayfields['d.town']['checked']))           print_liste_field_titre($arrayfields['d.town']['label'], $_SERVER["PHP_SELF"], 'd.town', '', $param, '', $sortfield, $sortorder);
626
-if (!empty($arrayfields['state.nom']['checked']))        print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
627
-if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder);
628
-if (!empty($arrayfields['d.phone']['checked']))          print_liste_field_titre($arrayfields['d.phone']['label'], $_SERVER["PHP_SELF"], 'd.phone', '', $param, '', $sortfield, $sortorder);
629
-if (!empty($arrayfields['d.phone_perso']['checked']))    print_liste_field_titre($arrayfields['d.phone_perso']['label'], $_SERVER["PHP_SELF"], 'd.phone_perso', '', $param, '', $sortfield, $sortorder);
630
-if (!empty($arrayfields['d.phone_mobile']['checked']))   print_liste_field_titre($arrayfields['d.phone_mobile']['label'], $_SERVER["PHP_SELF"], 'd.phone_mobile', '', $param, '', $sortfield, $sortorder);
631
-if (!empty($arrayfields['d.email']['checked']))          print_liste_field_titre($arrayfields['d.email']['label'], $_SERVER["PHP_SELF"], 'd.email', '', $param, '', $sortfield, $sortorder);
632
-if (!empty($arrayfields['d.datefin']['checked']))        print_liste_field_titre($arrayfields['d.datefin']['label'], $_SERVER["PHP_SELF"], 'd.datefin', '', $param, 'align="center"', $sortfield, $sortorder);
744
+if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
745
+	print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder);
746
+}
747
+if (!empty($arrayfields['d.ref']['checked'])) {
748
+	print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], 'd.ref', '', $param, '', $sortfield, $sortorder);
749
+}
750
+if (!empty($arrayfields['d.civility']['checked'])) {
751
+	print_liste_field_titre($arrayfields['d.civility']['label'], $_SERVER["PHP_SELF"], 'd.civility', '', $param, '', $sortfield, $sortorder);
752
+}
753
+if (!empty($arrayfields['d.firstname']['checked'])) {
754
+	print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], 'd.firstname', '', $param, '', $sortfield, $sortorder);
755
+}
756
+if (!empty($arrayfields['d.lastname']['checked'])) {
757
+	print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], 'd.lastname', '', $param, '', $sortfield, $sortorder);
758
+}
759
+if (!empty($arrayfields['d.gender']['checked'])) {
760
+	print_liste_field_titre($arrayfields['d.gender']['label'], $_SERVER['PHP_SELF'], 'd.gender', $param, "", "", $sortfield, $sortorder);
761
+}
762
+if (!empty($arrayfields['d.company']['checked'])) {
763
+	print_liste_field_titre($arrayfields['d.company']['label'], $_SERVER["PHP_SELF"], 'd.societe', '', $param, '', $sortfield, $sortorder);
764
+}
765
+if (!empty($arrayfields['d.login']['checked'])) {
766
+	print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], 'd.login', '', $param, '', $sortfield, $sortorder);
767
+}
768
+if (!empty($arrayfields['d.morphy']['checked'])) {
769
+	print_liste_field_titre($arrayfields['d.morphy']['label'], $_SERVER["PHP_SELF"], 'd.morphy', '', $param, '', $sortfield, $sortorder);
770
+}
771
+if (!empty($arrayfields['t.libelle']['checked'])) {
772
+	print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], 't.libelle', '', $param, '', $sortfield, $sortorder);
773
+}
774
+if (!empty($arrayfields['d.address']['checked'])) {
775
+	print_liste_field_titre($arrayfields['d.address']['label'], $_SERVER["PHP_SELF"], 'd.address', '', $param, '', $sortfield, $sortorder);
776
+}
777
+if (!empty($arrayfields['d.zip']['checked'])) {
778
+	print_liste_field_titre($arrayfields['d.zip']['label'], $_SERVER["PHP_SELF"], 'd.zip', '', $param, '', $sortfield, $sortorder);
779
+}
780
+if (!empty($arrayfields['d.town']['checked'])) {
781
+	print_liste_field_titre($arrayfields['d.town']['label'], $_SERVER["PHP_SELF"], 'd.town', '', $param, '', $sortfield, $sortorder);
782
+}
783
+if (!empty($arrayfields['state.nom']['checked'])) {
784
+	print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
785
+}
786
+if (!empty($arrayfields['country.code_iso']['checked'])) {
787
+	print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder);
788
+}
789
+if (!empty($arrayfields['d.phone']['checked'])) {
790
+	print_liste_field_titre($arrayfields['d.phone']['label'], $_SERVER["PHP_SELF"], 'd.phone', '', $param, '', $sortfield, $sortorder);
791
+}
792
+if (!empty($arrayfields['d.phone_perso']['checked'])) {
793
+	print_liste_field_titre($arrayfields['d.phone_perso']['label'], $_SERVER["PHP_SELF"], 'd.phone_perso', '', $param, '', $sortfield, $sortorder);
794
+}
795
+if (!empty($arrayfields['d.phone_mobile']['checked'])) {
796
+	print_liste_field_titre($arrayfields['d.phone_mobile']['label'], $_SERVER["PHP_SELF"], 'd.phone_mobile', '', $param, '', $sortfield, $sortorder);
797
+}
798
+if (!empty($arrayfields['d.email']['checked'])) {
799
+	print_liste_field_titre($arrayfields['d.email']['label'], $_SERVER["PHP_SELF"], 'd.email', '', $param, '', $sortfield, $sortorder);
800
+}
801
+if (!empty($arrayfields['d.datefin']['checked'])) {
802
+	print_liste_field_titre($arrayfields['d.datefin']['label'], $_SERVER["PHP_SELF"], 'd.datefin', '', $param, 'align="center"', $sortfield, $sortorder);
803
+}
633 804
 // Extra fields
634 805
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
635 806
 
@@ -637,10 +808,18 @@  discard block
 block discarded – undo
637 808
 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
638 809
 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
639 810
 print $hookmanager->resPrint;
640
-if (!empty($arrayfields['d.datec']['checked']))     print_liste_field_titre($arrayfields['d.datec']['label'], $_SERVER["PHP_SELF"], "d.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
641
-if (!empty($arrayfields['d.birth']['checked']))     print_liste_field_titre($arrayfields['d.birth']['label'], $_SERVER["PHP_SELF"], "d.birth", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
642
-if (!empty($arrayfields['d.tms']['checked']))       print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
643
-if (!empty($arrayfields['d.statut']['checked']))    print_liste_field_titre($arrayfields['d.statut']['label'], $_SERVER["PHP_SELF"], "d.statut", "", $param, 'class="right"', $sortfield, $sortorder);
811
+if (!empty($arrayfields['d.datec']['checked'])) {
812
+	print_liste_field_titre($arrayfields['d.datec']['label'], $_SERVER["PHP_SELF"], "d.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
813
+}
814
+if (!empty($arrayfields['d.birth']['checked'])) {
815
+	print_liste_field_titre($arrayfields['d.birth']['label'], $_SERVER["PHP_SELF"], "d.birth", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
816
+}
817
+if (!empty($arrayfields['d.tms']['checked'])) {
818
+	print_liste_field_titre($arrayfields['d.tms']['label'], $_SERVER["PHP_SELF"], "d.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
819
+}
820
+if (!empty($arrayfields['d.statut']['checked'])) {
821
+	print_liste_field_titre($arrayfields['d.statut']['label'], $_SERVER["PHP_SELF"], "d.statut", "", $param, 'class="right"', $sortfield, $sortorder);
822
+}
644 823
 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
645 824
 print "</tr>\n";
646 825
 
@@ -677,7 +856,9 @@  discard block
 block discarded – undo
677 856
 
678 857
 	if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
679 858
 		print '<td class="center">'.$obj->rowid.'</td>';
680
-		if (!$i) $totalarray['nbfield']++;
859
+		if (!$i) {
860
+			$totalarray['nbfield']++;
861
+		}
681 862
 	}
682 863
 
683 864
 	// Ref
@@ -685,35 +866,47 @@  discard block
 block discarded – undo
685 866
 		print "<td>";
686 867
 		print $memberstatic->getNomUrl(-1, 0, 'card', 'ref', '', -1, 0, 1);
687 868
 		print "</td>\n";
688
-		if (!$i) $totalarray['nbfield']++;
869
+		if (!$i) {
870
+			$totalarray['nbfield']++;
871
+		}
689 872
 	}
690 873
 	// Civility
691 874
 	if (!empty($arrayfields['d.civility']['checked'])) {
692 875
 		print "<td>";
693 876
 		print $obj->civility;
694 877
 		print "</td>\n";
695
-		if (!$i) $totalarray['nbfield']++;
878
+		if (!$i) {
879
+			$totalarray['nbfield']++;
880
+		}
696 881
 	}
697 882
 	// Firstname
698 883
 	if (!empty($arrayfields['d.firstname']['checked'])) {
699 884
 		print "<td>";
700 885
 		print $obj->firstname;
701 886
 		print "</td>\n";
702
-		if (!$i) $totalarray['nbfield']++;
887
+		if (!$i) {
888
+			$totalarray['nbfield']++;
889
+		}
703 890
 	}
704 891
 	// Lastname
705 892
 	if (!empty($arrayfields['d.lastname']['checked'])) {
706 893
 		print "<td>";
707 894
 		print $obj->lastname;
708 895
 		print "</td>\n";
709
-		if (!$i) $totalarray['nbfield']++;
896
+		if (!$i) {
897
+			$totalarray['nbfield']++;
898
+		}
710 899
 	}
711 900
 	// Gender
712 901
 	if (!empty($arrayfields['d.gender']['checked'])) {
713 902
 		print '<td>';
714
-		if ($obj->gender) print $langs->trans("Gender".$obj->gender);
903
+		if ($obj->gender) {
904
+			print $langs->trans("Gender".$obj->gender);
905
+		}
715 906
 		print '</td>';
716
-		if (!$i) $totalarray['nbfield']++;
907
+		if (!$i) {
908
+			$totalarray['nbfield']++;
909
+		}
717 910
 	}
718 911
 	// Company
719 912
 	if (!empty($arrayfields['d.company']['checked'])) {
@@ -724,7 +917,9 @@  discard block
 block discarded – undo
724 917
 	// Login
725 918
 	if (!empty($arrayfields['d.login']['checked'])) {
726 919
 		print "<td>".$obj->login."</td>\n";
727
-		if (!$i) $totalarray['nbfield']++;
920
+		if (!$i) {
921
+			$totalarray['nbfield']++;
922
+		}
728 923
 	}
729 924
 	// Nature (Moral/Physical)
730 925
 	if (!empty($arrayfields['d.morphy']['checked'])) {
@@ -738,7 +933,9 @@  discard block
 block discarded – undo
738 933
 		}
739 934
 		print $s;
740 935
 		print "</td>\n";
741
-		if (!$i) $totalarray['nbfield']++;
936
+		if (!$i) {
937
+			$totalarray['nbfield']++;
938
+		}
742 939
 	}
743 940
 	// Type label
744 941
 	if (!empty($arrayfields['t.libelle']['checked'])) {
@@ -747,33 +944,43 @@  discard block
 block discarded – undo
747 944
 		print '<td class="nowrap">';
748 945
 		print $membertypestatic->getNomUrl(1, 32);
749 946
 		print '</td>';
750
-		if (!$i) $totalarray['nbfield']++;
947
+		if (!$i) {
948
+			$totalarray['nbfield']++;
949
+		}
751 950
 	}
752 951
 	// Address
753 952
 	if (!empty($arrayfields['d.address']['checked'])) {
754 953
 		print '<td class="nocellnopadd">';
755 954
 		print $obj->address;
756 955
 		print '</td>';
757
-		if (!$i) $totalarray['nbfield']++;
956
+		if (!$i) {
957
+			$totalarray['nbfield']++;
958
+		}
758 959
 	}
759 960
 	// Zip
760 961
 	if (!empty($arrayfields['d.zip']['checked'])) {
761 962
 		print '<td class="nocellnopadd">';
762 963
 		print $obj->zip;
763 964
 		print '</td>';
764
-		if (!$i) $totalarray['nbfield']++;
965
+		if (!$i) {
966
+			$totalarray['nbfield']++;
967
+		}
765 968
 	}
766 969
 	// Town
767 970
 	if (!empty($arrayfields['d.town']['checked'])) {
768 971
 		print '<td class="nocellnopadd">';
769 972
 		print $obj->town;
770 973
 		print '</td>';
771
-		if (!$i) $totalarray['nbfield']++;
974
+		if (!$i) {
975
+			$totalarray['nbfield']++;
976
+		}
772 977
 	}
773 978
 	// State
774 979
 	if (!empty($arrayfields['state.nom']['checked'])) {
775 980
 		print "<td>".$obj->state_name."</td>\n";
776
-		if (!$i) $totalarray['nbfield']++;
981
+		if (!$i) {
982
+			$totalarray['nbfield']++;
983
+		}
777 984
 	}
778 985
 	// Country
779 986
 	if (!empty($arrayfields['country.code_iso']['checked'])) {
@@ -781,28 +988,36 @@  discard block
 block discarded – undo
781 988
 		$tmparray = getCountry($obj->country, 'all');
782 989
 		print $tmparray['label'];
783 990
 		print '</td>';
784
-		if (!$i) $totalarray['nbfield']++;
991
+		if (!$i) {
992
+			$totalarray['nbfield']++;
993
+		}
785 994
 	}
786 995
 	// Phone pro
787 996
 	if (!empty($arrayfields['d.phone']['checked'])) {
788 997
 		print '<td class="nocellnopadd">';
789 998
 		print $obj->phone;
790 999
 		print '</td>';
791
-		if (!$i) $totalarray['nbfield']++;
1000
+		if (!$i) {
1001
+			$totalarray['nbfield']++;
1002
+		}
792 1003
 	}
793 1004
 	// Phone perso
794 1005
 	if (!empty($arrayfields['d.phone_perso']['checked'])) {
795 1006
 		print '<td class="nocellnopadd">';
796 1007
 		print $obj->phone_perso;
797 1008
 		print '</td>';
798
-		if (!$i) $totalarray['nbfield']++;
1009
+		if (!$i) {
1010
+			$totalarray['nbfield']++;
1011
+		}
799 1012
 	}
800 1013
 	// Phone mobile
801 1014
 	if (!empty($arrayfields['d.phone_mobile']['checked'])) {
802 1015
 		print '<td class="nocellnopadd">';
803 1016
 		print $obj->phone_mobile;
804 1017
 		print '</td>';
805
-		if (!$i) $totalarray['nbfield']++;
1018
+		if (!$i) {
1019
+			$totalarray['nbfield']++;
1020
+		}
806 1021
 	}
807 1022
 	// EMail
808 1023
 	if (!empty($arrayfields['d.email']['checked'])) {
@@ -823,7 +1038,9 @@  discard block
 block discarded – undo
823 1038
 			print '<td class="nowrap left">';
824 1039
 			if ($obj->subscription == 'yes') {
825 1040
 				print $langs->trans("SubscriptionNotReceived");
826
-				if ($obj->statut > 0) print " ".img_warning();
1041
+				if ($obj->statut > 0) {
1042
+					print " ".img_warning();
1043
+				}
827 1044
 			} else {
828 1045
 				print '&nbsp;';
829 1046
 			}
@@ -841,38 +1058,50 @@  discard block
 block discarded – undo
841 1058
 		print '<td class="nowrap center">';
842 1059
 		print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
843 1060
 		print '</td>';
844
-		if (!$i) $totalarray['nbfield']++;
1061
+		if (!$i) {
1062
+			$totalarray['nbfield']++;
1063
+		}
845 1064
 	}
846 1065
 	// Birth
847 1066
 	if (!empty($arrayfields['d.birth']['checked'])) {
848 1067
 		print '<td class="nowrap center">';
849 1068
 		print dol_print_date($db->jdate($obj->birth), 'day', 'tzuser');
850 1069
 		print '</td>';
851
-		if (!$i) $totalarray['nbfield']++;
1070
+		if (!$i) {
1071
+			$totalarray['nbfield']++;
1072
+		}
852 1073
 	}
853 1074
 	// Date modification
854 1075
 	if (!empty($arrayfields['d.tms']['checked'])) {
855 1076
 		print '<td class="nowrap center">';
856 1077
 		print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
857 1078
 		print '</td>';
858
-		if (!$i) $totalarray['nbfield']++;
1079
+		if (!$i) {
1080
+			$totalarray['nbfield']++;
1081
+		}
859 1082
 	}
860 1083
 	// Status
861 1084
 	if (!empty($arrayfields['d.statut']['checked'])) {
862 1085
 		print '<td class="nowrap right">';
863 1086
 		print $memberstatic->LibStatut($obj->statut, $obj->subscription, $datefin, 5);
864 1087
 		print '</td>';
865
-		if (!$i) $totalarray['nbfield']++;
1088
+		if (!$i) {
1089
+			$totalarray['nbfield']++;
1090
+		}
866 1091
 	}
867 1092
 	// Action column
868 1093
 	print '<td class="center">';
869 1094
 	if ($massactionbutton || $massaction) {   // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
870 1095
 		$selected = 0;
871
-		if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
1096
+		if (in_array($obj->rowid, $arrayofselected)) {
1097
+			$selected = 1;
1098
+		}
872 1099
 		print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
873 1100
 	}
874 1101
 	print '</td>';
875
-	if (!$i) $totalarray['nbfield']++;
1102
+	if (!$i) {
1103
+		$totalarray['nbfield']++;
1104
+	}
876 1105
 
877 1106
 	print "</tr>\n";
878 1107
 	$i++;
@@ -885,7 +1114,10 @@  discard block
 block discarded – undo
885 1114
 // If no record found
886 1115
 if ($num == 0) {
887 1116
 	$colspan = 1;
888
-	foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
1117
+	foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) {
1118
+		$colspan++;
1119
+	}
1120
+	}
889 1121
 	print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
890 1122
 }
891 1123
 
Please login to merge, or discard this patch.
htdocs/comm/action/list.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -298,7 +298,7 @@
 block discarded – undo
298 298
 	$arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
299 299
 }
300 300
 if ($user->rights->agenda->myactions->create) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
301
-if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array();
301
+if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) $arrayofmassactions = array();
302 302
 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
303 303
 
304 304
 $sql = "SELECT";
Please login to merge, or discard this patch.
Braces   +335 added lines, -119 removed lines patch added patch discarded remove patch
@@ -27,7 +27,9 @@  discard block
 block discarded – undo
27 27
  *		\brief      Page to list actions
28 28
  */
29 29
 
30
-if (!defined("NOREDIRECTBYMAINTOLOGIN"))  define('NOREDIRECTBYMAINTOLOGIN', 1);
30
+if (!defined("NOREDIRECTBYMAINTOLOGIN")) {
31
+	define('NOREDIRECTBYMAINTOLOGIN', 1);
32
+}
31 33
 
32 34
 require '../../main.inc.php';
33 35
 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
@@ -58,11 +60,15 @@  discard block
 block discarded – undo
58 60
 if (GETPOST('search_actioncode', 'array'))
59 61
 {
60 62
 	$actioncode = GETPOST('search_actioncode', 'array', 3);
61
-	if (!count($actioncode)) $actioncode = '0';
62
-} else {
63
+	if (!count($actioncode)) {
64
+		$actioncode = '0';
65
+	}
66
+	} else {
63 67
 	$actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
64 68
 }
65
-if ($actioncode == '' && empty($actioncodearray)) $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE);
69
+if ($actioncode == '' && empty($actioncodearray)) {
70
+	$actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE);
71
+}
66 72
 $search_id = GETPOST('search_id', 'alpha');
67 73
 $search_title = GETPOST('search_title', 'alpha');
68 74
 $search_note = GETPOST('search_note', 'alpha');
@@ -70,8 +76,12 @@  discard block
 block discarded – undo
70 76
 $dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int'));
71 77
 $datestart = dol_mktime(0, 0, 0, GETPOST('datestartmonth', 'int'), GETPOST('datestartday', 'int'), GETPOST('datestartyear', 'int'));
72 78
 $dateend = dol_mktime(0, 0, 0, GETPOST('dateendmonth', 'int'), GETPOST('dateendday', 'int'), GETPOST('dateendyear', 'int'));
73
-if ($search_status == '' && !GETPOSTISSET('search_status')) $search_status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
74
-if (empty($action) && !GETPOSTISSET('action')) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
79
+if ($search_status == '' && !GETPOSTISSET('search_status')) {
80
+	$search_status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
81
+}
82
+if (empty($action) && !GETPOSTISSET('action')) {
83
+	$action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
84
+}
75 85
 
76 86
 $filter = GETPOST("search_filter", 'alpha', 3) ?GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3);
77 87
 $filtert = GETPOST("search_filtert", "int", 3) ?GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3);
@@ -103,27 +113,41 @@  discard block
 block discarded – undo
103 113
 if (!$sortorder)
104 114
 {
105 115
 	$sortorder = "DESC,DESC";
106
-	if ($search_status == 'todo') $sortorder = "DESC,DESC";
107
-}
116
+	if ($search_status == 'todo') {
117
+		$sortorder = "DESC,DESC";
118
+	}
119
+	}
108 120
 if (!$sortfield)
109 121
 {
110 122
 	$sortfield = "a.datep,a.id";
111
-	if ($search_status == 'todo') $sortfield = "a.datep,a.id";
112
-}
123
+	if ($search_status == 'todo') {
124
+		$sortfield = "a.datep,a.id";
125
+	}
126
+	}
113 127
 
114 128
 // Security check
115 129
 $socid = GETPOST("search_socid", 'int') ?GETPOST("search_socid", 'int') : GETPOST("socid", 'int');
116
-if ($user->socid) $socid = $user->socid;
130
+if ($user->socid) {
131
+	$socid = $user->socid;
132
+}
117 133
 $result = restrictedArea($user, 'agenda', 0, '', 'myactions');
118
-if ($socid < 0) $socid = '';
134
+if ($socid < 0) {
135
+	$socid = '';
136
+}
119 137
 
120 138
 $canedit = 1;
121
-if (!$user->rights->agenda->myactions->read) accessforbidden();
122
-if (!$user->rights->agenda->allactions->read) $canedit = 0;
123
-if (!$user->rights->agenda->allactions->read || $filter == 'mine')	// If no permission to see all, we show only affected to me
139
+if (!$user->rights->agenda->myactions->read) {
140
+	accessforbidden();
141
+}
142
+if (!$user->rights->agenda->allactions->read) {
143
+	$canedit = 0;
144
+}
145
+if (!$user->rights->agenda->allactions->read || $filter == 'mine') {
146
+	// If no permission to see all, we show only affected to me
124 147
 {
125 148
 	$filtert = $user->id;
126 149
 }
150
+}
127 151
 
128 152
 $arrayfields = array(
129 153
 	'a.id'=>array('label'=>"Ref", 'checked'=>1),
@@ -174,15 +198,19 @@  discard block
 block discarded – undo
174 198
 
175 199
 $parameters = array('id'=>$socid);
176 200
 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
177
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
201
+if ($reshook < 0) {
202
+	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
203
+}
178 204
 
179 205
 // Selection of new fields
180 206
 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
181 207
 // Purge search criteria
182
-if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
208
+if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
209
+	// All tests are required to be compatible with all browsers
183 210
 {
184 211
 	//$actioncode='';
185 212
 	$search_id = '';
213
+}
186 214
 	$search_title = '';
187 215
 	$search_note = '';
188 216
 	$datestart = '';
@@ -258,32 +286,78 @@  discard block
 block discarded – undo
258 286
 $listofextcals = array();
259 287
 
260 288
 $param = '';
261
-if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
262
-if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
289
+if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
290
+	$param .= '&contextpage='.urlencode($contextpage);
291
+}
292
+if ($limit > 0 && $limit != $conf->liste_limit) {
293
+	$param .= '&limit='.urlencode($limit);
294
+}
263 295
 if ($actioncode != '') {
264 296
 	if (is_array($actioncode)) {
265
-		foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action);
266
-	} else $param .= "&search_actioncode=".urlencode($actioncode);
267
-}
268
-if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid);
269
-if ($search_status != '' && $search_status > -1) $param .= "&search_status=".urlencode($search_status);
270
-if ($filter) $param .= "&search_filter=".urlencode($filter);
271
-if ($filtert) $param .= "&search_filtert=".urlencode($filtert);
272
-if ($socid) $param .= "&search_socid=".urlencode($socid);
273
-if ($showbirthday) $param .= "&search_showbirthday=1";
274
-if ($pid) $param .= "&search_projectid=".urlencode($pid);
275
-if ($type) $param .= "&search_type=".urlencode($type);
276
-if ($usergroup) $param .= "&search_usergroup=".urlencode($usergroup);
277
-if ($search_id != '') $param .= '&search_title='.urlencode($search_id);
278
-if ($search_title != '') $param .= '&search_title='.urlencode($search_title);
279
-if ($search_note != '') $param .= '&search_note='.$search_note;
280
-if (GETPOST('datestartday', 'int')) $param .= '&datestartday='.GETPOST('datestartday', 'int');
281
-if (GETPOST('datestartmonth', 'int')) $param .= '&datestartmonth='.GETPOST('datestartmonth', 'int');
282
-if (GETPOST('datestartyear', 'int')) $param .= '&datestartyear='.GETPOST('datestartyear', 'int');
283
-if (GETPOST('dateendday', 'int')) $param .= '&dateendday='.GETPOST('dateendday', 'int');
284
-if (GETPOST('dateendmonth', 'int')) $param .= '&dateendmonth='.GETPOST('dateendmonth', 'int');
285
-if (GETPOST('dateendyear', 'int')) $param .= '&dateendyear='.GETPOST('dateendyear', 'int');
286
-if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
297
+		foreach ($actioncode as $str_action) {
298
+			$param .= "&search_actioncode[]=".urlencode($str_action);
299
+		}
300
+	} else {
301
+		$param .= "&search_actioncode=".urlencode($actioncode);
302
+	}
303
+	}
304
+if ($resourceid > 0) {
305
+	$param .= "&search_resourceid=".urlencode($resourceid);
306
+}
307
+if ($search_status != '' && $search_status > -1) {
308
+	$param .= "&search_status=".urlencode($search_status);
309
+}
310
+if ($filter) {
311
+	$param .= "&search_filter=".urlencode($filter);
312
+}
313
+if ($filtert) {
314
+	$param .= "&search_filtert=".urlencode($filtert);
315
+}
316
+if ($socid) {
317
+	$param .= "&search_socid=".urlencode($socid);
318
+}
319
+if ($showbirthday) {
320
+	$param .= "&search_showbirthday=1";
321
+}
322
+if ($pid) {
323
+	$param .= "&search_projectid=".urlencode($pid);
324
+}
325
+if ($type) {
326
+	$param .= "&search_type=".urlencode($type);
327
+}
328
+if ($usergroup) {
329
+	$param .= "&search_usergroup=".urlencode($usergroup);
330
+}
331
+if ($search_id != '') {
332
+	$param .= '&search_title='.urlencode($search_id);
333
+}
334
+if ($search_title != '') {
335
+	$param .= '&search_title='.urlencode($search_title);
336
+}
337
+if ($search_note != '') {
338
+	$param .= '&search_note='.$search_note;
339
+}
340
+if (GETPOST('datestartday', 'int')) {
341
+	$param .= '&datestartday='.GETPOST('datestartday', 'int');
342
+}
343
+if (GETPOST('datestartmonth', 'int')) {
344
+	$param .= '&datestartmonth='.GETPOST('datestartmonth', 'int');
345
+}
346
+if (GETPOST('datestartyear', 'int')) {
347
+	$param .= '&datestartyear='.GETPOST('datestartyear', 'int');
348
+}
349
+if (GETPOST('dateendday', 'int')) {
350
+	$param .= '&dateendday='.GETPOST('dateendday', 'int');
351
+}
352
+if (GETPOST('dateendmonth', 'int')) {
353
+	$param .= '&dateendmonth='.GETPOST('dateendmonth', 'int');
354
+}
355
+if (GETPOST('dateendyear', 'int')) {
356
+	$param .= '&dateendyear='.GETPOST('dateendyear', 'int');
357
+}
358
+if ($optioncss != '') {
359
+	$param .= '&optioncss='.urlencode($optioncss);
360
+}
287 361
 // Add $param from extra fields
288 362
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
289 363
 
@@ -297,12 +371,18 @@  discard block
 block discarded – undo
297 371
 {
298 372
 	$arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
299 373
 }
300
-if ($user->rights->agenda->myactions->create) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
301
-if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array();
374
+if ($user->rights->agenda->myactions->create) {
375
+	$arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
376
+}
377
+if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) {
378
+	$arrayofmassactions = array();
379
+}
302 380
 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
303 381
 
304 382
 $sql = "SELECT";
305
-if ($usergroup > 0) $sql .= " DISTINCT";
383
+if ($usergroup > 0) {
384
+	$sql .= " DISTINCT";
385
+}
306 386
 $sql .= " s.nom as societe, s.rowid as socid, s.client, s.email as socemail,";
307 387
 $sql .= " a.id, a.code, a.label, a.note, a.datep as dp, a.datep2 as dp2, a.fulldayevent, a.location,";
308 388
 $sql .= ' a.fk_user_author,a.fk_user_action,';
@@ -313,8 +393,10 @@  discard block
 block discarded – undo
313 393
 
314 394
 // Add fields from extrafields
315 395
 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
316
-	foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
317
-}
396
+	foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
397
+		$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
398
+	}
399
+	}
318 400
 
319 401
 // Add fields from hooks
320 402
 $parameters = array();
@@ -323,15 +405,23 @@  discard block
 block discarded – undo
323 405
 
324 406
 $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
325 407
 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_extrafields as ef ON (a.id = ef.fk_object) ";
326
-if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
408
+if (!$user->rights->societe->client->voir && !$socid) {
409
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
410
+}
327 411
 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
328 412
 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
329 413
 $sql .= " ,".MAIN_DB_PREFIX."c_actioncomm as c";
330 414
 // We must filter on resource table
331
-if ($resourceid > 0) $sql .= ", ".MAIN_DB_PREFIX."element_resources as r";
415
+if ($resourceid > 0) {
416
+	$sql .= ", ".MAIN_DB_PREFIX."element_resources as r";
417
+}
332 418
 // We must filter on assignement table
333
-if ($filtert > 0 || $usergroup > 0) $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
334
-if ($usergroup > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
419
+if ($filtert > 0 || $usergroup > 0) {
420
+	$sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
421
+}
422
+if ($usergroup > 0) {
423
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
424
+}
335 425
 $sql .= " WHERE c.id = a.fk_action";
336 426
 $sql .= ' AND a.entity IN ('.getEntity('agenda').')';
337 427
 // Condition on actioncode
@@ -339,16 +429,24 @@  discard block
 block discarded – undo
339 429
 {
340 430
 	if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
341 431
 	{
342
-		if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'";
343
-		elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'";
344
-		else {
345
-			if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'";
346
-			if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'";
432
+		if ($actioncode == 'AC_NON_AUTO') {
433
+			$sql .= " AND c.type != 'systemauto'";
434
+		} elseif ($actioncode == 'AC_ALL_AUTO') {
435
+			$sql .= " AND c.type = 'systemauto'";
436
+		} else {
437
+			if ($actioncode == 'AC_OTH') {
438
+				$sql .= " AND c.type != 'systemauto'";
439
+			}
440
+			if ($actioncode == 'AC_OTH_AUTO') {
441
+				$sql .= " AND c.type = 'systemauto'";
442
+			}
347 443
 		}
348 444
 	} else {
349
-		if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'";
350
-		elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'";
351
-		else {
445
+		if ($actioncode == 'AC_NON_AUTO') {
446
+			$sql .= " AND c.type != 'systemauto'";
447
+		} elseif ($actioncode == 'AC_ALL_AUTO') {
448
+			$sql .= " AND c.type = 'systemauto'";
449
+		} else {
352 450
 			if (is_array($actioncode))
353 451
 			{
354 452
 				$sql .= " AND c.code IN ('".implode("','", $actioncode)."')";
@@ -358,35 +456,64 @@  discard block
 block discarded – undo
358 456
 		}
359 457
 	}
360 458
 }
361
-if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
362
-if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid);
363
-if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")";
364
-if ($socid > 0) $sql .= " AND s.rowid = ".$socid;
459
+if ($resourceid > 0) {
460
+	$sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
461
+}
462
+if ($pid) {
463
+	$sql .= " AND a.fk_project=".$db->escape($pid);
464
+}
465
+if (!$user->rights->societe->client->voir && !$socid) {
466
+	$sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")";
467
+}
468
+if ($socid > 0) {
469
+	$sql .= " AND s.rowid = ".$socid;
470
+}
365 471
 // We must filter on assignement table
366
-if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
367
-if ($type) $sql .= " AND c.id = ".(int) $type;
472
+if ($filtert > 0 || $usergroup > 0) {
473
+	$sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
474
+}
475
+if ($type) {
476
+	$sql .= " AND c.id = ".(int) $type;
477
+}
368 478
 if ($search_status == '0') { $sql .= " AND a.percent = 0"; }
369 479
 if ($search_status == '-1') { $sql .= " AND a.percent = -1"; }	// Not applicable
370 480
 if ($search_status == '50') { $sql .= " AND (a.percent > 0 AND a.percent < 100)"; }	// Running already started
371 481
 if ($search_status == '100') { $sql .= " AND a.percent = 100"; }
372 482
 if ($search_status == 'done') { $sql .= " AND (a.percent = 100)"; }
373 483
 if ($search_status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; }
374
-if ($search_id) $sql .= natural_search("a.id", $search_id, 1);
375
-if ($search_title) $sql .= natural_search("a.label", $search_title);
376
-if ($search_note) $sql .= natural_search('a.note', $search_note);
484
+if ($search_id) {
485
+	$sql .= natural_search("a.id", $search_id, 1);
486
+}
487
+if ($search_title) {
488
+	$sql .= natural_search("a.label", $search_title);
489
+}
490
+if ($search_note) {
491
+	$sql .= natural_search('a.note', $search_note);
492
+}
377 493
 // We must filter on assignement table
378 494
 if ($filtert > 0 || $usergroup > 0)
379 495
 {
380 496
 	$sql .= " AND (";
381
-	if ($filtert > 0) $sql .= "(ar.fk_element = ".$filtert." OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert."))"; // The OR is for backward compatibility
382
-	if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup;
497
+	if ($filtert > 0) {
498
+		$sql .= "(ar.fk_element = ".$filtert." OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert."))";
499
+	}
500
+	// The OR is for backward compatibility
501
+	if ($usergroup > 0) {
502
+		$sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup;
503
+	}
383 504
 	$sql .= ")";
384 505
 }
385 506
 
386 507
 // The second or of next test is to take event with no end date (we suppose duration is 1 hour in such case)
387
-if ($dateselect > 0) $sql .= " AND ((a.datep2 >= '".$db->idate($dateselect)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."') OR (a.datep2 IS NULL AND a.datep > '".$db->idate($dateselect - 3600)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."'))";
388
-if ($datestart > 0) $sql .= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart + 3600 * 24 - 1)."'";
389
-if ($dateend > 0) $sql .= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend + 3600 * 24 - 1)."'";
508
+if ($dateselect > 0) {
509
+	$sql .= " AND ((a.datep2 >= '".$db->idate($dateselect)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."') OR (a.datep2 IS NULL AND a.datep > '".$db->idate($dateselect - 3600)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."'))";
510
+}
511
+if ($datestart > 0) {
512
+	$sql .= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart + 3600 * 24 - 1)."'";
513
+}
514
+if ($dateend > 0) {
515
+	$sql .= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend + 3600 * 24 - 1)."'";
516
+}
390 517
 
391 518
 // Add where from extra fields
392 519
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
@@ -403,9 +530,11 @@  discard block
 block discarded – undo
403 530
 {
404 531
 	$result = $db->query($sql);
405 532
 	$nbtotalofrecords = $db->num_rows($result);
406
-	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
533
+	if (($page * $limit) > $nbtotalofrecords) {
534
+		// if total resultset is smaller then paging size (filtering), goto and load page 0
407 535
 	{
408 536
 		$page = 0;
537
+	}
409 538
 		$offset = 0;
410 539
 	}
411 540
 }
@@ -436,7 +565,9 @@  discard block
 block discarded – undo
436 565
 
437 566
 	print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n";
438 567
 
439
-	if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
568
+	if ($optioncss != '') {
569
+		print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
570
+	}
440 571
 	print '<input type="hidden" name="token" value="'.newToken().'">';
441 572
 	print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
442 573
 	print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
@@ -444,8 +575,12 @@  discard block
 block discarded – undo
444 575
 	print '<input type="hidden" name="type" value="'.$type.'">';
445 576
 	$nav = '';
446 577
 
447
-	if ($filter)          $nav .= '<input type="hidden" name="search_filter" value="'.$filter.'">';
448
-	if ($showbirthday)    $nav .= '<input type="hidden" name="search_showbirthday" value="1">';
578
+	if ($filter) {
579
+		$nav .= '<input type="hidden" name="search_filter" value="'.$filter.'">';
580
+	}
581
+	if ($showbirthday) {
582
+		$nav .= '<input type="hidden" name="search_showbirthday" value="1">';
583
+	}
449 584
 	print $nav;
450 585
 
451 586
 	//print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
@@ -541,7 +676,9 @@  discard block
 block discarded – undo
541 676
 
542 677
 	$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
543 678
 	$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
544
-	if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
679
+	if ($massactionbutton) {
680
+		$selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
681
+	}
545 682
 	$i = 0;
546 683
 
547 684
 	print '<div class="liste_titre liste_titre_bydiv centpercent">';
@@ -552,11 +689,21 @@  discard block
 block discarded – undo
552 689
 	print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
553 690
 
554 691
 	print '<tr class="liste_titre_filter">';
555
-	if (!empty($arrayfields['a.id']['checked']))		print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>';
556
-	if (!empty($arrayfields['owner']['checked']))		print '<td class="liste_titre"></td>';
557
-	if (!empty($arrayfields['c.libelle']['checked']))	print '<td class="liste_titre"></td>';
558
-	if (!empty($arrayfields['a.label']['checked']))	print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>';
559
-	if (!empty($arrayfields['a.note']['checked']))	print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_note" value="'.$search_note.'"></td>';
692
+	if (!empty($arrayfields['a.id']['checked'])) {
693
+		print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>';
694
+	}
695
+	if (!empty($arrayfields['owner']['checked'])) {
696
+		print '<td class="liste_titre"></td>';
697
+	}
698
+	if (!empty($arrayfields['c.libelle']['checked'])) {
699
+		print '<td class="liste_titre"></td>';
700
+	}
701
+	if (!empty($arrayfields['a.label']['checked'])) {
702
+		print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>';
703
+	}
704
+	if (!empty($arrayfields['a.note']['checked'])) {
705
+		print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_note" value="'.$search_note.'"></td>';
706
+	}
560 707
 	if (!empty($arrayfields['a.datep']['checked'])) {
561 708
 		print '<td class="liste_titre nowraponall" align="center">';
562 709
 		print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0);
@@ -570,8 +717,12 @@  discard block
 block discarded – undo
570 717
 	if (!empty($arrayfields['s.nom']['checked'])) {
571 718
 		print '<td class="liste_titre"></td>';
572 719
 	}
573
-	if (!empty($arrayfields['a.fk_contact']['checked']))	print '<td class="liste_titre"></td>';
574
-	if (!empty($arrayfields['a.fk_element']['checked']))	print '<td class="liste_titre"></td>';
720
+	if (!empty($arrayfields['a.fk_contact']['checked'])) {
721
+		print '<td class="liste_titre"></td>';
722
+	}
723
+	if (!empty($arrayfields['a.fk_element']['checked'])) {
724
+		print '<td class="liste_titre"></td>';
725
+	}
575 726
 
576 727
 	// Extra fields
577 728
 	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
@@ -581,8 +732,12 @@  discard block
 block discarded – undo
581 732
 	$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
582 733
 	print $hookmanager->resPrint;
583 734
 
584
-	if (!empty($arrayfields['a.datec']['checked']))	print '<td class="liste_titre"></td>';
585
-	if (!empty($arrayfields['a.tms']['checked']))		print '<td class="liste_titre"></td>';
735
+	if (!empty($arrayfields['a.datec']['checked'])) {
736
+		print '<td class="liste_titre"></td>';
737
+	}
738
+	if (!empty($arrayfields['a.tms']['checked'])) {
739
+		print '<td class="liste_titre"></td>';
740
+	}
586 741
 	if (!empty($arrayfields['a.percent']['checked'])) {
587 742
 		print '<td class="liste_titre center">';
588 743
 		$formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'minwidth100imp maxwidth125');
@@ -597,17 +752,37 @@  discard block
 block discarded – undo
597 752
 	print "</tr>\n";
598 753
 
599 754
 	print '<tr class="liste_titre">';
600
-	if (!empty($arrayfields['a.id']['checked']))	      print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder);
601
-	if (!empty($arrayfields['owner']['checked']))        print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
602
-	if (!empty($arrayfields['c.libelle']['checked']))	  print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder);
603
-	if (!empty($arrayfields['a.label']['checked']))	  print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder);
604
-	if (!empty($arrayfields['a.note']['checked']))		  print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder);
755
+	if (!empty($arrayfields['a.id']['checked'])) {
756
+		print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder);
757
+	}
758
+	if (!empty($arrayfields['owner']['checked'])) {
759
+		print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
760
+	}
761
+	if (!empty($arrayfields['c.libelle']['checked'])) {
762
+		print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder);
763
+	}
764
+	if (!empty($arrayfields['a.label']['checked'])) {
765
+		print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder);
766
+	}
767
+	if (!empty($arrayfields['a.note']['checked'])) {
768
+		print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder);
769
+	}
605 770
 	//if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
606
-	if (!empty($arrayfields['a.datep']['checked']))	  print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder);
607
-	if (!empty($arrayfields['a.datep2']['checked']))	  print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder);
608
-	if (!empty($arrayfields['s.nom']['checked']))	      print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder);
609
-	if (!empty($arrayfields['a.fk_contact']['checked'])) print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
610
-	if (!empty($arrayfields['a.fk_element']['checked'])) print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
771
+	if (!empty($arrayfields['a.datep']['checked'])) {
772
+		print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder);
773
+	}
774
+	if (!empty($arrayfields['a.datep2']['checked'])) {
775
+		print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder);
776
+	}
777
+	if (!empty($arrayfields['s.nom']['checked'])) {
778
+		print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder);
779
+	}
780
+	if (!empty($arrayfields['a.fk_contact']['checked'])) {
781
+		print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
782
+	}
783
+	if (!empty($arrayfields['a.fk_element']['checked'])) {
784
+		print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
785
+	}
611 786
 
612 787
 	// Extra fields
613 788
 	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
@@ -617,10 +792,16 @@  discard block
 block discarded – undo
617 792
 	$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
618 793
 	print $hookmanager->resPrint;
619 794
 
620
-	if (!empty($arrayfields['a.datec']['checked'])) print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
621
-	if (!empty($arrayfields['a.tms']['checked'])) print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
795
+	if (!empty($arrayfields['a.datec']['checked'])) {
796
+		print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
797
+	}
798
+	if (!empty($arrayfields['a.tms']['checked'])) {
799
+		print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
800
+	}
622 801
 
623
-	if (!empty($arrayfields['a.percent']['checked']))print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder);
802
+	if (!empty($arrayfields['a.percent']['checked'])) {
803
+		print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder);
804
+	}
624 805
 	print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
625 806
 	print "</tr>\n";
626 807
 
@@ -673,7 +854,9 @@  discard block
 block discarded – undo
673 854
 			{
674 855
 				$userstatic->fetch($obj->fk_user_action);
675 856
 				print $userstatic->getNomUrl(-1);
676
-			} else print '&nbsp;';
857
+			} else {
858
+				print '&nbsp;';
859
+			}
677 860
 			print '</td>';
678 861
 		}
679 862
 
@@ -689,24 +872,39 @@  discard block
 block discarded – undo
689 872
 				if ($actioncomm->type_picto) {
690 873
 					$imgpicto = img_picto('', $actioncomm->type_picto);
691 874
 				} else {
692
-					if ($actioncomm->type_code == 'AC_RDV')         $imgpicto = img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' ';
693
-					elseif ($actioncomm->type_code == 'AC_TEL')     $imgpicto = img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' ';
694
-					elseif ($actioncomm->type_code == 'AC_FAX')     $imgpicto = img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' ';
695
-					elseif ($actioncomm->type_code == 'AC_EMAIL' || $actioncomm->type_code == 'AC_EMAIL_IN')   $imgpicto = img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' ';
696
-					elseif ($actioncomm->type_code == 'AC_INT')     $imgpicto = img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' ';
697
-					elseif ($actioncomm->type_code == 'AC_OTH' && $actioncomm->code == 'TICKET_MSG') $imgpicto = img_picto('', 'object_conversation', '', false, 0, 0, '', 'paddingright').' ';
698
-					elseif (!preg_match('/_AUTO/', $actioncomm->type_code)) $imgpicto = img_picto('', 'object_other', '', false, 0, 0, '', 'paddingright').' ';
875
+					if ($actioncomm->type_code == 'AC_RDV') {
876
+						$imgpicto = img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' ';
877
+					} elseif ($actioncomm->type_code == 'AC_TEL') {
878
+						$imgpicto = img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' ';
879
+					} elseif ($actioncomm->type_code == 'AC_FAX') {
880
+						$imgpicto = img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' ';
881
+					} elseif ($actioncomm->type_code == 'AC_EMAIL' || $actioncomm->type_code == 'AC_EMAIL_IN') {
882
+						$imgpicto = img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' ';
883
+					} elseif ($actioncomm->type_code == 'AC_INT') {
884
+						$imgpicto = img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' ';
885
+					} elseif ($actioncomm->type_code == 'AC_OTH' && $actioncomm->code == 'TICKET_MSG') {
886
+						$imgpicto = img_picto('', 'object_conversation', '', false, 0, 0, '', 'paddingright').' ';
887
+					} elseif (!preg_match('/_AUTO/', $actioncomm->type_code)) {
888
+						$imgpicto = img_picto('', 'object_other', '', false, 0, 0, '', 'paddingright').' ';
889
+					}
699 890
 				}
700 891
 			}
701 892
 			print $imgpicto;
702 893
 
703 894
 			$labeltype = $obj->type_code;
704
-			if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) $labeltype = 'AC_OTH';
895
+			if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) {
896
+				$labeltype = 'AC_OTH';
897
+			}
705 898
 			if ($actioncomm->type_code == 'AC_OTH' && $actioncomm->code == 'TICKET_MSG') {
706 899
 				$labeltype = $langs->trans("Message");
707 900
 			} else {
708
-				if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype];
709
-				if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) $labeltype .= ' - '.$arraylist[$obj->code]; // Use code in priority on type_code
901
+				if (!empty($arraylist[$labeltype])) {
902
+					$labeltype = $arraylist[$labeltype];
903
+				}
904
+				if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) {
905
+					$labeltype .= ' - '.$arraylist[$obj->code];
906
+				}
907
+				// Use code in priority on type_code
710 908
 			}
711 909
 			print dol_trunc($labeltype, 28);
712 910
 			print '</td>';
@@ -734,11 +932,21 @@  discard block
 block discarded – undo
734 932
 			print '<td class="center nowraponall">';
735 933
 			print dol_print_date($db->jdate($obj->dp), $formatToUse);
736 934
 			$late = 0;
737
-			if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1;
738
-			if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1;
739
-			if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) $late = 1;
740
-			if ($obj->percent > 0 && $obj->percent < 100 && !$obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) $late = 1;
741
-			if ($late) print img_warning($langs->trans("Late")).' ';
935
+			if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) {
936
+				$late = 1;
937
+			}
938
+			if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) {
939
+				$late = 1;
940
+			}
941
+			if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) {
942
+				$late = 1;
943
+			}
944
+			if ($obj->percent > 0 && $obj->percent < 100 && !$obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) {
945
+				$late = 1;
946
+			}
947
+			if ($late) {
948
+				print img_warning($langs->trans("Late")).' ';
949
+			}
742 950
 			print '</td>';
743 951
 		}
744 952
 
@@ -760,7 +968,9 @@  discard block
 block discarded – undo
760 968
 				$societestatic->email = $obj->socemail;
761 969
 
762 970
 				print $societestatic->getNomUrl(1, '', 28);
763
-			} else print '&nbsp;';
971
+			} else {
972
+				print '&nbsp;';
973
+			}
764 974
 			print '</td>';
765 975
 		}
766 976
 
@@ -790,9 +1000,11 @@  discard block
 block discarded – undo
790 1000
 				if (!empty($contactList)) {
791 1001
 					print implode(', ', $contactList);
792 1002
 				}
793
-			} elseif ($obj->fk_contact > 0) //keep for retrocompatibility with faraway event
1003
+			} elseif ($obj->fk_contact > 0) {
1004
+				//keep for retrocompatibility with faraway event
794 1005
 			{
795 1006
 				$contactstatic->id = $obj->fk_contact;
1007
+			}
796 1008
 				$contactstatic->email = $obj->email;
797 1009
 				$contactstatic->lastname = $obj->lastname;
798 1010
 				$contactstatic->firstname = $obj->firstname;
@@ -843,10 +1055,14 @@  discard block
 block discarded – undo
843 1055
 		}
844 1056
 		// Action column
845 1057
 		print '<td class="nowrap center">';
846
-		if ($massactionbutton || $massaction)   // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1058
+		if ($massactionbutton || $massaction) {
1059
+			// If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
847 1060
 		{
848 1061
 			$selected = 0;
849
-			if (in_array($obj->id, $arrayofselected)) $selected = 1;
1062
+		}
1063
+			if (in_array($obj->id, $arrayofselected)) {
1064
+				$selected = 1;
1065
+			}
850 1066
 			print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
851 1067
 		}
852 1068
 		print '</td>';
Please login to merge, or discard this patch.
htdocs/user/list.php 1 patch
Braces   +302 added lines, -101 removed lines patch added patch discarded remove patch
@@ -78,16 +78,22 @@  discard block
 block discarded – undo
78 78
 
79 79
 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
80 80
 
81
-if (!$sortfield) $sortfield = "u.login";
82
-if (!$sortorder) $sortorder = "ASC";
81
+if (!$sortfield) {
82
+	$sortfield = "u.login";
83
+}
84
+if (!$sortorder) {
85
+	$sortorder = "ASC";
86
+}
83 87
 
84 88
 // Initialize array of search criterias
85 89
 $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
86 90
 $search = array();
87 91
 foreach ($object->fields as $key => $val)
88 92
 {
89
-	if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha');
90
-}
93
+	if (GETPOST('search_'.$key, 'alpha') !== '') {
94
+		$search[$key] = GETPOST('search_'.$key, 'alpha');
95
+	}
96
+	}
91 97
 
92 98
 $userstatic = new User($db);
93 99
 $companystatic = new Societe($db);
@@ -152,8 +158,12 @@  discard block
 block discarded – undo
152 158
 $catid = GETPOST('catid', 'int');
153 159
 
154 160
 // Default search
155
-if ($search_statut == '') $search_statut = '1';
156
-if ($mode == 'employee' && !GETPOSTISSET('search_employee')) $search_employee = 1;
161
+if ($search_statut == '') {
162
+	$search_statut = '1';
163
+}
164
+if ($mode == 'employee' && !GETPOSTISSET('search_employee')) {
165
+	$search_employee = 1;
166
+}
157 167
 
158 168
 // Define value to know what current user can do on users
159 169
 $permissiontoadd = (!empty($user->admin) || $user->rights->user->user->creer);
@@ -182,7 +192,9 @@  discard block
 block discarded – undo
182 192
 
183 193
 $parameters = array();
184 194
 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
185
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
195
+if ($reshook < 0) {
196
+	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
197
+}
186 198
 
187 199
 if (empty($reshook))
188 200
 {
@@ -190,9 +202,11 @@  discard block
 block discarded – undo
190 202
 	include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
191 203
 
192 204
 	// Purge search criteria
193
-	if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
205
+	if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
206
+		// All tests are required to be compatible with all browsers
194 207
 	{
195 208
 		$search_user = "";
209
+	}
196 210
 		$search_login = "";
197 211
 		$search_lastname = "";
198 212
 		$search_firstname = "";
@@ -251,7 +265,9 @@  discard block
 block discarded – undo
251 265
 						setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
252 266
 						$error++;
253 267
 						break;
254
-					} else $nbok++;
268
+					} else {
269
+						$nbok++;
270
+					}
255 271
 				} else {
256 272
 					setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
257 273
 					$error++;
@@ -269,8 +285,11 @@  discard block
 block discarded – undo
269 285
 
270 286
 			if (!$error)
271 287
 			{
272
-				if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
273
-				else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
288
+				if ($nbok > 1) {
289
+					setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
290
+				} else {
291
+					setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
292
+				}
274 293
 				$db->commit();
275 294
 			} else {
276 295
 				$db->rollback();
@@ -304,8 +323,10 @@  discard block
 block discarded – undo
304 323
 $sql .= " s.nom as name, s.canvas";
305 324
 // Add fields from extrafields
306 325
 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
307
-	foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
308
-}
326
+	foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
327
+		$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
328
+	}
329
+	}
309 330
 // Add fields from hooks
310 331
 $parameters = array();
311 332
 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
@@ -313,10 +334,15 @@  discard block
 block discarded – undo
313 334
 $sql = preg_replace('/,\s*$/', '', $sql);
314 335
 $sql .= $hookmanager->resPrint;
315 336
 $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
316
-if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (u.rowid = ef.fk_object)";
337
+if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
338
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (u.rowid = ef.fk_object)";
339
+}
317 340
 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid";
318 341
 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u2 ON u.fk_user = u2.rowid";
319
-if (!empty($search_categ) || !empty($catid)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_user as cu ON u.rowid = cu.fk_user"; // We'll need this table joined to the select in order to filter by categ
342
+if (!empty($search_categ) || !empty($catid)) {
343
+	$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_user as cu ON u.rowid = cu.fk_user";
344
+}
345
+// We'll need this table joined to the select in order to filter by categ
320 346
 // Add fields from hooks
321 347
 $parameters = array();
322 348
 $reshook = $hookmanager->executeHooks('printUserListWhere', $parameters); // Note that $action and $object may have been modified by hook
@@ -325,27 +351,62 @@  discard block
 block discarded – undo
325 351
 } else {
326 352
 	$sql .= " WHERE u.entity IN (".getEntity('user').")";
327 353
 }
328
-if ($socid > 0) $sql .= " AND u.fk_soc = ".$socid;
354
+if ($socid > 0) {
355
+	$sql .= " AND u.fk_soc = ".$socid;
356
+}
329 357
 //if ($search_user != '')       $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname'), $search_user);
330
-if ($search_supervisor > 0)   $sql .= " AND u.fk_user IN (".$db->sanitize($db->escape($search_supervisor)).")";
331
-if ($search_thirdparty != '') $sql .= natural_search(array('s.nom'), $search_thirdparty);
332
-if ($search_login != '')      $sql .= natural_search("u.login", $search_login);
333
-if ($search_lastname != '')   $sql .= natural_search("u.lastname", $search_lastname);
334
-if ($search_firstname != '')  $sql .= natural_search("u.firstname", $search_firstname);
335
-if ($search_gender != '' && $search_gender != '-1')     $sql .= " AND u.gender = '".$db->escape($search_gender)."'"; // Cannot use natural_search as looking for %man% also includes woman
358
+if ($search_supervisor > 0) {
359
+	$sql .= " AND u.fk_user IN (".$db->sanitize($db->escape($search_supervisor)).")";
360
+}
361
+if ($search_thirdparty != '') {
362
+	$sql .= natural_search(array('s.nom'), $search_thirdparty);
363
+}
364
+if ($search_login != '') {
365
+	$sql .= natural_search("u.login", $search_login);
366
+}
367
+if ($search_lastname != '') {
368
+	$sql .= natural_search("u.lastname", $search_lastname);
369
+}
370
+if ($search_firstname != '') {
371
+	$sql .= natural_search("u.firstname", $search_firstname);
372
+}
373
+if ($search_gender != '' && $search_gender != '-1') {
374
+	$sql .= " AND u.gender = '".$db->escape($search_gender)."'";
375
+}
376
+// Cannot use natural_search as looking for %man% also includes woman
336 377
 if (is_numeric($search_employee) && $search_employee >= 0) {
337 378
 	$sql .= ' AND u.employee = '.(int) $search_employee;
338 379
 }
339
-if ($search_accountancy_code != '')  $sql .= natural_search("u.accountancy_code", $search_accountancy_code);
340
-if ($search_email != '')             $sql .= natural_search("u.email", $search_email);
341
-if ($search_api_key != '')           $sql .= natural_search("u.api_key", $search_api_key);
342
-if ($search_statut != '' && $search_statut >= 0) $sql .= " AND u.statut IN (".$db->sanitize($db->escape($search_statut)).")";
343
-if ($sall)                           $sql .= natural_search(array_keys($fieldstosearchall), $sall);
344
-if ($catid > 0)     $sql .= " AND cu.fk_categorie = ".((int) $catid);
345
-if ($catid == -2)   $sql .= " AND cu.fk_categorie IS NULL";
346
-if ($search_categ > 0)   $sql .= " AND cu.fk_categorie = ".$db->escape($search_categ);
347
-if ($search_categ == -2) $sql .= " AND cu.fk_categorie IS NULL";
348
-if ($mode == 'employee' && empty($user->rights->salaries->readall)) $sql .= " AND s.fk_user IN (".join(',', $childids).")";
380
+if ($search_accountancy_code != '') {
381
+	$sql .= natural_search("u.accountancy_code", $search_accountancy_code);
382
+}
383
+if ($search_email != '') {
384
+	$sql .= natural_search("u.email", $search_email);
385
+}
386
+if ($search_api_key != '') {
387
+	$sql .= natural_search("u.api_key", $search_api_key);
388
+}
389
+if ($search_statut != '' && $search_statut >= 0) {
390
+	$sql .= " AND u.statut IN (".$db->sanitize($db->escape($search_statut)).")";
391
+}
392
+if ($sall) {
393
+	$sql .= natural_search(array_keys($fieldstosearchall), $sall);
394
+}
395
+if ($catid > 0) {
396
+	$sql .= " AND cu.fk_categorie = ".((int) $catid);
397
+}
398
+if ($catid == -2) {
399
+	$sql .= " AND cu.fk_categorie IS NULL";
400
+}
401
+if ($search_categ > 0) {
402
+	$sql .= " AND cu.fk_categorie = ".$db->escape($search_categ);
403
+}
404
+if ($search_categ == -2) {
405
+	$sql .= " AND cu.fk_categorie IS NULL";
406
+}
407
+if ($mode == 'employee' && empty($user->rights->salaries->readall)) {
408
+	$sql .= " AND s.fk_user IN (".join(',', $childids).")";
409
+}
349 410
 // Add where from extra fields
350 411
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
351 412
 // Add where from hooks
@@ -360,9 +421,11 @@  discard block
 block discarded – undo
360 421
 {
361 422
 	$resql = $db->query($sql);
362 423
 	$nbtotalofrecords = $db->num_rows($resql);
363
-	if (($page * $limit) > $nbtotalofrecords)	// if total of record found is smaller than page * limit, goto and load page 0
424
+	if (($page * $limit) > $nbtotalofrecords) {
425
+		// if total of record found is smaller than page * limit, goto and load page 0
364 426
 	{
365 427
 		$page = 0;
428
+	}
366 429
 		$offset = 0;
367 430
 	}
368 431
 }
@@ -371,7 +434,9 @@  discard block
 block discarded – undo
371 434
 {
372 435
 	$num = $nbtotalofrecords;
373 436
 } else {
374
-	if ($limit) $sql .= $db->plimit($limit + 1, $offset);
437
+	if ($limit) {
438
+		$sql .= $db->plimit($limit + 1, $offset);
439
+	}
375 440
 
376 441
 	$resql = $db->query($sql);
377 442
 	if (!$resql)
@@ -398,38 +463,82 @@  discard block
 block discarded – undo
398 463
 llxHeader('', $langs->trans("ListOfUsers"), $help_url);
399 464
 
400 465
 $param = '';
401
-if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&amp;contextpage='.urlencode($contextpage);
402
-if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&amp;limit='.urlencode($limit);
403
-if ($sall != '') $param .= '&amp;sall='.urlencode($sall);
404
-if ($search_user != '') $param .= "&amp;search_user=".urlencode($search_user);
405
-if ($search_login != '') $param .= "&amp;search_login=".urlencode($search_login);
406
-if ($search_lastname != '') $param .= "&amp;search_lastname=".urlencode($search_lastname);
407
-if ($search_firstname != '') $param .= "&amp;search_firstname=".urlencode($search_firstname);
408
-if ($search_gender != '') $param .= "&amp;search_gender=".urlencode($search_gender);
409
-if ($search_employee != '') $param .= "&amp;search_employee=".urlencode($search_employee);
410
-if ($search_accountancy_code != '') $param .= "&amp;search_accountancy_code=".urlencode($search_accountancy_code);
411
-if ($search_email != '') $param .= "&amp;search_email=".urlencode($search_email);
412
-if ($search_api_key != '') $param .= "&amp;search_api_key=".urlencode($search_api_key);
413
-if ($search_supervisor > 0) $param .= "&amp;search_supervisor=".urlencode($search_supervisor);
414
-if ($search_statut != '') $param .= "&amp;search_statut=".urlencode($search_statut);
415
-if ($optioncss != '') $param .= '&amp;optioncss='.urlencode($optioncss);
416
-if ($mode != '')      $param .= '&amp;mode='.urlencode($mode);
417
-if ($search_categ > 0) $param .= "&amp;search_categ=".urlencode($search_categ);
466
+if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
467
+	$param .= '&amp;contextpage='.urlencode($contextpage);
468
+}
469
+if ($limit > 0 && $limit != $conf->liste_limit) {
470
+	$param .= '&amp;limit='.urlencode($limit);
471
+}
472
+if ($sall != '') {
473
+	$param .= '&amp;sall='.urlencode($sall);
474
+}
475
+if ($search_user != '') {
476
+	$param .= "&amp;search_user=".urlencode($search_user);
477
+}
478
+if ($search_login != '') {
479
+	$param .= "&amp;search_login=".urlencode($search_login);
480
+}
481
+if ($search_lastname != '') {
482
+	$param .= "&amp;search_lastname=".urlencode($search_lastname);
483
+}
484
+if ($search_firstname != '') {
485
+	$param .= "&amp;search_firstname=".urlencode($search_firstname);
486
+}
487
+if ($search_gender != '') {
488
+	$param .= "&amp;search_gender=".urlencode($search_gender);
489
+}
490
+if ($search_employee != '') {
491
+	$param .= "&amp;search_employee=".urlencode($search_employee);
492
+}
493
+if ($search_accountancy_code != '') {
494
+	$param .= "&amp;search_accountancy_code=".urlencode($search_accountancy_code);
495
+}
496
+if ($search_email != '') {
497
+	$param .= "&amp;search_email=".urlencode($search_email);
498
+}
499
+if ($search_api_key != '') {
500
+	$param .= "&amp;search_api_key=".urlencode($search_api_key);
501
+}
502
+if ($search_supervisor > 0) {
503
+	$param .= "&amp;search_supervisor=".urlencode($search_supervisor);
504
+}
505
+if ($search_statut != '') {
506
+	$param .= "&amp;search_statut=".urlencode($search_statut);
507
+}
508
+if ($optioncss != '') {
509
+	$param .= '&amp;optioncss='.urlencode($optioncss);
510
+}
511
+if ($mode != '') {
512
+	$param .= '&amp;mode='.urlencode($mode);
513
+}
514
+if ($search_categ > 0) {
515
+	$param .= "&amp;search_categ=".urlencode($search_categ);
516
+}
418 517
 // Add $param from extra fields
419 518
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
420 519
 
421 520
 // List of mass actions available
422 521
 $arrayofmassactions = array();
423
-if ($permissiontoadd) $arrayofmassactions['disable'] = $langs->trans("DisableUser");
424
-if ($permissiontoadd) $arrayofmassactions['reactivate'] = $langs->trans("Reactivate");
425
-if ($permissiontoadd) $arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
522
+if ($permissiontoadd) {
523
+	$arrayofmassactions['disable'] = $langs->trans("DisableUser");
524
+}
525
+if ($permissiontoadd) {
526
+	$arrayofmassactions['reactivate'] = $langs->trans("Reactivate");
527
+}
528
+if ($permissiontoadd) {
529
+	$arrayofmassactions['preaffecttag'] = '<span class="fa fa-tag paddingrightonly"></span>'.$langs->trans("AffectTag");
530
+}
426 531
 //if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
427 532
 
428
-if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) $arrayofmassactions = array();
533
+if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) {
534
+	$arrayofmassactions = array();
535
+}
429 536
 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
430 537
 
431 538
 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
432
-if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
539
+if ($optioncss != '') {
540
+	print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
541
+}
433 542
 print '<input type="hidden" name="token" value="'.newToken().'">';
434 543
 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
435 544
 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
@@ -438,7 +547,9 @@  discard block
 block discarded – undo
438 547
 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
439 548
 
440 549
 $url = DOL_URL_ROOT.'/user/card.php?action=create'.($mode == 'employee' ? '&employee=1' : '').'&leftmenu=';
441
-if (!empty($socid)) $url .= '&socid='.$socid;
550
+if (!empty($socid)) {
551
+	$url .= '&socid='.$socid;
552
+}
442 553
 
443 554
 $newcardbutton = dolGetButtonTitle($langs->trans('NewUser'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd);
444 555
 
@@ -467,7 +578,9 @@  discard block
 block discarded – undo
467 578
 
468 579
 if ($search_all)
469 580
 {
470
-	foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
581
+	foreach ($fieldstosearchall as $key => $val) {
582
+		$fieldstosearchall[$key] = $langs->trans($val);
583
+	}
471 584
 	print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
472 585
 }
473 586
 
@@ -487,8 +600,11 @@  discard block
 block discarded – undo
487 600
 
488 601
 $parameters = array();
489 602
 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
490
-if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
491
-else $moreforfilter = $hookmanager->resPrint;
603
+if (empty($reshook)) {
604
+	$moreforfilter .= $hookmanager->resPrint;
605
+} else {
606
+	$moreforfilter = $hookmanager->resPrint;
607
+}
492 608
 
493 609
 if (!empty($moreforfilter))
494 610
 {
@@ -605,29 +721,63 @@  discard block
 block discarded – undo
605 721
 
606 722
 
607 723
 print '<tr class="liste_titre">';
608
-if (!empty($arrayfields['u.login']['checked']))          print_liste_field_titre("Login", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
609
-if (!empty($arrayfields['u.lastname']['checked']))       print_liste_field_titre("Lastname", $_SERVER['PHP_SELF'], "u.lastname", $param, "", "", $sortfield, $sortorder);
610
-if (!empty($arrayfields['u.firstname']['checked']))      print_liste_field_titre("FirstName", $_SERVER['PHP_SELF'], "u.firstname", $param, "", "", $sortfield, $sortorder);
611
-if (!empty($arrayfields['u.gender']['checked']))         print_liste_field_titre("Gender", $_SERVER['PHP_SELF'], "u.gender", $param, "", "", $sortfield, $sortorder);
612
-if (!empty($arrayfields['u.employee']['checked']))       print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.employee", $param, "", "", $sortfield, $sortorder);
613
-if (!empty($arrayfields['u.fk_user']['checked']))        print_liste_field_titre("HierarchicalResponsible", $_SERVER['PHP_SELF'], "u.fk_user", $param, "", "", $sortfield, $sortorder);
614
-if (!empty($arrayfields['u.accountancy_code']['checked'])) print_liste_field_titre("AccountancyCode", $_SERVER['PHP_SELF'], "u.accountancy_code", $param, "", "", $sortfield, $sortorder);
615
-if (!empty($arrayfields['u.email']['checked']))          print_liste_field_titre("EMail", $_SERVER['PHP_SELF'], "u.email", $param, "", "", $sortfield, $sortorder);
616
-if (!empty($arrayfields['u.api_key']['checked']))        print_liste_field_titre("ApiKey", $_SERVER['PHP_SELF'], "u.api_key", $param, "", "", $sortfield, $sortorder);
617
-if (!empty($arrayfields['u.fk_soc']['checked']))         print_liste_field_titre("Company", $_SERVER['PHP_SELF'], "u.fk_soc", $param, "", "", $sortfield, $sortorder);
618
-if (!empty($arrayfields['u.entity']['checked']))         print_liste_field_titre("Entity", $_SERVER['PHP_SELF'], "u.entity", $param, "", "", $sortfield, $sortorder);
619
-if (!empty($arrayfields['u.salary']['checked']))         print_liste_field_titre("Salary", $_SERVER['PHP_SELF'], "u.salary", $param, "", "", $sortfield, $sortorder, 'right ');
620
-if (!empty($arrayfields['u.datelastlogin']['checked']))  print_liste_field_titre("LastConnexion", $_SERVER['PHP_SELF'], "u.datelastlogin", $param, "", '', $sortfield, $sortorder, 'center ');
621
-if (!empty($arrayfields['u.datepreviouslogin']['checked'])) print_liste_field_titre("PreviousConnexion", $_SERVER['PHP_SELF'], "u.datepreviouslogin", $param, "", '', $sortfield, $sortorder, 'center ');
724
+if (!empty($arrayfields['u.login']['checked'])) {
725
+	print_liste_field_titre("Login", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
726
+}
727
+if (!empty($arrayfields['u.lastname']['checked'])) {
728
+	print_liste_field_titre("Lastname", $_SERVER['PHP_SELF'], "u.lastname", $param, "", "", $sortfield, $sortorder);
729
+}
730
+if (!empty($arrayfields['u.firstname']['checked'])) {
731
+	print_liste_field_titre("FirstName", $_SERVER['PHP_SELF'], "u.firstname", $param, "", "", $sortfield, $sortorder);
732
+}
733
+if (!empty($arrayfields['u.gender']['checked'])) {
734
+	print_liste_field_titre("Gender", $_SERVER['PHP_SELF'], "u.gender", $param, "", "", $sortfield, $sortorder);
735
+}
736
+if (!empty($arrayfields['u.employee']['checked'])) {
737
+	print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.employee", $param, "", "", $sortfield, $sortorder);
738
+}
739
+if (!empty($arrayfields['u.fk_user']['checked'])) {
740
+	print_liste_field_titre("HierarchicalResponsible", $_SERVER['PHP_SELF'], "u.fk_user", $param, "", "", $sortfield, $sortorder);
741
+}
742
+if (!empty($arrayfields['u.accountancy_code']['checked'])) {
743
+	print_liste_field_titre("AccountancyCode", $_SERVER['PHP_SELF'], "u.accountancy_code", $param, "", "", $sortfield, $sortorder);
744
+}
745
+if (!empty($arrayfields['u.email']['checked'])) {
746
+	print_liste_field_titre("EMail", $_SERVER['PHP_SELF'], "u.email", $param, "", "", $sortfield, $sortorder);
747
+}
748
+if (!empty($arrayfields['u.api_key']['checked'])) {
749
+	print_liste_field_titre("ApiKey", $_SERVER['PHP_SELF'], "u.api_key", $param, "", "", $sortfield, $sortorder);
750
+}
751
+if (!empty($arrayfields['u.fk_soc']['checked'])) {
752
+	print_liste_field_titre("Company", $_SERVER['PHP_SELF'], "u.fk_soc", $param, "", "", $sortfield, $sortorder);
753
+}
754
+if (!empty($arrayfields['u.entity']['checked'])) {
755
+	print_liste_field_titre("Entity", $_SERVER['PHP_SELF'], "u.entity", $param, "", "", $sortfield, $sortorder);
756
+}
757
+if (!empty($arrayfields['u.salary']['checked'])) {
758
+	print_liste_field_titre("Salary", $_SERVER['PHP_SELF'], "u.salary", $param, "", "", $sortfield, $sortorder, 'right ');
759
+}
760
+if (!empty($arrayfields['u.datelastlogin']['checked'])) {
761
+	print_liste_field_titre("LastConnexion", $_SERVER['PHP_SELF'], "u.datelastlogin", $param, "", '', $sortfield, $sortorder, 'center ');
762
+}
763
+if (!empty($arrayfields['u.datepreviouslogin']['checked'])) {
764
+	print_liste_field_titre("PreviousConnexion", $_SERVER['PHP_SELF'], "u.datepreviouslogin", $param, "", '', $sortfield, $sortorder, 'center ');
765
+}
622 766
 // Extra fields
623 767
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
624 768
 // Hook fields
625 769
 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
626 770
 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
627 771
 print $hookmanager->resPrint;
628
-if (!empty($arrayfields['u.datec']['checked']))  print_liste_field_titre("DateCreationShort", $_SERVER["PHP_SELF"], "u.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
629
-if (!empty($arrayfields['u.tms']['checked']))    print_liste_field_titre("DateModificationShort", $_SERVER["PHP_SELF"], "u.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
630
-if (!empty($arrayfields['u.statut']['checked'])) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "u.statut", "", $param, '', $sortfield, $sortorder, 'center ');
772
+if (!empty($arrayfields['u.datec']['checked'])) {
773
+	print_liste_field_titre("DateCreationShort", $_SERVER["PHP_SELF"], "u.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
774
+}
775
+if (!empty($arrayfields['u.tms']['checked'])) {
776
+	print_liste_field_titre("DateModificationShort", $_SERVER["PHP_SELF"], "u.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
777
+}
778
+if (!empty($arrayfields['u.statut']['checked'])) {
779
+	print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "u.statut", "", $param, '', $sortfield, $sortorder, 'center ');
780
+}
631 781
 // Action column
632 782
 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
633 783
 print '</tr>'."\n";
@@ -639,7 +789,10 @@  discard block
 block discarded – undo
639 789
 {
640 790
 	foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
641 791
 	{
642
-		if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
792
+		if (preg_match('/\$object/', $val)) {
793
+			$needToFetchEachLine++;
794
+		}
795
+		// There is at least one compute field that use $object
643 796
 	}
644 797
 }
645 798
 
@@ -652,7 +805,10 @@  discard block
 block discarded – undo
652 805
 while ($i < ($limit ? min($num, $limit) : $num))
653 806
 {
654 807
 	$obj = $db->fetch_object($resql);
655
-	if (empty($obj)) break; // Should not happen
808
+	if (empty($obj)) {
809
+		break;
810
+	}
811
+	// Should not happen
656 812
 
657 813
 	// Store properties in $object
658 814
 	$object->setVarsFromFetchObj($obj);
@@ -685,29 +841,41 @@  discard block
 block discarded – undo
685 841
 			print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingleft"');
686 842
 		}
687 843
 		print '</td>';
688
-		if (!$i) $totalarray['nbfield']++;
844
+		if (!$i) {
845
+			$totalarray['nbfield']++;
846
+		}
689 847
 	}
690 848
 	if (!empty($arrayfields['u.lastname']['checked']))
691 849
 	{
692 850
 		  print '<td class="tdoverflowmax150">'.$obj->lastname.'</td>';
693
-		if (!$i) $totalarray['nbfield']++;
851
+		if (!$i) {
852
+			$totalarray['nbfield']++;
853
+		}
694 854
 	}
695 855
 	if (!empty($arrayfields['u.firstname']['checked']))
696 856
 	{
697 857
 		print '<td class="tdoverflowmax150">'.$obj->firstname.'</td>';
698
-		if (!$i) $totalarray['nbfield']++;
858
+		if (!$i) {
859
+			$totalarray['nbfield']++;
860
+		}
699 861
 	}
700 862
 	if (!empty($arrayfields['u.gender']['checked']))
701 863
 	{
702 864
 		print '<td>';
703
-		if ($obj->gender) print $langs->trans("Gender".$obj->gender);
865
+		if ($obj->gender) {
866
+			print $langs->trans("Gender".$obj->gender);
867
+		}
704 868
 		print '</td>';
705
-		if (!$i) $totalarray['nbfield']++;
869
+		if (!$i) {
870
+			$totalarray['nbfield']++;
871
+		}
706 872
 	}
707 873
 	if (!empty($arrayfields['u.employee']['checked']))
708 874
 	{
709 875
 		print '<td>'.yn($obj->employee).'</td>';
710
-		if (!$i) $totalarray['nbfield']++;
876
+		if (!$i) {
877
+			$totalarray['nbfield']++;
878
+		}
711 879
 	}
712 880
 
713 881
 	// Supervisor
@@ -737,23 +905,31 @@  discard block
 block discarded – undo
737 905
 	        }
738 906
 	    }
739 907
 	    print '</td>';
740
-	    if (!$i) $totalarray['nbfield']++;
908
+	    if (!$i) {
909
+	    	$totalarray['nbfield']++;
910
+	    }
741 911
 	}
742 912
 
743 913
 	if (!empty($arrayfields['u.accountancy_code']['checked']))
744 914
 	{
745 915
 		print '<td>'.$obj->accountancy_code.'</td>';
746
-		if (!$i) $totalarray['nbfield']++;
916
+		if (!$i) {
917
+			$totalarray['nbfield']++;
918
+		}
747 919
 	}
748 920
 	if (!empty($arrayfields['u.email']['checked']))
749 921
 	{
750 922
 		print '<td>'.$obj->email.'</td>';
751
-		if (!$i) $totalarray['nbfield']++;
923
+		if (!$i) {
924
+			$totalarray['nbfield']++;
925
+		}
752 926
 	}
753 927
 	if (!empty($arrayfields['u.api_key']['checked']))
754 928
 	{
755 929
 		print '<td>'.$obj->api_key.'</td>';
756
-		if (!$i) $totalarray['nbfield']++;
930
+		if (!$i) {
931
+			$totalarray['nbfield']++;
932
+		}
757 933
 	}
758 934
 	if (!empty($arrayfields['u.fk_soc']['checked']))
759 935
 	{
@@ -771,7 +947,9 @@  discard block
 block discarded – undo
771 947
 			print $langs->trans("InternalUser");
772 948
 		}
773 949
 		print '</td>';
774
-		if (!$i) $totalarray['nbfield']++;
950
+		if (!$i) {
951
+			$totalarray['nbfield']++;
952
+		}
775 953
 	}
776 954
 	// Multicompany enabled
777 955
 	if (!empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
@@ -787,7 +965,9 @@  discard block
 block discarded – undo
787 965
 				print $mc->label;
788 966
 			}
789 967
 			print '</td>';
790
-			if (!$i) $totalarray['nbfield']++;
968
+			if (!$i) {
969
+				$totalarray['nbfield']++;
970
+			}
791 971
 		}
792 972
 	}
793 973
 
@@ -795,20 +975,26 @@  discard block
 block discarded – undo
795 975
 	if (!empty($arrayfields['u.salary']['checked']))
796 976
 	{
797 977
 	    print '<td class="nowraponall right">'.($obj->salary ? price($obj->salary) : '').'</td>';
798
-	    if (!$i) $totalarray['nbfield']++;
978
+	    if (!$i) {
979
+	    	$totalarray['nbfield']++;
980
+	    }
799 981
 	}
800 982
 
801 983
 	// Date last login
802 984
 	if (!empty($arrayfields['u.datelastlogin']['checked']))
803 985
 	{
804 986
 		print '<td class="nowrap center">'.dol_print_date($db->jdate($obj->datelastlogin), "dayhour").'</td>';
805
-		if (!$i) $totalarray['nbfield']++;
987
+		if (!$i) {
988
+			$totalarray['nbfield']++;
989
+		}
806 990
 	}
807 991
 	// Date previous login
808 992
 	if (!empty($arrayfields['u.datepreviouslogin']['checked']))
809 993
 	{
810 994
 		print '<td class="nowrap center">'.dol_print_date($db->jdate($obj->datepreviouslogin), "dayhour").'</td>';
811
-		if (!$i) $totalarray['nbfield']++;
995
+		if (!$i) {
996
+			$totalarray['nbfield']++;
997
+		}
812 998
 	}
813 999
 
814 1000
 	// Extra fields
@@ -823,7 +1009,9 @@  discard block
 block discarded – undo
823 1009
 		print '<td class="center">';
824 1010
 		print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser');
825 1011
 		print '</td>';
826
-		if (!$i) $totalarray['nbfield']++;
1012
+		if (!$i) {
1013
+			$totalarray['nbfield']++;
1014
+		}
827 1015
 	}
828 1016
 	// Date modification
829 1017
 	if (!empty($arrayfields['u.tms']['checked']))
@@ -831,25 +1019,35 @@  discard block
 block discarded – undo
831 1019
 		print '<td class="center">';
832 1020
 		print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser');
833 1021
 		print '</td>';
834
-		if (!$i) $totalarray['nbfield']++;
1022
+		if (!$i) {
1023
+			$totalarray['nbfield']++;
1024
+		}
835 1025
 	}
836 1026
 	// Status
837 1027
 	if (!empty($arrayfields['u.statut']['checked']))
838 1028
 	{
839 1029
 		$userstatic->statut = $obj->statut;
840 1030
 		print '<td class="center">'.$userstatic->getLibStatut(5).'</td>';
841
-		if (!$i) $totalarray['nbfield']++;
1031
+		if (!$i) {
1032
+			$totalarray['nbfield']++;
1033
+		}
842 1034
 	}
843 1035
 	// Action column
844 1036
 	print '<td class="nowrap center">';
845
-	if ($massactionbutton || $massaction)   // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
1037
+	if ($massactionbutton || $massaction) {
1038
+		// If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
846 1039
 	{
847 1040
 		$selected = 0;
848
-		if (in_array($object->id, $arrayofselected)) $selected = 1;
1041
+	}
1042
+		if (in_array($object->id, $arrayofselected)) {
1043
+			$selected = 1;
1044
+		}
849 1045
 		print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
850 1046
 	}
851 1047
 	print '</td>';
852
-	if (!$i) $totalarray['nbfield']++;
1048
+	if (!$i) {
1049
+		$totalarray['nbfield']++;
1050
+	}
853 1051
 
854 1052
 	print '</tr>'."\n";
855 1053
 
@@ -863,7 +1061,10 @@  discard block
 block discarded – undo
863 1061
 if ($num == 0)
864 1062
 {
865 1063
 	$colspan = 1;
866
-	foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
1064
+	foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) {
1065
+		$colspan++;
1066
+	}
1067
+	}
867 1068
 	print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
868 1069
 }
869 1070
 
Please login to merge, or discard this patch.