Passed
Pull Request — master (#2)
by
unknown
26:19
created
dolibarr/htdocs/core/class/html.formcontract.class.php 1 patch
Braces   +19 added lines, -15 removed lines patch added patch discarded remove patch
@@ -66,7 +66,9 @@  discard block
 block discarded – undo
66 66
 		global $db,$user,$conf,$langs;
67 67
 
68 68
 		$hideunselectables = false;
69
-		if (! empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) $hideunselectables = true;
69
+		if (! empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) {
70
+		    $hideunselectables = true;
71
+		}
70 72
 
71 73
 		// Search all contacts
72 74
 		$sql = 'SELECT c.rowid, c.ref, c.fk_soc, c.statut';
@@ -76,15 +78,17 @@  discard block
 block discarded – undo
76 78
 		if ($socid > 0)
77 79
 		{
78 80
 			// CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma.
79
-		    	if (empty($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY))
80
-			    $sql.= " AND (c.fk_soc=".$socid." OR c.fk_soc IS NULL)";
81
-		    	else if ($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all')
81
+		    	if (empty($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) {
82
+		    				    $sql.= " AND (c.fk_soc=".$socid." OR c.fk_soc IS NULL)";
83
+		    	} else if ($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all')
82 84
 			{
83 85
 		        	$sql.= " AND (c.fk_soc IN (".$socid.", ".$conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") ";
84 86
 				$sql.= " OR c.fk_soc IS NULL)";
85 87
 		    	}
86 88
 		}
87
-		if ($socid == 0) $sql.= " AND (c.fk_soc = 0 OR c.fk_soc IS NULL)";
89
+		if ($socid == 0) {
90
+		    $sql.= " AND (c.fk_soc = 0 OR c.fk_soc IS NULL)";
91
+		}
88 92
 		$sql.= " ORDER BY c.ref ";
89 93
 
90 94
 		dol_syslog(get_class($this)."::select_contract", LOG_DEBUG);
@@ -92,7 +96,9 @@  discard block
 block discarded – undo
92 96
 		if ($resql)
93 97
 		{
94 98
 			print '<select class="flat" name="'.$htmlname.'">';
95
-			if ($showempty) print '<option value="0">&nbsp;</option>';
99
+			if ($showempty) {
100
+			    print '<option value="0">&nbsp;</option>';
101
+			}
96 102
 			$num = $db->num_rows($resql);
97 103
 			$i = 0;
98 104
 			if ($num)
@@ -104,8 +110,7 @@  discard block
 block discarded – undo
104 110
 					if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire)
105 111
 					{
106 112
 						// Do nothing
107
-					}
108
-					else
113
+					} else
109 114
 					{
110 115
 						$labeltoshow=dol_trunc($obj->ref,18);
111 116
 						//if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
@@ -113,8 +118,7 @@  discard block
 block discarded – undo
113 118
 						if (!empty($selected) && $selected == $obj->rowid && $obj->statut > 0)
114 119
 						{
115 120
 							print '<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';
116
-						}
117
-						else
121
+						} else
118 122
 						{
119 123
 							$disabled=0;
120 124
 							if ( $obj->statut ==  0)
@@ -131,11 +135,12 @@  discard block
 block discarded – undo
131 135
 							if ($hideunselectables && $disabled)
132 136
 							{
133 137
 								$resultat='';
134
-							}
135
-							else
138
+							} else
136 139
 							{
137 140
 								$resultat='<option value="'.$obj->rowid.'"';
138
-								if ($disabled) $resultat.=' disabled';
141
+								if ($disabled) {
142
+								    $resultat.=' disabled';
143
+								}
139 144
 								//if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
140 145
 								//else $labeltoshow.=' ('.$langs->trans("Private").')';
141 146
 								$resultat.='>'.$labeltoshow;
@@ -158,8 +163,7 @@  discard block
 block discarded – undo
158 163
 			}
159 164
 
160 165
 			return $num;
161
-		}
162
-		else
166
+		} else
163 167
 		{
164 168
 			dol_print_error($db);
165 169
 			return -1;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/class/html.formmargin.class.php 1 patch
Braces   +66 added lines, -46 removed lines patch added patch discarded remove patch
@@ -88,8 +88,9 @@  discard block
 block discarded – undo
88 88
 			{
89 89
 				require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
90 90
 				$product = new ProductFournisseur($db);
91
-				if ($product->fetch_product_fournisseur_price($line->fk_fournprice))
92
-					$line->pa_ht = $product->fourn_unitprice * (1 - $product->fourn_remise_percent / 100);
91
+				if ($product->fetch_product_fournisseur_price($line->fk_fournprice)) {
92
+									$line->pa_ht = $product->fourn_unitprice * (1 - $product->fourn_remise_percent / 100);
93
+				}
93 94
 			}
94 95
 			// si prix d'achat non renseigné et devrait l'être, alors prix achat = prix vente
95 96
 			if ((!isset($line->pa_ht) || $line->pa_ht == 0) && $line->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) {
@@ -114,8 +115,7 @@  discard block
 block discarded – undo
114 115
 					//}
115 116
 					//else
116 117
 						$marginInfos['margin_on_products'] += $pv - $pa;
117
-				}
118
-				elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '2') { // remise globale considérée comme service
118
+				} elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '2') { // remise globale considérée comme service
119 119
 					$marginInfos['pa_services'] += $pa;
120 120
 					$marginInfos['pv_services'] += $pv;
121 121
 					$marginInfos['pa_total'] +=  $pa;
@@ -125,13 +125,11 @@  discard block
 block discarded – undo
125 125
 					//	$marginInfos['margin_on_services'] += -1 * (abs($pv) - $pa);
126 126
 					//else
127 127
 						$marginInfos['margin_on_services'] += $pv - $pa;
128
-				}
129
-				elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '3') { // remise globale prise en compte uniqt sur total
128
+				} elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '3') { // remise globale prise en compte uniqt sur total
130 129
 					$marginInfos['pa_total'] += $pa;
131 130
 					$marginInfos['pv_total'] += $pv;
132 131
 				}
133
-			}
134
-			else {
132
+			} else {
135 133
 				$type=$line->product_type?$line->product_type:$line->fk_product_type;
136 134
 				if ($type == 0) {  // product
137 135
 					$marginInfos['pa_products'] += $pa;
@@ -147,8 +145,7 @@  discard block
 block discarded – undo
147 145
 					//{
148 146
 					    $marginInfos['margin_on_products'] += $pv - $pa;
149 147
 					//}
150
-				}
151
-				elseif ($type == 1) {  // service
148
+				} elseif ($type == 1) {  // service
152 149
 					$marginInfos['pa_services'] += $pa;
153 150
 					$marginInfos['pv_services'] += $pv;
154 151
 					$marginInfos['pa_total'] +=  $pa;
@@ -161,25 +158,31 @@  discard block
 block discarded – undo
161 158
 				}
162 159
 			}
163 160
 		}
164
-		if ($marginInfos['pa_products'] > 0)
165
-			$marginInfos['margin_rate_products'] = 100 * $marginInfos['margin_on_products'] / $marginInfos['pa_products'];
166
-		if ($marginInfos['pv_products'] > 0)
167
-			$marginInfos['mark_rate_products'] = 100 * $marginInfos['margin_on_products'] / $marginInfos['pv_products'];
161
+		if ($marginInfos['pa_products'] > 0) {
162
+					$marginInfos['margin_rate_products'] = 100 * $marginInfos['margin_on_products'] / $marginInfos['pa_products'];
163
+		}
164
+		if ($marginInfos['pv_products'] > 0) {
165
+					$marginInfos['mark_rate_products'] = 100 * $marginInfos['margin_on_products'] / $marginInfos['pv_products'];
166
+		}
168 167
 
169
-		if ($marginInfos['pa_services'] > 0)
170
-			$marginInfos['margin_rate_services'] = 100 * $marginInfos['margin_on_services'] / $marginInfos['pa_services'];
171
-		if ($marginInfos['pv_services'] > 0)
172
-			$marginInfos['mark_rate_services'] = 100 * $marginInfos['margin_on_services'] / $marginInfos['pv_services'];
168
+		if ($marginInfos['pa_services'] > 0) {
169
+					$marginInfos['margin_rate_services'] = 100 * $marginInfos['margin_on_services'] / $marginInfos['pa_services'];
170
+		}
171
+		if ($marginInfos['pv_services'] > 0) {
172
+					$marginInfos['mark_rate_services'] = 100 * $marginInfos['margin_on_services'] / $marginInfos['pv_services'];
173
+		}
173 174
 
174 175
 		// if credit note, margin = -1 * (abs(selling_price) - buying_price)
175 176
 		//if ($marginInfos['pv_total'] < 0)
176 177
 		//	$marginInfos['total_margin'] = -1 * (abs($marginInfos['pv_total']) - $marginInfos['pa_total']);
177 178
 		//else
178 179
 			$marginInfos['total_margin'] = $marginInfos['pv_total'] - $marginInfos['pa_total'];
179
-		if ($marginInfos['pa_total'] > 0)
180
-			$marginInfos['total_margin_rate'] = 100 * $marginInfos['total_margin'] / $marginInfos['pa_total'];
181
-		if ($marginInfos['pv_total'] > 0)
182
-			$marginInfos['total_mark_rate'] = 100 * $marginInfos['total_margin'] / $marginInfos['pv_total'];
180
+		if ($marginInfos['pa_total'] > 0) {
181
+					$marginInfos['total_margin_rate'] = 100 * $marginInfos['total_margin'] / $marginInfos['pa_total'];
182
+		}
183
+		if ($marginInfos['pv_total'] > 0) {
184
+					$marginInfos['total_mark_rate'] = 100 * $marginInfos['total_margin'] / $marginInfos['pv_total'];
185
+		}
183 186
 
184 187
 		return $marginInfos;
185 188
 	}
@@ -195,17 +198,23 @@  discard block
 block discarded – undo
195 198
 	{
196 199
 		global $langs, $conf, $user;
197 200
 
198
-    	if (! empty($user->societe_id)) return;
201
+    	if (! empty($user->societe_id)) {
202
+    	    return;
203
+    	}
199 204
 
200
-    	if (! $user->rights->margins->liretous) return;
205
+    	if (! $user->rights->margins->liretous) {
206
+    	    return;
207
+    	}
201 208
 
202 209
         $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT);
203 210
 
204 211
 		$marginInfo = $this->getMarginInfosArray($object, $force_price);
205 212
 
206
-		if (! empty($conf->global->MARGIN_ADD_SHOWHIDE_BUTTON))	// TODO Warning this feature rely on an external js file that may be removed. Using native js function document.cookie should be better
213
+		if (! empty($conf->global->MARGIN_ADD_SHOWHIDE_BUTTON)) {
214
+		    // TODO Warning this feature rely on an external js file that may be removed. Using native js function document.cookie should be better
207 215
 		{
208 216
 			print $langs->trans('ShowMarginInfos').' : ';
217
+		}
209 218
 	        $hidemargininfos = $_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW'];
210 219
 	    	print '<span id="showMarginInfos" class="linkobject '.(!empty($hidemargininfos)?'':'hideobject').'">'.img_picto($langs->trans("Disabled"),'switch_off').'</span>';
211 220
 	    	print '<span id="hideMarginInfos" class="linkobject '.(!empty($hidemargininfos)?'hideobject':'').'">'.img_picto($langs->trans("Enabled"),'switch_on').'</span>';
@@ -214,7 +223,9 @@  discard block
 block discarded – undo
214 223
         	    $("span#showMarginInfos").click(function() { $.getScript( "'.dol_buildpath('/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js', 1).'", function( data, textStatus, jqxhr ) { $.cookie("DOLUSER_MARGININFO_HIDE_SHOW", 0); $(".margininfos").show(); $("span#showMarginInfos").addClass("hideobject"); $("span#hideMarginInfos").removeClass("hideobject");})});
215 224
         	    $("span#hideMarginInfos").click(function() { $.getScript( "'.dol_buildpath('/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js', 1).'", function( data, textStatus, jqxhr ) { $.cookie("DOLUSER_MARGININFO_HIDE_SHOW", 1); $(".margininfos").hide(); $("span#hideMarginInfos").addClass("hideobject"); $("span#showMarginInfos").removeClass("hideobject");})});
216 225
       	        });</script>';
217
-    	    if (!empty($hidemargininfos)) print '<script>$(document).ready(function() {$(".margininfos").hide();});</script>';
226
+    	    if (!empty($hidemargininfos)) {
227
+    	        print '<script>$(document).ready(function() {$(".margininfos").hide();});</script>';
228
+    	    }
218 229
 		}
219 230
 
220 231
 		print '<div class="div-table-responsive-no-min">';
@@ -224,15 +235,18 @@  discard block
 block discarded – undo
224 235
 		print '<tr class="liste_titre">';
225 236
 		print '<td class="liste_titre">'.$langs->trans('Margins').'</td>';
226 237
 		print '<td class="liste_titre" align="right">'.$langs->trans('SellingPrice').'</td>';
227
-		if ($conf->global->MARGIN_TYPE == "1")
228
-			print '<td class="liste_titre" align="right">'.$langs->trans('BuyingPrice').'</td>';
229
-		else
230
-			print '<td class="liste_titre" align="right">'.$langs->trans('CostPrice').'</td>';
238
+		if ($conf->global->MARGIN_TYPE == "1") {
239
+					print '<td class="liste_titre" align="right">'.$langs->trans('BuyingPrice').'</td>';
240
+		} else {
241
+					print '<td class="liste_titre" align="right">'.$langs->trans('CostPrice').'</td>';
242
+		}
231 243
 		print '<td class="liste_titre" align="right">'.$langs->trans('Margin').'</td>';
232
-		if (! empty($conf->global->DISPLAY_MARGIN_RATES))
233
-			print '<td class="liste_titre" align="right">'.$langs->trans('MarginRate').'</td>';
234
-		if (! empty($conf->global->DISPLAY_MARK_RATES))
235
-			print '<td class="liste_titre" align="right">'.$langs->trans('MarkRate').'</td>';
244
+		if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
245
+					print '<td class="liste_titre" align="right">'.$langs->trans('MarginRate').'</td>';
246
+		}
247
+		if (! empty($conf->global->DISPLAY_MARK_RATES)) {
248
+					print '<td class="liste_titre" align="right">'.$langs->trans('MarkRate').'</td>';
249
+		}
236 250
 		print '</tr>';
237 251
 
238 252
 		if (! empty($conf->product->enabled))
@@ -243,10 +257,12 @@  discard block
 block discarded – undo
243 257
 			print '<td align="right">'.price($marginInfo['pv_products'], null, null, null, null, $rounding).'</td>';
244 258
 			print '<td align="right">'.price($marginInfo['pa_products'], null, null, null, null, $rounding).'</td>';
245 259
 			print '<td align="right">'.price($marginInfo['margin_on_products'], null, null, null, null, $rounding).'</td>';
246
-			if (! empty($conf->global->DISPLAY_MARGIN_RATES))
247
-				print '<td align="right">'.(($marginInfo['margin_rate_products'] == '')?'':price($marginInfo['margin_rate_products'], null, null, null, null, $rounding).'%').'</td>';
248
-			if (! empty($conf->global->DISPLAY_MARK_RATES))
249
-				print '<td align="right">'.(($marginInfo['mark_rate_products'] == '')?'':price($marginInfo['mark_rate_products'], null, null, null, null, $rounding).'%').'</td>';
260
+			if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
261
+							print '<td align="right">'.(($marginInfo['margin_rate_products'] == '')?'':price($marginInfo['margin_rate_products'], null, null, null, null, $rounding).'%').'</td>';
262
+			}
263
+			if (! empty($conf->global->DISPLAY_MARK_RATES)) {
264
+							print '<td align="right">'.(($marginInfo['mark_rate_products'] == '')?'':price($marginInfo['mark_rate_products'], null, null, null, null, $rounding).'%').'</td>';
265
+			}
250 266
 			print '</tr>';
251 267
 		}
252 268
 
@@ -257,10 +273,12 @@  discard block
 block discarded – undo
257 273
 			print '<td align="right">'.price($marginInfo['pv_services'], null, null, null, null, $rounding).'</td>';
258 274
 			print '<td align="right">'.price($marginInfo['pa_services'], null, null, null, null, $rounding).'</td>';
259 275
 			print '<td align="right">'.price($marginInfo['margin_on_services'], null, null, null, null, $rounding).'</td>';
260
-			if (! empty($conf->global->DISPLAY_MARGIN_RATES))
261
-				print '<td align="right">'.(($marginInfo['margin_rate_services'] == '')?'':price($marginInfo['margin_rate_services'], null, null, null, null, $rounding).'%').'</td>';
262
-			if (! empty($conf->global->DISPLAY_MARK_RATES))
263
-				print '<td align="right">'.(($marginInfo['mark_rate_services'] == '')?'':price($marginInfo['mark_rate_services'], null, null, null, null, $rounding).'%').'</td>';
276
+			if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
277
+							print '<td align="right">'.(($marginInfo['margin_rate_services'] == '')?'':price($marginInfo['margin_rate_services'], null, null, null, null, $rounding).'%').'</td>';
278
+			}
279
+			if (! empty($conf->global->DISPLAY_MARK_RATES)) {
280
+							print '<td align="right">'.(($marginInfo['mark_rate_services'] == '')?'':price($marginInfo['mark_rate_services'], null, null, null, null, $rounding).'%').'</td>';
281
+			}
264 282
 			print '</tr>';
265 283
 		}
266 284
 
@@ -271,10 +289,12 @@  discard block
 block discarded – undo
271 289
 			print '<td align="right">'.price($marginInfo['pv_total'], null, null, null, null, $rounding).'</td>';
272 290
 			print '<td align="right">'.price($marginInfo['pa_total'], null, null, null, null, $rounding).'</td>';
273 291
 			print '<td align="right">'.price($marginInfo['total_margin'], null, null, null, null, $rounding).'</td>';
274
-			if (! empty($conf->global->DISPLAY_MARGIN_RATES))
275
-				print '<td align="right">'.(($marginInfo['total_margin_rate'] == '')?'':price($marginInfo['total_margin_rate'], null, null, null, null, $rounding).'%').'</td>';
276
-			if (! empty($conf->global->DISPLAY_MARK_RATES))
277
-				print '<td align="right">'.(($marginInfo['total_mark_rate'] == '')?'':price($marginInfo['total_mark_rate'], null, null, null, null, $rounding).'%').'</td>';
292
+			if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
293
+							print '<td align="right">'.(($marginInfo['total_margin_rate'] == '')?'':price($marginInfo['total_margin_rate'], null, null, null, null, $rounding).'%').'</td>';
294
+			}
295
+			if (! empty($conf->global->DISPLAY_MARK_RATES)) {
296
+							print '<td align="right">'.(($marginInfo['total_mark_rate'] == '')?'':price($marginInfo['total_mark_rate'], null, null, null, null, $rounding).'%').'</td>';
297
+			}
278 298
 			print '</tr>';
279 299
 		}
280 300
 		print '</table>';
Please login to merge, or discard this patch.
dolibarr/htdocs/core/class/html.formpropal.class.php 1 patch
Braces   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -78,8 +78,7 @@  discard block
 block discarded – undo
78 78
                 3=>array('id'=>3, 'code'=>'PR_NOTSIGNED'),
79 79
                 4=>array('id'=>4, 'code'=>'PR_CLOSED')
80 80
             );
81
-        }
82
-        else
81
+        } else
83 82
         {
84 83
             $prefix="PropalStatus";
85 84
 
@@ -100,15 +99,16 @@  discard block
 block discarded – undo
100 99
                         $i++;
101 100
                     }
102 101
                 }
103
-            }
104
-            else
102
+            } else
105 103
             {
106 104
                 dol_print_error($this->db);
107 105
             }
108 106
         }
109 107
 
110 108
         print '<select class="flat" name="'.$htmlname.'">';
111
-        if ($showempty) print '<option value="-1">&nbsp;</option>';
109
+        if ($showempty) {
110
+            print '<option value="-1">&nbsp;</option>';
111
+        }
112 112
 
113 113
         foreach($listofstatus as $key => $obj)
114 114
         {
@@ -123,8 +123,7 @@  discard block
 block discarded – undo
123 123
             if ($selected != '' && $selected == $obj['id'])
124 124
             {
125 125
                 print '<option value="'.$obj['id'].'" selected>';
126
-            }
127
-            else
126
+            } else
128 127
             {
129 128
                 print '<option value="'.$obj['id'].'">';
130 129
             }
@@ -132,11 +131,12 @@  discard block
 block discarded – undo
132 131
             if ($langs->trans($prefix.$key.($short?'Short':'')) != $prefix.$key.($short?'Short':''))
133 132
             {
134 133
                 print $langs->trans($prefix.$key.($short?'Short':''));
135
-            }
136
-            else
134
+            } else
137 135
 			{
138 136
                 $conv_to_new_code=array('PR_DRAFT'=>'Draft','PR_OPEN'=>'Validated','PR_CLOSED'=>'Closed','PR_SIGNED'=>'Signed','PR_NOTSIGNED'=>'NotSigned','PR_FAC'=>'Billed');
139
-                if (! empty($conv_to_new_code[$obj['code']])) $key=$conv_to_new_code[$obj['code']];
137
+                if (! empty($conv_to_new_code[$obj['code']])) {
138
+                    $key=$conv_to_new_code[$obj['code']];
139
+                }
140 140
 
141 141
                 print ($langs->trans($prefix.$key.($short?'Short':''))!=$prefix.$key.($short?'Short':''))?$langs->trans($prefix.$key.($short?'Short':'')):($obj['label']?$obj['label']:$obj['code']);
142 142
             }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/class/discount.class.php 1 patch
Braces   +88 added lines, -59 removed lines patch added patch discarded remove patch
@@ -131,9 +131,15 @@  discard block
 block discarded – undo
131 131
         $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON sr.fk_facture_source = f.rowid";
132 132
         $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fsup ON sr.fk_invoice_supplier_source = fsup.rowid";
133 133
         $sql.= " WHERE sr.entity = " . $conf->entity;
134
-        if ($rowid) $sql.= " AND sr.rowid=".$rowid;
135
-        if ($fk_facture_source) $sql.= " AND sr.fk_facture_source=".$fk_facture_source;
136
-        if ($fk_invoice_supplier_source) $sql.= " AND sr.fk_invoice_supplier_source=".$fk_invoice_supplier_source;
134
+        if ($rowid) {
135
+            $sql.= " AND sr.rowid=".$rowid;
136
+        }
137
+        if ($fk_facture_source) {
138
+            $sql.= " AND sr.fk_facture_source=".$fk_facture_source;
139
+        }
140
+        if ($fk_invoice_supplier_source) {
141
+            $sql.= " AND sr.fk_invoice_supplier_source=".$fk_invoice_supplier_source;
142
+        }
137 143
 
138 144
         dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
139 145
         $resql = $this->db->query($sql);
@@ -170,14 +176,12 @@  discard block
 block discarded – undo
170 176
 
171 177
                 $this->db->free($resql);
172 178
                 return 1;
173
-            }
174
-            else
179
+            } else
175 180
             {
176 181
                 $this->db->free($resql);
177 182
                 return 0;
178 183
             }
179
-        }
180
-        else
184
+        } else
181 185
         {
182 186
             $this->error=$this->db->error();
183 187
             return -1;
@@ -206,9 +210,15 @@  discard block
 block discarded – undo
206 210
         $this->multicurrency_amount_tva=price2num($this->multicurrency_amount_tva);
207 211
         $this->multicurrency_amount_ttc=price2num($this->multicurrency_amount_ttc);
208 212
 
209
-        if (empty($this->multicurrency_amount_ht)) $this->multicurrency_amount_ht=0;
210
-        if (empty($this->multicurrency_amount_tva)) $this->multicurrency_amount_tva=0;
211
-        if (empty($this->multicurrency_amount_ttc)) $this->multicurrency_amount_ttc=0;
213
+        if (empty($this->multicurrency_amount_ht)) {
214
+            $this->multicurrency_amount_ht=0;
215
+        }
216
+        if (empty($this->multicurrency_amount_tva)) {
217
+            $this->multicurrency_amount_tva=0;
218
+        }
219
+        if (empty($this->multicurrency_amount_ttc)) {
220
+            $this->multicurrency_amount_ttc=0;
221
+        }
212 222
 
213 223
         // Check parameters
214 224
         if (empty($this->description))
@@ -238,8 +248,7 @@  discard block
 block discarded – undo
238 248
         {
239 249
             $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."societe_remise_except");
240 250
             return $this->id;
241
-        }
242
-        else
251
+        } else
243 252
         {
244 253
             $this->error=$this->db->lasterror().' - sql='.$sql;
245 254
             return -1;
@@ -277,8 +286,7 @@  discard block
 block discarded – undo
277 286
                     $this->error='ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved';
278 287
                     return -2;
279 288
                 }
280
-            }
281
-            else
289
+            } else
282 290
             {
283 291
                 dol_print_error($this->db);
284 292
                 return -1;
@@ -305,8 +313,7 @@  discard block
 block discarded – undo
305 313
         			$this->error='ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved';
306 314
         			return -2;
307 315
         		}
308
-        	}
309
-        	else
316
+        	} else
310 317
         	{
311 318
         		dol_print_error($this->db);
312 319
         		return -1;
@@ -317,9 +324,18 @@  discard block
 block discarded – undo
317 324
 
318 325
         // Delete but only if not used
319 326
         $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except ";
320
-        if ($this->fk_facture_source) $sql.= " WHERE fk_facture_source = ".$this->fk_facture_source;	// Delete all lines of same serie
321
-        elseif ($this->fk_invoice_supplier_source) $sql.= " WHERE fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source;	// Delete all lines of same serie
322
-        else $sql.= " WHERE rowid = ".$this->id;	// Delete only line
327
+        if ($this->fk_facture_source) {
328
+            $sql.= " WHERE fk_facture_source = ".$this->fk_facture_source;
329
+        }
330
+        // Delete all lines of same serie
331
+        elseif ($this->fk_invoice_supplier_source) {
332
+            $sql.= " WHERE fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source;
333
+        }
334
+        // Delete all lines of same serie
335
+        else {
336
+            $sql.= " WHERE rowid = ".$this->id;
337
+        }
338
+        // Delete only line
323 339
         $sql.= " AND (fk_facture_line IS NULL";	// Not used as absolute simple discount
324 340
         $sql.= " AND fk_facture IS NULL)";		// Not used as credit note and not used as deposit
325 341
         $sql.= " AND (fk_invoice_supplier_line IS NULL";	// Not used as absolute simple discount
@@ -342,15 +358,13 @@  discard block
 block discarded – undo
342 358
                 {
343 359
                     $this->db->commit();
344 360
                     return 1;
345
-                }
346
-                else
361
+                } else
347 362
                 {
348 363
                     $this->error=$this->db->lasterror();
349 364
                     $this->db->rollback();
350 365
                     return -1;
351 366
                 }
352
-            }
353
-            elseif($this->fk_invoice_supplier_source) {
367
+            } elseif($this->fk_invoice_supplier_source) {
354 368
 
355 369
             	$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn";
356 370
             	$sql.=" set paye=0, fk_statut=1";
@@ -362,21 +376,18 @@  discard block
 block discarded – undo
362 376
             	{
363 377
             		$this->db->commit();
364 378
             		return 1;
365
-            	}
366
-            	else
379
+            	} else
367 380
             	{
368 381
             		$this->error=$this->db->lasterror();
369 382
             		$this->db->rollback();
370 383
             		return -1;
371 384
             	}
372
-            }
373
-            else
385
+            } else
374 386
             {
375 387
                 $this->db->commit();
376 388
                 return 1;
377 389
             }
378
-        }
379
-        else
390
+        } else
380 391
         {
381 392
             $this->error=$this->db->lasterror();
382 393
             $this->db->rollback();
@@ -413,11 +424,19 @@  discard block
 block discarded – undo
413 424
 
414 425
         $sql ="UPDATE ".MAIN_DB_PREFIX."societe_remise_except";
415 426
         if(! empty($this->discount_type)) {
416
-        	if ($rowidline)    $sql.=" SET fk_invoice_supplier_line = ".$rowidline;
417
-        	if ($rowidinvoice) $sql.=" SET fk_invoice_supplier = ".$rowidinvoice;
427
+        	if ($rowidline) {
428
+        	    $sql.=" SET fk_invoice_supplier_line = ".$rowidline;
429
+        	}
430
+        	if ($rowidinvoice) {
431
+        	    $sql.=" SET fk_invoice_supplier = ".$rowidinvoice;
432
+        	}
418 433
         } else {
419
-        	if ($rowidline)    $sql.=" SET fk_facture_line = ".$rowidline;
420
-        	if ($rowidinvoice) $sql.=" SET fk_facture = ".$rowidinvoice;
434
+        	if ($rowidline) {
435
+        	    $sql.=" SET fk_facture_line = ".$rowidline;
436
+        	}
437
+        	if ($rowidinvoice) {
438
+        	    $sql.=" SET fk_facture = ".$rowidinvoice;
439
+        	}
421 440
         }
422 441
         $sql.=" WHERE rowid = ".$this->id;
423 442
 
@@ -433,8 +452,7 @@  discard block
 block discarded – undo
433 452
         		$this->fk_facture=$rowidinvoice;
434 453
         	}
435 454
             return 1;
436
-        }
437
-        else
455
+        } else
438 456
         {
439 457
             $this->error=$this->db->error();
440 458
             return -3;
@@ -465,8 +483,7 @@  discard block
 block discarded – undo
465 483
         if ($resql)
466 484
         {
467 485
             return 1;
468
-        }
469
-        else
486
+        } else
470 487
         {
471 488
             $this->error=$this->db->error();
472 489
             return -3;
@@ -498,10 +515,18 @@  discard block
 block discarded – undo
498 515
         } else {
499 516
         	$sql.= " AND (rc.fk_facture IS NULL AND rc.fk_facture_line IS NULL)"; // Available to customer
500 517
         }
501
-        if (is_object($company)) $sql.= " AND rc.fk_soc = ".$company->id;
502
-        if (is_object($user))    $sql.= " AND rc.fk_user = ".$user->id;
503
-        if ($filter)   $sql.=' AND ('.$filter.')';
504
-        if ($maxvalue) $sql.=' AND rc.amount_ttc <= '.price2num($maxvalue);
518
+        if (is_object($company)) {
519
+            $sql.= " AND rc.fk_soc = ".$company->id;
520
+        }
521
+        if (is_object($user)) {
522
+            $sql.= " AND rc.fk_user = ".$user->id;
523
+        }
524
+        if ($filter) {
525
+            $sql.=' AND ('.$filter.')';
526
+        }
527
+        if ($maxvalue) {
528
+            $sql.=' AND rc.amount_ttc <= '.price2num($maxvalue);
529
+        }
505 530
 
506 531
         dol_syslog(get_class($this)."::getAvailableDiscounts", LOG_DEBUG);
507 532
         $resql=$this->db->query($sql);
@@ -537,15 +562,13 @@  discard block
 block discarded – undo
537 562
             $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f';
538 563
             $sql.= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id;
539 564
             $sql.= ' AND f.type = 3';
540
-        }
541
-        else if ($invoice->element == 'invoice_supplier')
565
+        } else if ($invoice->element == 'invoice_supplier')
542 566
         {
543 567
             $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
544 568
             $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f';
545 569
             $sql.= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id;
546 570
             $sql.= ' AND f.type = 3';
547
-        }
548
-        else
571
+        } else
549 572
         {
550 573
             $this->error=get_class($this)."::getSumDepositsUsed was called with a bad object as a first parameter";
551 574
             dol_print_error($this->error);
@@ -556,10 +579,12 @@  discard block
 block discarded – undo
556 579
         if ($resql)
557 580
         {
558 581
             $obj = $this->db->fetch_object($resql);
559
-            if ($multicurrency) return $obj->multicurrency_amount;
560
-			else return $obj->amount;
561
-        }
562
-        else
582
+            if ($multicurrency) {
583
+                return $obj->multicurrency_amount;
584
+            } else {
585
+			    return $obj->amount;
586
+			}
587
+        } else
563 588
         {
564 589
             $this->error = $this->db->lasterror();
565 590
             return -1;
@@ -583,15 +608,13 @@  discard block
 block discarded – undo
583 608
             $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f';
584 609
             $sql.= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id;
585 610
             $sql.= ' AND (f.type = 2 OR f.type = 0)';	// Find discount coming from credit note or excess received
586
-        }
587
-        else if ($invoice->element == 'invoice_supplier')
611
+        } else if ($invoice->element == 'invoice_supplier')
588 612
         {
589 613
             $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
590 614
             $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f';
591 615
             $sql.= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id;
592 616
             $sql.= ' AND (f.type = 2 OR f.type = 0)';	// Find discount coming from credit note or excess paid
593
-        }
594
-        else
617
+        } else
595 618
         {
596 619
             $this->error=get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter";
597 620
             dol_print_error($this->error);
@@ -602,10 +625,12 @@  discard block
 block discarded – undo
602 625
         if ($resql)
603 626
         {
604 627
             $obj = $this->db->fetch_object($resql);
605
-            if ($multicurrency) return $obj->multicurrency_amount;
606
-			else return $obj->amount;
607
-        }
608
-        else
628
+            if ($multicurrency) {
629
+                return $obj->multicurrency_amount;
630
+            } else {
631
+			    return $obj->amount;
632
+			}
633
+        } else
609 634
         {
610 635
             $this->error = $this->db->lasterror();
611 636
             return -1;
@@ -643,8 +668,12 @@  discard block
 block discarded – undo
643 668
         }
644 669
 
645 670
 
646
-        if ($withpicto) $result.=($link.img_object($label, $picto, 'class="classfortooltip"').$linkend);
647
-        if ($withpicto && $withpicto != 2) $result.=' ';
671
+        if ($withpicto) {
672
+            $result.=($link.img_object($label, $picto, 'class="classfortooltip"').$linkend);
673
+        }
674
+        if ($withpicto && $withpicto != 2) {
675
+            $result.=' ';
676
+        }
648 677
         $result.=$link.$ref.$linkend;
649 678
         return $result;
650 679
     }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/class/openid.class.php 1 patch
Braces   +21 added lines, -16 removed lines patch added patch discarded remove patch
@@ -218,8 +218,7 @@  discard block
 block discarded – undo
218 218
         if (count($this->error) > 0)
219 219
         {
220 220
             return true;
221
-        }
222
-        else
221
+        } else
223 222
         {
224 223
             return false;
225 224
         }
@@ -255,8 +254,9 @@  discard block
 block discarded – undo
255 254
     function OpenID_Standarize($openid_identity = null)
256 255
     {
257 256
         // phpcs:enable
258
-        if ($openid_identity === null)
259
-        $openid_identity = $this->openid_url_identity;
257
+        if ($openid_identity === null) {
258
+                $openid_identity = $this->openid_url_identity;
259
+        }
260 260
 
261 261
         $u = parse_url(strtolower(trim($openid_identity)));
262 262
 
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
         }
269 269
         if (isset($u['query'])){ // If there is a query string, then use identity as is
270 270
             return $u['host'] . $u['path'] . '?' . $u['query'];
271
-        }else{
271
+        } else{
272 272
             return $u['host'] . $u['path'];
273 273
         }
274 274
     }
@@ -339,7 +339,9 @@  discard block
 block discarded – undo
339 339
     {
340 340
         // phpcs:enable
341 341
         // Remember, SSL MUST BE SUPPORTED
342
-        if (is_array($params)) $params = $this->array2url($params);
342
+        if (is_array($params)) {
343
+            $params = $this->array2url($params);
344
+        }
343 345
 
344 346
         $curl = curl_init($url . ($method == "GET" && $params != "" ? "?" . $params : ""));
345 347
         @curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
@@ -347,13 +349,15 @@  discard block
 block discarded – undo
347 349
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
348 350
         curl_setopt($curl, CURLOPT_HTTPGET, ($method == "GET"));
349 351
         curl_setopt($curl, CURLOPT_POST, ($method == "POST"));
350
-        if ($method == "POST") curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
352
+        if ($method == "POST") {
353
+            curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
354
+        }
351 355
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
352 356
         $response = curl_exec($curl);
353 357
 
354 358
         if (curl_errno($curl) == 0){
355 359
             $response;
356
-        }else{
360
+        } else{
357 361
             $this->ErrorStore('OPENID_CURL', curl_error($curl));
358 362
         }
359 363
         return $response;
@@ -400,7 +404,9 @@  discard block
 block discarded – undo
400 404
         global $conf;
401 405
 
402 406
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
403
-		if (empty($url)) $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL;
407
+		if (empty($url)) {
408
+		    $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL;
409
+		}
404 410
 
405 411
         $response = getURLContent($url);
406 412
 
@@ -458,8 +464,7 @@  discard block
 block discarded – undo
458 464
             echo '<script language="JavaScript" type="text/javascript">window.location=\'';
459 465
             echo $redirect_to;
460 466
             echo '\';</script>';
461
-        }
462
-        else
467
+        } else
463 468
         {	// Default Header Redirect
464 469
             header('Location: ' . $redirect_to);
465 470
         }
@@ -502,8 +507,7 @@  discard block
 block discarded – undo
502 507
         if ($data['is_valid'] == "true")
503 508
         {
504 509
             return true;
505
-        }
506
-        else
510
+        } else
507 511
         {
508 512
             return false;
509 513
         }
@@ -523,7 +527,9 @@  discard block
 block discarded – undo
523 527
     	global $conf;
524 528
 
525 529
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
526
-		if (empty($url)) $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL;
530
+		if (empty($url)) {
531
+		    $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL;
532
+		}
527 533
 
528 534
 		dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS get XRDS');
529 535
 
@@ -554,8 +560,7 @@  discard block
 block discarded – undo
554 560
         {
555 561
             $this->ErrorStore('OPENID_NOSERVERSFOUND');
556 562
             return false;
557
-        }
558
-        else
563
+        } else
559 564
        {
560 565
        		dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS found endpoint = '.$server);
561 566
         	$this->SetOpenIDServer($server);
Please login to merge, or discard this patch.
dolibarr/htdocs/core/class/emailsenderprofile.class.php 1 patch
Braces   +54 added lines, -28 removed lines patch added patch discarded remove patch
@@ -152,8 +152,12 @@  discard block
 block discarded – undo
152 152
 
153 153
 		$this->db = $db;
154 154
 
155
-		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0;
156
-		if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled']=0;
155
+		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
156
+		    $this->fields['rowid']['visible']=0;
157
+		}
158
+		if (empty($conf->multicompany->enabled)) {
159
+		    $this->fields['entity']['enabled']=0;
160
+		}
157 161
 	}
158 162
 
159 163
 	/**
@@ -227,7 +231,9 @@  discard block
 block discarded – undo
227 231
 	public function fetch($id, $ref = null)
228 232
 	{
229 233
 		$result = $this->fetchCommon($id, $ref);
230
-		if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
234
+		if ($result > 0 && ! empty($this->table_element_line)) {
235
+		    $this->fetchLines();
236
+		}
231 237
 		return $result;
232 238
 	}
233 239
 
@@ -295,7 +301,9 @@  discard block
 block discarded – undo
295 301
 		if ($withpicto)
296 302
 		{
297 303
 			$result.=($linkstart.img_object($label, 'label', 'class="classfortooltip"').$linkend);
298
-			if ($withpicto != 2) $result.=' ';
304
+			if ($withpicto != 2) {
305
+			    $result.=' ';
306
+			}
299 307
 		}
300 308
 		$result.= $linkstart . $this->label . $linkend;
301 309
 		return $result;
@@ -337,33 +345,52 @@  discard block
 block discarded – undo
337 345
 
338 346
 		if ($mode == 0 || $mode == 1)
339 347
 		{
340
-			if ($status == 1) return $langs->trans('Enabled');
341
-			if ($status == 0) return $langs->trans('Disabled');
342
-		}
343
-		elseif ($mode == 2)
348
+			if ($status == 1) {
349
+			    return $langs->trans('Enabled');
350
+			}
351
+			if ($status == 0) {
352
+			    return $langs->trans('Disabled');
353
+			}
354
+		} elseif ($mode == 2)
344 355
 		{
345
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
346
-			if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
347
-		}
348
-		elseif ($mode == 3)
356
+			if ($status == 1) {
357
+			    return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
358
+			}
359
+			if ($status == 0) {
360
+			    return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
361
+			}
362
+		} elseif ($mode == 3)
349 363
 		{
350
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
351
-			if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
352
-		}
353
-		elseif ($mode == 4)
364
+			if ($status == 1) {
365
+			    return img_picto($langs->trans('Enabled'),'statut4');
366
+			}
367
+			if ($status == 0) {
368
+			    return img_picto($langs->trans('Disabled'),'statut5');
369
+			}
370
+		} elseif ($mode == 4)
354 371
 		{
355
-			if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
356
-			if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
357
-		}
358
-		elseif ($mode == 5)
372
+			if ($status == 1) {
373
+			    return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
374
+			}
375
+			if ($status == 0) {
376
+			    return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
377
+			}
378
+		} elseif ($mode == 5)
359 379
 		{
360
-			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
361
-			if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
362
-		}
363
-		elseif ($mode == 6)
380
+			if ($status == 1) {
381
+			    return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
382
+			}
383
+			if ($status == 0) {
384
+			    return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
385
+			}
386
+		} elseif ($mode == 6)
364 387
 		{
365
-			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
366
-			if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
388
+			if ($status == 1) {
389
+			    return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
390
+			}
391
+			if ($status == 0) {
392
+			    return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
393
+			}
367 394
 		}
368 395
 	}
369 396
 
@@ -413,8 +440,7 @@  discard block
 block discarded – undo
413 440
 			}
414 441
 
415 442
 			$this->db->free($result);
416
-		}
417
-		else
443
+		} else
418 444
 		{
419 445
 			dol_print_error($this->db);
420 446
 		}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/class/html.formwebsite.class.php 1 patch
Braces   +9 added lines, -13 removed lines patch added patch discarded remove patch
@@ -79,8 +79,7 @@  discard block
 block discarded – undo
79 79
                 if ($selected == $obj->rowid)
80 80
                 {
81 81
                     $out.='<option value="'.$obj->rowid.'" selected>';
82
-                }
83
-                else
82
+                } else
84 83
                 {
85 84
                     $out.='<option value="'.$obj->rowid.'">';
86 85
                 }
@@ -89,8 +88,7 @@  discard block
 block discarded – undo
89 88
                 $i++;
90 89
             }
91 90
             $out.="</select>";
92
-        }
93
-        else {
91
+        } else {
94 92
             dol_print_error($this->db);
95 93
         }
96 94
 
@@ -138,8 +136,7 @@  discard block
 block discarded – undo
138 136
     				if ($selected == $obj->rowid || $selected == $obj->code)
139 137
     				{
140 138
     					print '<option value="'.$obj->code.'" selected>';
141
-    				}
142
-    				else
139
+    				} else
143 140
     				{
144 141
     					print '<option value="'.$obj->code.'">';
145 142
     				}
@@ -148,14 +145,14 @@  discard block
 block discarded – undo
148 145
     				$i++;
149 146
     			}
150 147
     			print "</select>";
151
-    			if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
152
-    		}
153
-    		else
148
+    			if ($user->admin) {
149
+    			    print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
150
+    			}
151
+    		} else
154 152
     		{
155 153
     			print $langs->trans("NoTypeOfPagePleaseEditDictionary");
156 154
     		}
157
-    	}
158
-    	else {
155
+    	} else {
159 156
     		dol_print_error($this->db);
160 157
     	}
161 158
     }
@@ -191,8 +188,7 @@  discard block
 block discarded – undo
191 188
     		if ($selected == $key)
192 189
     		{
193 190
     			$out .= '<option value="'.$key.'" selected>';
194
-    		}
195
-    		else
191
+    		} else
196 192
     		{
197 193
     			$out .= '<option value="'.$key.'">';
198 194
     		}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/actions_addupdatedelete.inc.php 1 patch
Braces   +51 added lines, -29 removed lines patch added patch discarded remove patch
@@ -45,7 +45,10 @@  discard block
 block discarded – undo
45 45
 {
46 46
 	foreach ($object->fields as $key => $val)
47 47
 	{
48
-		if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue;	// Ignore special fields
48
+		if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) {
49
+		    continue;
50
+		}
51
+		// Ignore special fields
49 52
 
50 53
 		// Set value to insert
51 54
 		if (in_array($object->fields[$key]['type'], array('text', 'html'))) {
@@ -59,8 +62,14 @@  discard block
 block discarded – undo
59 62
 		} else {
60 63
 			$value = GETPOST($key,'alpha');
61 64
 		}
62
-		if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value='';		// This is an implicit foreign key field
63
-		if (! empty($object->fields[$key]['foreignkey']) && $value == '-1') $value='';					// This is an explicit foreign key field
65
+		if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') {
66
+		    $value='';
67
+		}
68
+		// This is an implicit foreign key field
69
+		if (! empty($object->fields[$key]['foreignkey']) && $value == '-1') {
70
+		    $value='';
71
+		}
72
+		// This is an explicit foreign key field
64 73
 
65 74
 		$object->$key=$value;
66 75
 		if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default']))
@@ -79,16 +88,17 @@  discard block
 block discarded – undo
79 88
 			$urltogo=$backtopage?str_replace('__ID__', $result, $backtopage):$backurlforlist;
80 89
 			header("Location: ".$urltogo);
81 90
 			exit;
82
-		}
83
-		else
91
+		} else
84 92
 		{
85 93
 			// Creation KO
86
-			if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
87
-			else  setEventMessages($object->error, null, 'errors');
94
+			if (! empty($object->errors)) {
95
+			    setEventMessages(null, $object->errors, 'errors');
96
+			} else {
97
+			    setEventMessages($object->error, null, 'errors');
98
+			}
88 99
 			$action='create';
89 100
 		}
90
-	}
91
-	else
101
+	} else
92 102
 	{
93 103
 		$action='create';
94 104
 	}
@@ -99,8 +109,14 @@  discard block
 block discarded – undo
99 109
 {
100 110
 	foreach ($object->fields as $key => $val)
101 111
 	{
102
-		if (! GETPOSTISSET($key)) continue;		// The field was not submited to be edited
103
-		if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue;	// Ignore special fields
112
+		if (! GETPOSTISSET($key)) {
113
+		    continue;
114
+		}
115
+		// The field was not submited to be edited
116
+		if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) {
117
+		    continue;
118
+		}
119
+		// Ignore special fields
104 120
 
105 121
 		// Set value to update
106 122
 		if (in_array($object->fields[$key]['type'], array('text', 'html'))) {
@@ -114,8 +130,14 @@  discard block
 block discarded – undo
114 130
 		} else {
115 131
 			$value = GETPOST($key,'alpha');
116 132
 		}
117
-		if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value='';		// This is an implicit foreign key field
118
-		if (! empty($object->fields[$key]['foreignkey']) && $value == '-1') $value='';					// This is an explicit foreign key field
133
+		if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') {
134
+		    $value='';
135
+		}
136
+		// This is an implicit foreign key field
137
+		if (! empty($object->fields[$key]['foreignkey']) && $value == '-1') {
138
+		    $value='';
139
+		}
140
+		// This is an explicit foreign key field
119 141
 
120 142
 		$object->$key=$value;
121 143
 		if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default']))
@@ -131,15 +153,13 @@  discard block
 block discarded – undo
131 153
 		if ($result > 0)
132 154
 		{
133 155
 			$action='view';
134
-		}
135
-		else
156
+		} else
136 157
 		{
137 158
 			// Creation KO
138 159
 			setEventMessages($object->error, $object->errors, 'errors');
139 160
 			$action='edit';
140 161
 		}
141
-	}
142
-	else
162
+	} else
143 163
 	{
144 164
 		$action='edit';
145 165
 	}
@@ -158,8 +178,7 @@  discard block
 block discarded – undo
158 178
 	{
159 179
 		setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
160 180
 		$action = 'view';
161
-	}
162
-	else
181
+	} else
163 182
 	{
164 183
 		setEventMessages($object->error, $object->errors, 'errors');
165 184
 		$action = 'edit_extras';
@@ -176,11 +195,13 @@  discard block
 block discarded – undo
176 195
 		setEventMessages("RecordDeleted", null, 'mesgs');
177 196
 		header("Location: ".$backurlforlist);
178 197
 		exit;
179
-	}
180
-	else
198
+	} else
181 199
 	{
182
-		if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
183
-		else setEventMessages($object->error, null, 'errors');
200
+		if (! empty($object->errors)) {
201
+		    setEventMessages(null, $object->errors, 'errors');
202
+		} else {
203
+		    setEventMessages($object->error, null, 'errors');
204
+		}
184 205
 	}
185 206
 }
186 207
 
@@ -190,8 +211,7 @@  discard block
 block discarded – undo
190 211
 	if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
191 212
 	{
192 213
 		setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
193
-	}
194
-	else
214
+	} else
195 215
 	{
196 216
 		if ($object->id > 0)
197 217
 		{
@@ -202,12 +222,14 @@  discard block
 block discarded – undo
202 222
 			if ($result > 0)
203 223
 			{
204 224
 				$newid = 0;
205
-				if (is_object($result)) $newid = $result->id;
206
-				else $newid = $result;
225
+				if (is_object($result)) {
226
+				    $newid = $result->id;
227
+				} else {
228
+				    $newid = $result;
229
+				}
207 230
 				header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid);	// Open record of new object
208 231
 				exit;
209
-			}
210
-			else
232
+			} else
211 233
 			{
212 234
 				setEventMessages($object->error, $object->errors, 'errors');
213 235
 				$object = $orig;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/actions_comments.inc.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,8 +49,7 @@  discard block
 block discarded – undo
49 49
 			setEventMessages($langs->trans("CommentAdded"), null, 'mesgs');
50 50
 			header('Location: '.$varpage.'?id='.$id.($withproject?'&withproject=1':''));
51 51
 			exit;
52
-		}
53
-		else
52
+		} else
54 53
 		{
55 54
 			setEventMessages($comment->error, $comment->errors,'errors');
56 55
 			$action='';
@@ -66,8 +65,7 @@  discard block
 block discarded – undo
66 65
 			setEventMessages($langs->trans("CommentDeleted"), null, 'mesgs');
67 66
 			header('Location: '.$varpage.'?id='.$id.($withproject?'&withproject=1':''));
68 67
 			exit;
69
-		}
70
-		else
68
+		} else
71 69
 		{
72 70
 			setEventMessages($comment->error, $comment->errors,'errors');
73 71
 			$action='';
Please login to merge, or discard this patch.