Passed
Push — master ( 49af33...3cffbe )
by Alxarafe
21:21
created
dolibarr/htdocs/margin/tabs/thirdpartyMargins.php 1 patch
Braces   +48 added lines, -27 removed lines patch added patch discarded remove patch
@@ -30,7 +30,9 @@  discard block
 block discarded – undo
30 30
 
31 31
 // Security check
32 32
 $socid = GETPOST('socid','int');
33
-if (! empty($user->societe_id)) $socid=$user->societe_id;
33
+if (! empty($user->societe_id)) {
34
+    $socid=$user->societe_id;
35
+}
34 36
 $result = restrictedArea($user, 'societe','','');
35 37
 
36 38
 
@@ -43,11 +45,17 @@  discard block
 block discarded – undo
43 45
 $offset = $conf->liste_limit * $page;
44 46
 $pageprev = $page - 1;
45 47
 $pagenext = $page + 1;
46
-if (! $sortorder) $sortorder="DESC";
47
-if (! $sortfield) $sortfield="f.datef";
48
+if (! $sortorder) {
49
+    $sortorder="DESC";
50
+}
51
+if (! $sortfield) {
52
+    $sortfield="f.datef";
53
+}
48 54
 
49 55
 $object = new Societe($db);
50
-if ($socid > 0) $object->fetch($socid);
56
+if ($socid > 0) {
57
+    $object->fetch($socid);
58
+}
51 59
 
52 60
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
53 61
 $hookmanager->initHooks(array('thirdpartymargins','globalcard'));
@@ -59,7 +67,9 @@  discard block
 block discarded – undo
59 67
 
60 68
 $parameters=array('id'=>$socid);
61 69
 $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
62
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
70
+if ($reshook < 0) {
71
+    setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
72
+}
63 73
 
64 74
 
65 75
 
@@ -71,7 +81,9 @@  discard block
 block discarded – undo
71 81
 $form = new Form($db);
72 82
 
73 83
 $title=$langs->trans("ThirdParty").' - '.$langs->trans("Margins");
74
-if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name.' - '.$langs->trans("Files");
84
+if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) {
85
+    $title=$object->name.' - '.$langs->trans("Files");
86
+}
75 87
 $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
76 88
 llxHeader('',$title,$help_url);
77 89
 
@@ -102,7 +114,9 @@  discard block
 block discarded – undo
102 114
         print '<tr><td class="titlefield">';
103 115
         print $langs->trans('CustomerCode').'</td><td colspan="3">';
104 116
         print $object->code_client;
105
-        if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
117
+        if ($object->check_codeclient() <> 0) {
118
+            print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
119
+        }
106 120
         print '</td></tr>';
107 121
     }
108 122
 
@@ -111,7 +125,9 @@  discard block
 block discarded – undo
111 125
         print '<tr><td class="titlefield">';
112 126
         print $langs->trans('SupplierCode').'</td><td colspan="3">';
113 127
         print $object->code_fournisseur;
114
-        if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
128
+        if ($object->check_codefournisseur() <> 0) {
129
+            print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
130
+        }
115 131
         print '</td></tr>';
116 132
     }
117 133
 
@@ -158,7 +174,9 @@  discard block
 block discarded – undo
158 174
     $sql.= " AND d.fk_facture = f.rowid";
159 175
     $sql.= " AND f.fk_soc = $socid";
160 176
     $sql.= " AND d.buy_price_ht IS NOT NULL";
161
-    if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0";
177
+    if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) {
178
+        $sql .= " AND d.buy_price_ht <> 0";
179
+    }
162 180
     $sql.= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut, f.type";
163 181
     $sql.= $db->order($sortfield,$sortorder);
164 182
     // TODO: calculate total to display then restore pagination
@@ -182,10 +200,12 @@  discard block
 block discarded – undo
182 200
     	print_liste_field_titre("SoldAmount",$_SERVER["PHP_SELF"],"selling_price","","&amp;socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
183 201
     	print_liste_field_titre("PurchasedAmount",$_SERVER["PHP_SELF"],"buying_price","","&amp;socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
184 202
     	print_liste_field_titre("Margin",$_SERVER["PHP_SELF"],"marge","","&amp;socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
185
-    	if (! empty($conf->global->DISPLAY_MARGIN_RATES))
186
-    		print_liste_field_titre("MarginRate",$_SERVER["PHP_SELF"],"","","&amp;socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
187
-    	if (! empty($conf->global->DISPLAY_MARK_RATES))
188
-    		print_liste_field_titre("MarkRate",$_SERVER["PHP_SELF"],"","","&amp;socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
203
+    	if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
204
+    	    		print_liste_field_titre("MarginRate",$_SERVER["PHP_SELF"],"","","&amp;socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
205
+    	}
206
+    	if (! empty($conf->global->DISPLAY_MARK_RATES)) {
207
+    	    		print_liste_field_titre("MarkRate",$_SERVER["PHP_SELF"],"","","&amp;socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
208
+    	}
189 209
     	print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&amp;socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
190 210
     	print "</tr>\n";
191 211
 
@@ -219,10 +239,12 @@  discard block
 block discarded – undo
219 239
     			print "<td align=\"right\">".price($objp->selling_price, null, null, null, null, $rounding)."</td>\n";
220 240
     			print "<td align=\"right\">".price(($objp->type == 2 ? -1 : 1) * $objp->buying_price, null, null, null, null, $rounding)."</td>\n";
221 241
     			print "<td align=\"right\">".$sign.price($objp->marge, null, null, null, null, $rounding)."</td>\n";
222
-    			if (! empty($conf->global->DISPLAY_MARGIN_RATES))
223
-    			    print "<td align=\"right\">".(($marginRate === '')?'n/a':$sign.price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
224
-    			if (! empty($conf->global->DISPLAY_MARK_RATES))
225
-    			    print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
242
+    			if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
243
+    			    			    print "<td align=\"right\">".(($marginRate === '')?'n/a':$sign.price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
244
+    			}
245
+    			if (! empty($conf->global->DISPLAY_MARK_RATES)) {
246
+    			    			    print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
247
+    			}
226 248
     			print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'</td>';
227 249
     			print "</tr>\n";
228 250
     			$i++;
@@ -238,8 +260,7 @@  discard block
 block discarded – undo
238 260
     	{
239 261
     		$marginRate = ($cumul_achat != 0)?-1*(100 * $totalMargin / $cumul_achat):'';
240 262
     		$markRate = ($cumul_vente != 0)?-1*(100 * $totalMargin / $cumul_vente):'';
241
-    	}
242
-    	else
263
+    	} else
243 264
     	{
244 265
     		$marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):'';
245 266
     		$markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):'';
@@ -251,14 +272,15 @@  discard block
 block discarded – undo
251 272
     	print "<td align=\"right\">".price($cumul_vente, null, null, null, null, $rounding)."</td>\n";
252 273
     	print "<td align=\"right\">".price($cumul_achat, null, null, null, null, $rounding)."</td>\n";
253 274
     	print "<td align=\"right\">".price($totalMargin, null, null, null, null, $rounding)."</td>\n";
254
-    	if (! empty($conf->global->DISPLAY_MARGIN_RATES))
255
-    		print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
256
-    	if (! empty($conf->global->DISPLAY_MARK_RATES))
257
-    		print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
275
+    	if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
276
+    	    		print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
277
+    	}
278
+    	if (! empty($conf->global->DISPLAY_MARK_RATES)) {
279
+    	    		print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
280
+    	}
258 281
     	print '<td align="right">&nbsp;</td>';
259 282
     	print "</tr>\n";
260
-    }
261
-    else
283
+    } else
262 284
     {
263 285
     	dol_print_error($db);
264 286
     }
@@ -267,8 +289,7 @@  discard block
 block discarded – undo
267 289
 
268 290
     print '<br>';
269 291
     $db->free($result);
270
-}
271
-else
292
+} else
272 293
 {
273 294
 	dol_print_error('', 'Parameter socid not defined');
274 295
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/margin/admin/margin.php 1 patch
Braces   +22 added lines, -26 removed lines patch added patch discarded remove patch
@@ -31,7 +31,9 @@  discard block
 block discarded – undo
31 31
 
32 32
 $langs->loadLangs(array("admin", "bills", "margins", "stocks"));
33 33
 
34
-if (! $user->admin) accessforbidden();
34
+if (! $user->admin) {
35
+    accessforbidden();
36
+}
35 37
 
36 38
 $action=GETPOST('action','alpha');
37 39
 
@@ -46,8 +48,7 @@  discard block
 block discarded – undo
46 48
     {
47 49
         header("Location: ".$_SERVER["PHP_SELF"]);
48 50
         exit;
49
-    }
50
-    else
51
+    } else
51 52
     {
52 53
         dol_print_error($db);
53 54
     }
@@ -60,8 +61,7 @@  discard block
 block discarded – undo
60 61
     {
61 62
         header("Location: ".$_SERVER["PHP_SELF"]);
62 63
         exit;
63
-    }
64
-    else
64
+    } else
65 65
     {
66 66
         dol_print_error($db);
67 67
     }
@@ -72,8 +72,7 @@  discard block
 block discarded – undo
72 72
     if (dolibarr_set_const($db, 'MARGIN_METHODE_FOR_DISCOUNT', $_POST['MARGIN_METHODE_FOR_DISCOUNT'], 'chaine', 0, '', $conf->entity) > 0)
73 73
     {
74 74
           setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
75
-    }
76
-    else
75
+    } else
77 76
     {
78 77
         dol_print_error($db);
79 78
     }
@@ -84,8 +83,7 @@  discard block
 block discarded – undo
84 83
     if (dolibarr_set_const($db, 'MARGIN_TYPE', $_POST['MARGIN_TYPE'], 'chaine', 0, '', $conf->entity) > 0)
85 84
     {
86 85
           setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
87
-    }
88
-    else
86
+    } else
89 87
     {
90 88
         dol_print_error($db);
91 89
     }
@@ -96,8 +94,7 @@  discard block
 block discarded – undo
96 94
     if (dolibarr_set_const($db, 'AGENT_CONTACT_TYPE', $_POST['AGENT_CONTACT_TYPE'], 'chaine', 0, '', $conf->entity) > 0)
97 95
     {
98 96
           setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
99
-    }
100
-    else
97
+    } else
101 98
     {
102 99
         dol_print_error($db);
103 100
     }
@@ -136,18 +133,23 @@  discard block
 block discarded – undo
136 133
 print '<td>'.$langs->trans("MARGIN_TYPE").'</td>';
137 134
 print '<td>';
138 135
 print ' <input type="radio" name="MARGIN_TYPE" value="1" ';
139
-if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1')
136
+if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1') {
140 137
 	print 'checked ';
138
+}
141 139
 print '/> ';
142 140
 print $langs->trans('MargeType1');
143 141
 print '<br>';
144 142
 print ' <input type="radio" name="MARGIN_TYPE" value="pmp" ';
145
-if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'pmp') print 'checked ';
143
+if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'pmp') {
144
+    print 'checked ';
145
+}
146 146
 print '/> ';
147 147
 print $langs->trans('MargeType2');
148 148
 print '<br>';
149 149
 print ' <input type="radio" name="MARGIN_TYPE" value="costprice" ';
150
-if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'costprice') print 'checked ';
150
+if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'costprice') {
151
+    print 'checked ';
152
+}
151 153
 print '/> ';
152 154
 print $langs->trans('MargeType3');
153 155
 print '</td>';
@@ -166,14 +168,12 @@  discard block
 block discarded – undo
166 168
 if (! empty($conf->use_javascript_ajax))
167 169
 {
168 170
 	print ajax_constantonoff('DISPLAY_MARGIN_RATES');
169
-}
170
-else
171
+} else
171 172
 {
172 173
 	if (empty($conf->global->DISPLAY_MARGIN_RATES))
173 174
 	{
174 175
 		print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_DISPLAY_MARGIN_RATES">'.img_picto($langs->trans("Disabled"),'off').'</a>';
175
-	}
176
-	else
176
+	} else
177 177
 	{
178 178
 		print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_DISPLAY_MARGIN_RATES">'.img_picto($langs->trans("Enabled"),'on').'</a>';
179 179
 	}
@@ -189,14 +189,12 @@  discard block
 block discarded – undo
189 189
 if (! empty($conf->use_javascript_ajax))
190 190
 {
191 191
 	print ajax_constantonoff('DISPLAY_MARK_RATES');
192
-}
193
-else
192
+} else
194 193
 {
195 194
 	if (empty($conf->global->DISPLAY_MARK_RATES))
196 195
 	{
197 196
 		print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_DISPLAY_MARK_RATES">'.img_picto($langs->trans("Disabled"),'off').'</a>';
198
-	}
199
-	else
197
+	} else
200 198
 	{
201 199
 		print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_DISPLAY_MARK_RATES">'.img_picto($langs->trans("Enabled"),'on').'</a>';
202 200
 	}
@@ -212,14 +210,12 @@  discard block
 block discarded – undo
212 210
 if (! empty($conf->use_javascript_ajax))
213 211
 {
214 212
 	print ajax_constantonoff('ForceBuyingPriceIfNull');
215
-}
216
-else
213
+} else
217 214
 {
218 215
 	if (empty($conf->global->ForceBuyingPriceIfNull))
219 216
 	{
220 217
 		print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_ForceBuyingPriceIfNull">'.img_picto($langs->trans("Disabled"),'off').'</a>';
221
-	}
222
-	else
218
+	} else
223 219
 	{
224 220
 		print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_ForceBuyingPriceIfNull">'.img_picto($langs->trans("Enabled"),'on').'</a>';
225 221
 	}
Please login to merge, or discard this patch.
dolibarr/htdocs/margin/customerMargins.php 1 patch
Braces   +84 added lines, -51 removed lines patch added patch discarded remove patch
@@ -36,7 +36,9 @@  discard block
 block discarded – undo
36 36
 $TSelectedProducts = GETPOST('products', 'array');
37 37
 $TSelectedCats = GETPOST('categories', 'array');
38 38
 
39
-if (! empty($user->societe_id)) $socid=$user->societe_id;
39
+if (! empty($user->societe_id)) {
40
+    $socid=$user->societe_id;
41
+}
40 42
 $result = restrictedArea($user, 'societe','','');
41 43
 $result = restrictedArea($user,'margins');
42 44
 
@@ -52,15 +54,22 @@  discard block
 block discarded – undo
52 54
 $offset = $limit * $page;
53 55
 $pageprev = $page - 1;
54 56
 $pagenext = $page + 1;
55
-if (! $sortfield) $sortfield="s.nom"; // Set here default search field
56
-if (! $sortorder) $sortorder="ASC";
57
+if (! $sortfield) {
58
+    $sortfield="s.nom";
59
+}
60
+// Set here default search field
61
+if (! $sortorder) {
62
+    $sortorder="ASC";
63
+}
57 64
 
58 65
 $startdate=$enddate='';
59 66
 
60
-if (!empty($_POST['startdatemonth']))
67
+if (!empty($_POST['startdatemonth'])) {
61 68
   $startdate  = dol_mktime(0, 0, 0, $_POST['startdatemonth'],  $_POST['startdateday'],  $_POST['startdateyear']);
62
-if (!empty($_POST['enddatemonth']))
69
+}
70
+if (!empty($_POST['enddatemonth'])) {
63 71
   $enddate  = dol_mktime(23, 59, 59, $_POST['enddatemonth'],  $_POST['enddateday'],  $_POST['enddateyear']);
72
+}
64 73
 
65 74
 
66 75
 /*
@@ -104,11 +113,14 @@  discard block
 block discarded – undo
104 113
 		print '</td></tr>';
105 114
 
106 115
 		$client = true;
107
-		if (! $sortorder) $sortorder="DESC";
108
-		if (! $sortfield) $sortfield="f.datef";
116
+		if (! $sortorder) {
117
+		    $sortorder="DESC";
118
+		}
119
+		if (! $sortfield) {
120
+		    $sortfield="f.datef";
121
+		}
109 122
 	}
110
-}
111
-else {
123
+} else {
112 124
 	print '<tr><td class="titlefield">'.$langs->trans('ThirdPartyName').'</td>';
113 125
 	print '<td class="maxwidthonsmartphone" colspan="4">';
114 126
 	print $form->select_company(null, 'socid', 'client=1 OR client=3', 1, 0, 0);
@@ -118,15 +130,16 @@  discard block
 block discarded – undo
118 130
 
119 131
 $sortfield = GETPOST("sortfield",'alpha');
120 132
 $sortorder = GETPOST("sortorder",'alpha');
121
-if (! $sortorder) $sortorder="ASC";
133
+if (! $sortorder) {
134
+    $sortorder="ASC";
135
+}
122 136
 if (! $sortfield)
123 137
 {
124 138
 	if ($client)
125 139
 	{
126 140
 		$sortfield="f.datef";
127 141
 		$sortorder="DESC";
128
-	}
129
-	else
142
+	} else
130 143
 	{
131 144
 	    $sortfield="s.nom";
132 145
 	    $sortorder="ASC";
@@ -202,7 +215,9 @@  discard block
 block discarded – undo
202 215
 
203 216
 $sql = "SELECT";
204 217
 $sql.= " s.rowid as socid, s.nom as name, s.code_client, s.client,";
205
-if ($client) $sql.= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,";
218
+if ($client) {
219
+    $sql.= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,";
220
+}
206 221
 $sql.= " sum(d.total_ht) as selling_price,";
207 222
 // Note: qty and buy_price_ht is always positive (if not, your database may be corrupted, you can update this)
208 223
 $sql.= " sum(".$db->ifsql('d.total_ht < 0','d.qty * d.buy_price_ht * -1','d.qty * d.buy_price_ht').") as buying_price,";
@@ -214,10 +229,16 @@  discard block
 block discarded – undo
214 229
 	$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=d.fk_product';
215 230
 }
216 231
 
217
-if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
232
+if (! $user->rights->societe->client->voir && ! $socid) {
233
+    $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
234
+}
218 235
 $sql.= " WHERE f.fk_soc = s.rowid";
219
-if ($socid > 0) $sql.= ' AND s.rowid = '.$socid;
220
-if (!$user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
236
+if ($socid > 0) {
237
+    $sql.= ' AND s.rowid = '.$socid;
238
+}
239
+if (!$user->rights->societe->client->voir && ! $socid) {
240
+    $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
241
+}
221 242
 $sql.= " AND f.fk_statut > 0";
222 243
 $sql.= ' AND s.entity IN ('.getEntity('societe').')';
223 244
 $sql.= " AND d.fk_facture = f.rowid";
@@ -228,15 +249,21 @@  discard block
 block discarded – undo
228 249
 if(! empty($TSelectedCats)) {
229 250
 	$sql .= ' AND cp.fk_categorie IN ('.implode(',', $TSelectedCats) . ')';
230 251
 }
231
-if (!empty($startdate))
232
-$sql.= " AND f.datef >= '".$db->idate($startdate)."'";
233
-if (!empty($enddate))
234
-$sql.= " AND f.datef <= '".$db->idate($enddate)."'";
252
+if (!empty($startdate)) {
253
+    $sql.= " AND f.datef >= '".$db->idate($startdate)."'";
254
+}
255
+if (!empty($enddate)) {
256
+    $sql.= " AND f.datef <= '".$db->idate($enddate)."'";
257
+}
235 258
 $sql .= " AND d.buy_price_ht IS NOT NULL";
236
-if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)
237
-$sql .= " AND d.buy_price_ht <> 0";
238
-if ($client) $sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut";
239
-else $sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client";
259
+if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) {
260
+    $sql .= " AND d.buy_price_ht <> 0";
261
+}
262
+if ($client) {
263
+    $sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut";
264
+} else {
265
+    $sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client";
266
+}
240 267
 $sql.=$db->order($sortfield,$sortorder);
241 268
 // TODO: calculate total to display then restore pagination
242 269
 //$sql.= $db->plimit($conf->liste_limit +1, $offset);
@@ -250,10 +277,12 @@  discard block
 block discarded – undo
250 277
   	print '<br>';
251 278
 	print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1);
252 279
 
253
-	if ($conf->global->MARGIN_TYPE == "1")
254
-	    $labelcostprice='BuyingPrice';
255
-	else   // value is 'costprice' or 'pmp'
280
+	if ($conf->global->MARGIN_TYPE == "1") {
281
+		    $labelcostprice='BuyingPrice';
282
+	} else {
283
+	    // value is 'costprice' or 'pmp'
256 284
 	    $labelcostprice='CostPrice';
285
+	}
257 286
 
258 287
 	$i = 0;
259 288
 	print "<table class=\"noborder\" width=\"100%\">";
@@ -262,16 +291,18 @@  discard block
 block discarded – undo
262 291
 	if (! empty($client)) {
263 292
   		print_liste_field_titre("Invoice",$_SERVER["PHP_SELF"],"f.ref","","&amp;socid=".$socid,'',$sortfield,$sortorder);
264 293
   		print_liste_field_titre("DateInvoice",$_SERVER["PHP_SELF"],"f.datef","","&amp;socid=".$socid,'align="center"',$sortfield,$sortorder);
294
+	} else {
295
+	  		print_liste_field_titre("Customer",$_SERVER["PHP_SELF"],"s.nom","","&amp;socid=".$socid,'',$sortfield,$sortorder);
265 296
 	}
266
-	else
267
-  		print_liste_field_titre("Customer",$_SERVER["PHP_SELF"],"s.nom","","&amp;socid=".$socid,'',$sortfield,$sortorder);
268 297
 	print_liste_field_titre("SellingPrice",$_SERVER["PHP_SELF"],"selling_price","","&amp;socid=".$socid,'align="right"',$sortfield,$sortorder);
269 298
 	print_liste_field_titre($labelcostprice,$_SERVER["PHP_SELF"],"buying_price","","&amp;socid=".$socid,'align="right"',$sortfield,$sortorder);
270 299
 	print_liste_field_titre("Margin",$_SERVER["PHP_SELF"],"marge","","&amp;socid=".$socid,'align="right"',$sortfield,$sortorder);
271
-	if (! empty($conf->global->DISPLAY_MARGIN_RATES))
272
-		print_liste_field_titre("MarginRate",$_SERVER["PHP_SELF"],"","","&amp;socid=".$socid,'align="right"',$sortfield,$sortorder);
273
-	if (! empty($conf->global->DISPLAY_MARK_RATES))
274
-		print_liste_field_titre("MarkRate",$_SERVER["PHP_SELF"],"","","&amp;socid=".$socid,'align="right"',$sortfield,$sortorder);
300
+	if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
301
+			print_liste_field_titre("MarginRate",$_SERVER["PHP_SELF"],"","","&amp;socid=".$socid,'align="right"',$sortfield,$sortorder);
302
+	}
303
+	if (! empty($conf->global->DISPLAY_MARK_RATES)) {
304
+			print_liste_field_titre("MarkRate",$_SERVER["PHP_SELF"],"","","&amp;socid=".$socid,'align="right"',$sortfield,$sortorder);
305
+	}
275 306
 	print "</tr>\n";
276 307
 
277 308
 	$cumul_achat = 0;
@@ -293,8 +324,7 @@  discard block
 block discarded – undo
293 324
 			{
294 325
 				$marginRate = ($pa != 0)?-1*(100 * $marge / $pa):'' ;
295 326
 				$markRate = ($pv != 0)?-1*(100 * $marge / $pv):'' ;
296
-			}
297
-			else
327
+			} else
298 328
 			{
299 329
 				$marginRate = ($pa != 0)?(100 * $marge / $pa):'' ;
300 330
 				$markRate = ($pv != 0)?(100 * $marge / $pv):'' ;
@@ -309,8 +339,7 @@  discard block
 block discarded – undo
309 339
 				print "</td>\n";
310 340
 				print "<td align=\"center\">";
311 341
 				print dol_print_date($db->jdate($objp->datef),'day')."</td>";
312
-		  	}
313
-		  	else {
342
+		  	} else {
314 343
 				$companystatic->id=$objp->socid;
315 344
 				$companystatic->name=$objp->name;
316 345
 				$companystatic->client=$objp->client;
@@ -320,10 +349,12 @@  discard block
 block discarded – undo
320 349
 			print "<td align=\"right\">".price($pv, null, null, null, null, $rounding)."</td>\n";
321 350
 			print "<td align=\"right\">".price($pa, null, null, null, null, $rounding)."</td>\n";
322 351
 			print "<td align=\"right\">".price($marge, null, null, null, null, $rounding)."</td>\n";
323
-			if (! empty($conf->global->DISPLAY_MARGIN_RATES))
324
-				print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
325
-			if (! empty($conf->global->DISPLAY_MARK_RATES))
326
-				print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
352
+			if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
353
+							print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
354
+			}
355
+			if (! empty($conf->global->DISPLAY_MARK_RATES)) {
356
+							print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
357
+			}
327 358
 			print "</tr>\n";
328 359
 
329 360
 			$i++;
@@ -347,23 +378,25 @@  discard block
 block discarded – undo
347 378
 	//}
348 379
 
349 380
 	print '<tr class="liste_total">';
350
-	if ($client)
351
-	    print '<td colspan=2>';
352
-  	else
353
-    	print '<td>';
381
+	if ($client) {
382
+		    print '<td colspan=2>';
383
+	} else {
384
+  	    	print '<td>';
385
+  	}
354 386
   	print $langs->trans('TotalMargin')."</td>";
355 387
 	print "<td align=\"right\">".price($cumul_vente, null, null, null, null, $rounding)."</td>\n";
356 388
 	print "<td align=\"right\">".price($cumul_achat, null, null, null, null, $rounding)."</td>\n";
357 389
 	print "<td align=\"right\">".price($totalMargin, null, null, null, null, $rounding)."</td>\n";
358
-	if (! empty($conf->global->DISPLAY_MARGIN_RATES))
359
-		print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
360
-	if (! empty($conf->global->DISPLAY_MARK_RATES))
361
-		print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
390
+	if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
391
+			print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."</td>\n";
392
+	}
393
+	if (! empty($conf->global->DISPLAY_MARK_RATES)) {
394
+			print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."</td>\n";
395
+	}
362 396
 	print "</tr>\n";
363 397
 
364 398
   print "</table>";
365
-}
366
-else
399
+} else
367 400
 {
368 401
 	dol_print_error($db);
369 402
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/margin/checkMargins.php 1 patch
Braces   +47 added lines, -17 removed lines patch added patch discarded remove patch
@@ -48,8 +48,12 @@  discard block
 block discarded – undo
48 48
 $offset = $limit * $page;
49 49
 $pageprev = $page - 1;
50 50
 $pagenext = $page + 1;
51
-if (! $sortorder) $sortorder = "DESC";
52
-if (! $sortfield) $sortfield = 'f.ref';
51
+if (! $sortorder) {
52
+    $sortorder = "DESC";
53
+}
54
+if (! $sortfield) {
55
+    $sortfield = 'f.ref';
56
+}
53 57
 
54 58
 $startdate = $enddate = '';
55 59
 
@@ -78,7 +82,9 @@  discard block
 block discarded – undo
78 82
 
79 83
 $parameters=array();
80 84
 $reshook=$hookmanager->executeHooks('doActions',$parameters, $object, $action);    // Note that $action and $object may have been modified by some hooks
81
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
85
+if ($reshook < 0) {
86
+    setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
87
+}
82 88
 
83 89
 if (empty($reshook))
84 90
 {
@@ -108,9 +114,11 @@  discard block
 block discarded – undo
108 114
     }
109 115
 
110 116
     // Purge search criteria
111
-    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
117
+    if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) {
118
+        // All tests are required to be compatible with all browsers
112 119
     {
113 120
         $search_ref='';
121
+    }
114 122
         $search_array_options=array();
115 123
     }
116 124
 
@@ -146,12 +154,24 @@  discard block
 block discarded – undo
146 154
 // print_fiche_titre($text);
147 155
 
148 156
 $param='';
149
-if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
150
-if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
151
-if ($search_ref != '')   $param.='&search_ref='.urlencode($search_ref);
152
-if (! empty($startdate)) $param .= '&startdatemonth=' . GETPOST('startdatemonth', 'int') . '&startdateday=' . GETPOST('startdateday', 'int') . '&startdateyear=' . GETPOST('startdateyear', 'int');
153
-if (! empty($enddate))   $param .= '&enddatemonth=' . GETPOST('enddatemonth', 'int') . '&enddateday=' . GETPOST('enddateday', 'int') . '&enddateyear=' . GETPOST('enddateyear', 'int');
154
-if ($optioncss != '')    $param.='&optioncss='.$optioncss;
157
+if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
158
+    $param.='&contextpage='.$contextpage;
159
+}
160
+if ($limit > 0 && $limit != $conf->liste_limit) {
161
+    $param.='&limit='.$limit;
162
+}
163
+if ($search_ref != '') {
164
+    $param.='&search_ref='.urlencode($search_ref);
165
+}
166
+if (! empty($startdate)) {
167
+    $param .= '&startdatemonth=' . GETPOST('startdatemonth', 'int') . '&startdateday=' . GETPOST('startdateday', 'int') . '&startdateyear=' . GETPOST('startdateyear', 'int');
168
+}
169
+if (! empty($enddate)) {
170
+    $param .= '&enddatemonth=' . GETPOST('enddatemonth', 'int') . '&enddateday=' . GETPOST('enddateday', 'int') . '&enddateyear=' . GETPOST('enddateyear', 'int');
171
+}
172
+if ($optioncss != '') {
173
+    $param.='&optioncss='.$optioncss;
174
+}
155 175
 
156 176
 // Show tabs
157 177
 $head = marges_prepare_head($user);
@@ -192,9 +212,15 @@  discard block
 block discarded – undo
192 212
 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON d.fk_product = p.rowid";
193 213
 $sql .= " WHERE f.fk_statut > 0";
194 214
 $sql .= " AND f.entity IN (" . getEntity('invoice') . ") ";
195
-if (! empty($startdate)) $sql .= " AND f.datef >= '" . $db->idate($startdate) . "'";
196
-if (! empty($enddate))   $sql .= " AND f.datef <= '" . $db->idate($enddate) . "'";
197
-if ($search_ref) $sql.=natural_search('f.ref', $search_ref);
215
+if (! empty($startdate)) {
216
+    $sql .= " AND f.datef >= '" . $db->idate($startdate) . "'";
217
+}
218
+if (! empty($enddate)) {
219
+    $sql .= " AND f.datef <= '" . $db->idate($enddate) . "'";
220
+}
221
+if ($search_ref) {
222
+    $sql.=natural_search('f.ref', $search_ref);
223
+}
198 224
 $sql .= " AND d.buy_price_ht IS NOT NULL";
199 225
 $sql .= $db->order($sortfield, $sortorder);
200 226
 
@@ -204,9 +230,11 @@  discard block
 block discarded – undo
204 230
 	dol_syslog(__FILE__, LOG_DEBUG);
205 231
 	$result = $db->query($sql);
206 232
 	$nbtotalofrecords = $db->num_rows($result);
207
-	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
233
+	if (($page * $limit) > $nbtotalofrecords) {
234
+	    // if total resultset is smaller then paging size (filtering), goto and load page 0
208 235
 	{
209 236
 		$page = 0;
237
+	}
210 238
 		$offset = 0;
211 239
 	}
212 240
 }
@@ -220,10 +248,12 @@  discard block
 block discarded – undo
220 248
 	print '<br>';
221 249
 	print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit);
222 250
 
223
-	if ($conf->global->MARGIN_TYPE == "1")
224
-	    $labelcostprice='BuyingPrice';
225
-	else   // value is 'costprice' or 'pmp'
251
+	if ($conf->global->MARGIN_TYPE == "1") {
252
+		    $labelcostprice='BuyingPrice';
253
+	} else {
254
+	    // value is 'costprice' or 'pmp'
226 255
 	    $labelcostprice='CostPrice';
256
+	}
227 257
 
228 258
 	$moreforfilter='';
229 259
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/actions_setmoduleoptions.inc.php 1 patch
Braces   +26 added lines, -13 removed lines patch added patch discarded remove patch
@@ -45,12 +45,15 @@  discard block
 block discarded – undo
45 45
 	if (! $error)
46 46
 	{
47 47
 		$db->commit();
48
-		if (empty($nomessageinupdate)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
49
-	}
50
-	else
48
+		if (empty($nomessageinupdate)) {
49
+		    setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
50
+		}
51
+	} else
51 52
 	{
52 53
 		$db->rollback();
53
-		if (empty($nomessageinupdate)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors');
54
+		if (empty($nomessageinupdate)) {
55
+		    setEventMessages($langs->trans("SetupNotSaved"), null, 'errors');
56
+		}
54 57
 	}
55 58
 }
56 59
 
@@ -64,14 +67,18 @@  discard block
 block discarded – undo
64 67
     {
65 68
         foreach($_POST as $key => $val)
66 69
         {
67
-            if (preg_match('/^param(\d*)$/', $key, $reg))    // Works for POST['param'], POST['param1'], POST['param2'], ...
70
+            if (preg_match('/^param(\d*)$/', $key, $reg)) {
71
+                // Works for POST['param'], POST['param1'], POST['param2'], ...
68 72
             {
69 73
                 $param=GETPOST("param".$reg[1],'alpha');
74
+            }
70 75
                 $value=GETPOST("value".$reg[1],'alpha');
71 76
                 if ($param)
72 77
                 {
73 78
                     $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
74
-                    if (! $res > 0) $error++;
79
+                    if (! $res > 0) {
80
+                        $error++;
81
+                    }
75 82
                 }
76 83
             }
77 84
         }
@@ -90,8 +97,9 @@  discard block
 block discarded – undo
90 97
             if (! $tmpdir) {
91 98
                 unset($listofdir[$key]); continue;
92 99
             }
93
-            if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
94
-            else
100
+            if (! is_dir($tmpdir)) {
101
+                $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
102
+            } else
95 103
             {
96 104
                 $upload_dir=$tmpdir;
97 105
             }
@@ -99,19 +107,24 @@  discard block
 block discarded – undo
99 107
         if ($upload_dir)
100 108
         {
101 109
             $result = dol_add_file_process($upload_dir, 0, 1, 'uploadfile', '');
102
-            if ($result <= 0) $error++;
110
+            if ($result <= 0) {
111
+                $error++;
112
+            }
103 113
         }
104 114
     }
105 115
 
106 116
     if (! $error)
107 117
     {
108 118
         $db->commit();
109
-        if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
110
-    }
111
-    else
119
+        if (empty($nomessageinsetmoduleoptions)) {
120
+            setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
121
+        }
122
+    } else
112 123
     {
113 124
         $db->rollback();
114
-        if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors');
125
+        if (empty($nomessageinsetmoduleoptions)) {
126
+            setEventMessages($langs->trans("SetupNotSaved"), null, 'errors');
127
+        }
115 128
     }
116 129
 }
117 130
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/class/infobox.class.php 1 patch
Braces   +36 added lines, -23 removed lines patch added patch discarded remove patch
@@ -55,19 +55,25 @@  discard block
 block discarded – undo
55 55
         $boxes=array();
56 56
 
57 57
         $confuserzone='MAIN_BOXES_'.$zone;
58
-        if ($mode == 'activated')	// activated
58
+        if ($mode == 'activated') {
59
+            // activated
59 60
         {
60 61
             $sql = "SELECT b.rowid, b.position, b.box_order, b.fk_user,";
62
+        }
61 63
             $sql.= " d.rowid as box_id, d.file, d.note, d.tms";
62 64
             $sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d";
63 65
             $sql.= " WHERE b.box_id = d.rowid";
64 66
             $sql.= " AND b.entity IN (0,".$conf->entity.")";
65
-            if ($zone >= 0) $sql.= " AND b.position = ".$zone;
66
-            if (is_object($user)) $sql.= " AND b.fk_user IN (0,".$user->id.")";
67
-            else $sql.= " AND b.fk_user = 0";
67
+            if ($zone >= 0) {
68
+                $sql.= " AND b.position = ".$zone;
69
+            }
70
+            if (is_object($user)) {
71
+                $sql.= " AND b.fk_user IN (0,".$user->id.")";
72
+            } else {
73
+                $sql.= " AND b.fk_user = 0";
74
+            }
68 75
             $sql.= " ORDER BY b.box_order";
69
-        }
70
-        else	// available
76
+        } else	// available
71 77
 		{
72 78
             $sql = "SELECT d.rowid as box_id, d.file, d.note, d.tms";
73 79
             $sql.= " FROM ".MAIN_DB_PREFIX."boxes_def as d";
@@ -92,8 +98,7 @@  discard block
 block discarded – undo
92 98
                         $boxname = preg_replace('/\.php$/i','',$regs[1]);
93 99
                         $module = $regs[2];
94 100
                         $relsourcefile = "/".$module."/core/boxes/".$boxname.".php";
95
-                    }
96
-                    else
101
+                    } else
97 102
                     {
98 103
                         $boxname=preg_replace('/\.php$/i','',$obj->file);
99 104
                         $relsourcefile = "/core/boxes/".$boxname.".php";
@@ -119,12 +124,15 @@  discard block
 block discarded – undo
119 124
                         $box->sourcefile= $relsourcefile;
120 125
                     	$box->class     = $boxname;
121 126
 
122
-                    	if ($mode == 'activated' && ! is_object($user))	// List of activated box was not yet personalized into database
127
+                    	if ($mode == 'activated' && ! is_object($user)) {
128
+                    	    // List of activated box was not yet personalized into database
123 129
                         {
124 130
                             if (is_numeric($box->box_order))
125 131
                             {
126 132
                                 if ($box->box_order % 2 == 1) $box->box_order='A'.$box->box_order;
127
-                                elseif ($box->box_order % 2 == 0) $box->box_order='B'.$box->box_order;
133
+                    	} elseif ($box->box_order % 2 == 0) {
134
+                                    $box->box_order='B'.$box->box_order;
135
+                                }
128 136
                             }
129 137
                         }
130 138
                         // box_def properties
@@ -143,12 +151,16 @@  discard block
 block discarded – undo
143 151
                             	foreach($arrayelem as $module)
144 152
                             	{
145 153
     	                        	$tmpmodule=preg_replace('/@[^@]+/','',$module);
146
-    	                        	if (! empty($conf->$tmpmodule->enabled)) $tmpenabled=1;
154
+    	                        	if (! empty($conf->$tmpmodule->enabled)) {
155
+    	                        	    $tmpenabled=1;
156
+    	                        	}
147 157
                             		//print $boxname.'-'.$module.'-module enabled='.(empty($conf->$tmpmodule->enabled)?0:1).'<br>';
148 158
                             	}
149
-                            	if (empty($tmpenabled))	// We found at least one module required that is disabled
159
+                            	if (empty($tmpenabled)) {
160
+                            	    // We found at least one module required that is disabled
150 161
         	                    {
151 162
         	                    	$enabled=0;
163
+                            	}
152 164
         	                    	break;
153 165
         	                    }
154 166
                             }
@@ -156,18 +168,19 @@  discard block
 block discarded – undo
156 168
                         //print '=>'.$boxname.'-enabled='.$enabled.'<br>';
157 169
 
158 170
                         //print 'xx module='.$module.' enabled='.$enabled;
159
-                        if ($enabled && ($includehidden || empty($box->hidden))) $boxes[]=$box;
160
-                        else unset($box);
161
-                    }
162
-                    else
171
+                        if ($enabled && ($includehidden || empty($box->hidden))) {
172
+                            $boxes[]=$box;
173
+                        } else {
174
+                            unset($box);
175
+                        }
176
+                    } else
163 177
 					{
164 178
                     	dol_syslog("Failed to load box '".$boxname."' into file '".$relsourcefile."'", LOG_WARNING);
165 179
 					}
166 180
                 }
167 181
                 $j++;
168 182
             }
169
-        }
170
-        else
183
+        } else
171 184
 		{
172 185
 			dol_syslog($db->lasterror(),LOG_ERR);
173 186
             return array('error'=>$db->lasterror());
@@ -196,7 +209,9 @@  discard block
 block discarded – undo
196 209
 
197 210
         dol_syslog(get_class()."::saveboxorder zone=".$zone." userid=".$userid);
198 211
 
199
-        if (! $userid || $userid == 0) return 0;
212
+        if (! $userid || $userid == 0) {
213
+            return 0;
214
+        }
200 215
 
201 216
         $user = new User($db);
202 217
         $user->id=$userid;
@@ -266,14 +281,12 @@  discard block
 block discarded – undo
266 281
                 $error=$db->error();
267 282
                 $db->rollback();
268 283
                 return -2;
269
-            }
270
-            else
284
+            } else
271 285
             {
272 286
                 $db->commit();
273 287
                 return 1;
274 288
             }
275
-        }
276
-        else
289
+        } else
277 290
         {
278 291
             $error=$db->lasterror();
279 292
             $db->rollback();
Please login to merge, or discard this patch.
dolibarr/htdocs/core/class/html.formintervention.class.php 1 patch
Braces   +15 added lines, -12 removed lines patch added patch discarded remove patch
@@ -75,8 +75,11 @@  discard block
 block discarded – undo
75 75
 		$sql.= " WHERE f.entity = ".$conf->entity;
76 76
 		if ($socid != '')
77 77
 		{
78
-			if ($socid == '0') $sql.= " AND (f.fk_soc = 0 OR f.fk_soc IS NULL)";
79
-			else $sql.= " AND f.fk_soc = ".$socid;
78
+			if ($socid == '0') {
79
+			    $sql.= " AND (f.fk_soc = 0 OR f.fk_soc IS NULL)";
80
+			} else {
81
+			    $sql.= " AND f.fk_soc = ".$socid;
82
+			}
80 83
 		}
81 84
 
82 85
 		dol_syslog(get_class($this)."::select_intervention", LOG_DEBUG);
@@ -84,7 +87,9 @@  discard block
 block discarded – undo
84 87
 		if ($resql)
85 88
 		{
86 89
 			$out.='<select id="interventionid" class="flat" name="'.$htmlname.'">';
87
-			if ($showempty) $out.='<option value="0">&nbsp;</option>';
90
+			if ($showempty) {
91
+			    $out.='<option value="0">&nbsp;</option>';
92
+			}
88 93
 			$num = $db->num_rows($resql);
89 94
 			$i = 0;
90 95
 			if ($num)
@@ -96,15 +101,13 @@  discard block
 block discarded – undo
96 101
 					if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire)
97 102
 					{
98 103
 						// Do nothing
99
-					}
100
-					else
104
+					} else
101 105
 					{
102 106
 						$labeltoshow=dol_trunc($obj->ref,18);
103 107
 						if (!empty($selected) && $selected == $obj->rowid && $obj->statut > 0)
104 108
 						{
105 109
 							$out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';
106
-						}
107
-						else
110
+						} else
108 111
 						{
109 112
 							$disabled=0;
110 113
 							if (! $obj->fk_statut > 0)
@@ -121,11 +124,12 @@  discard block
 block discarded – undo
121 124
 							if ($hideunselectables && $disabled)
122 125
 							{
123 126
 								$resultat='';
124
-							}
125
-							else
127
+							} else
126 128
 							{
127 129
 								$resultat='<option value="'.$obj->rowid.'"';
128
-								if ($disabled) $resultat.=' disabled';
130
+								if ($disabled) {
131
+								    $resultat.=' disabled';
132
+								}
129 133
 								$resultat.='>'.$labeltoshow;
130 134
 								$resultat.='</option>';
131 135
 							}
@@ -138,8 +142,7 @@  discard block
 block discarded – undo
138 142
 			$out.='</select>';
139 143
 			$db->free($resql);
140 144
 			return $out;
141
-		}
142
-		else
145
+		} else
143 146
 		{
144 147
 			dol_print_error($db);
145 148
 			return '';
Please login to merge, or discard this patch.
dolibarr/htdocs/core/class/interfaces.class.php 1 patch
Braces   +72 added lines, -35 removed lines patch added patch discarded remove patch
@@ -69,20 +69,26 @@  discard block
 block discarded – undo
69 69
     {
70 70
         // phpcs:enable
71 71
         // Check parameters
72
-        if (! is_object($object) || ! is_object($conf))	// Error
72
+        if (! is_object($object) || ! is_object($conf)) {
73
+            // Error
73 74
         {
74 75
         	$this->error='function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf);
76
+        }
75 77
             dol_syslog(get_class($this).'::run_triggers '.$this->error, LOG_ERR);
76 78
         	$this->errors[]=$this->error;
77 79
             return -1;
78 80
         }
79
-        if (! is_object($langs))	// Warning
81
+        if (! is_object($langs)) {
82
+            // Warning
80 83
         {
81 84
             dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING);
82 85
         }
83
-        if (! is_object($user))	    // Warning
86
+        }
87
+        if (! is_object($user)) {
88
+            // Warning
84 89
         {
85 90
             dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING);
91
+        }
86 92
             global $db;
87 93
             $user = new User($db);
88 94
         }
@@ -102,7 +108,9 @@  discard block
 block discarded – undo
102 108
             //print "xx".$dir;exit;
103 109
 
104 110
             // Check if directory exists (we do not use dol_is_dir to avoir loading files.lib.php at each call)
105
-            if (! is_dir($newdir)) continue;
111
+            if (! is_dir($newdir)) {
112
+                continue;
113
+            }
106 114
 
107 115
             $handle=opendir($newdir);
108 116
             if (is_resource($handle))
@@ -118,14 +126,18 @@  discard block
 block discarded – undo
118 126
                         $nbfile++;
119 127
 
120 128
                         // Check if trigger file is disabled by name
121
-                        if (preg_match('/NORUN$/i',$file)) continue;
129
+                        if (preg_match('/NORUN$/i',$file)) {
130
+                            continue;
131
+                        }
122 132
                         // Check if trigger file is for a particular module
123 133
                         $qualified=true;
124 134
                         if (strtolower($reg[2]) != 'all')
125 135
                         {
126 136
                             $module=preg_replace('/^mod/i','',$reg[2]);
127 137
                             $constparam='MAIN_MODULE_'.strtoupper($module);
128
-                            if (empty($conf->global->$constparam)) $qualified=false;
138
+                            if (empty($conf->global->$constparam)) {
139
+                                $qualified=false;
140
+                            }
129 141
                         }
130 142
 
131 143
                         if (! $qualified)
@@ -136,9 +148,11 @@  discard block
 block discarded – undo
136 148
 
137 149
                         $modName = "Interface".ucfirst($reg[3]);
138 150
                         //print "file=$file - modName=$modName\n";
139
-                        if (in_array($modName,$modules))    // $modules = list of modName already loaded
151
+                        if (in_array($modName,$modules)) {
152
+                            // $modules = list of modName already loaded
140 153
                         {
141 154
                             $langs->load("errors");
155
+                        }
142 156
                             dol_syslog(get_class($this)."::run_triggers action=".$action." ".$langs->trans("ErrorDuplicateTrigger", $newdir."/".$file, $fullpathfiles[$modName]), LOG_WARNING);
143 157
                             continue;
144 158
                         }
@@ -147,8 +161,7 @@  discard block
 block discarded – undo
147 161
                             //print 'Todo for '.$modName." : ".$newdir.'/'.$file."\n";
148 162
                             include_once $newdir.'/'.$file;
149 163
                             //print 'Done for '.$modName."\n";
150
-                        }
151
-                        catch(Exception $e)
164
+                        } catch(Exception $e)
152 165
                         {
153 166
                             dol_syslog('ko for '.$modName." ".$e->getMessage()."\n", LOG_ERR);
154 167
                         }
@@ -170,24 +183,28 @@  discard block
 block discarded – undo
170 183
         foreach ($orders as $key => $value)
171 184
         {
172 185
             $modName = $modules[$key];
173
-            if (empty($modName)) continue;
186
+            if (empty($modName)) {
187
+                continue;
188
+            }
174 189
 
175 190
             $objMod = new $modName($this->db);
176 191
             if ($objMod)
177 192
             {
178 193
             	$result=0;
179 194
 
180
-				if (method_exists($objMod, 'runTrigger'))	// New method to implement
195
+				if (method_exists($objMod, 'runTrigger')) {
196
+				    // New method to implement
181 197
 				{
182 198
 	                //dol_syslog(get_class($this)."::run_triggers action=".$action." Launch runTrigger for file '".$files[$key]."'", LOG_DEBUG);
183 199
 	                $result=$objMod->runTrigger($action,$object,$user,$langs,$conf);
184 200
 				}
185
-				elseif (method_exists($objMod, 'run_trigger'))	// Deprecated method
201
+				} elseif (method_exists($objMod, 'run_trigger')) {
202
+				    // Deprecated method
186 203
 				{
187 204
 	                dol_syslog(get_class($this)."::run_triggers action=".$action." Launch old method run_trigger (rename your trigger into runTrigger) for file '".$files[$key]."'", LOG_WARNING);
188
-					$result=$objMod->run_trigger($action,$object,$user,$langs,$conf);
189 205
 				}
190
-				else
206
+					$result=$objMod->run_trigger($action,$object,$user,$langs,$conf);
207
+				} else
191 208
 				{
192 209
 	                dol_syslog(get_class($this)."::run_triggers action=".$action." A trigger was declared for class ".get_class($objMod)." but method runTrigger was not found", LOG_ERR);
193 210
 				}
@@ -209,12 +226,14 @@  discard block
 block discarded – undo
209 226
                     //dol_syslog("Error in trigger ".$action." - Nb of error string returned = ".count($objMod->errors), LOG_ERR);
210 227
                     $nbtotal++;
211 228
                     $nbko++;
212
-                    if (! empty($objMod->errors)) $this->errors=array_merge($this->errors,$objMod->errors);
213
-                    else if (! empty($objMod->error))  $this->errors[]=$objMod->error;
229
+                    if (! empty($objMod->errors)) {
230
+                        $this->errors=array_merge($this->errors,$objMod->errors);
231
+                    } else if (! empty($objMod->error)) {
232
+                        $this->errors[]=$objMod->error;
233
+                    }
214 234
                     //dol_syslog("Error in trigger ".$action." - Nb of error string returned = ".count($this->errors), LOG_ERR);
215 235
                 }
216
-            }
217
-            else
236
+            } else
218 237
 			{
219 238
                 dol_syslog(get_class($this)."::run_triggers action=".$action." Failed to instantiate trigger for file '".$files[$key]."'", LOG_ERR);
220 239
             }
@@ -224,8 +243,7 @@  discard block
 block discarded – undo
224 243
         {
225 244
             dol_syslog(get_class($this)."::run_triggers action=".$action." Files found: ".$nbfile.", Files launched: ".$nbtotal.", Done: ".$nbok.", Failed: ".$nbko." - Nb of error string returned in this->errors = ".count($this->errors), LOG_ERR);
226 245
             return -$nbko;
227
-        }
228
-        else
246
+        } else
229 247
         {
230 248
             //dol_syslog(get_class($this)."::run_triggers Files found: ".$nbfile.", Files launched: ".$nbtotal.", Done: ".$nbok.", Failed: ".$nbko, LOG_DEBUG);
231 249
             return $nbok;
@@ -263,7 +281,9 @@  discard block
 block discarded – undo
263 281
             $newdir=dol_osencode($dir);
264 282
 
265 283
             // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call)
266
-            if (! is_dir($newdir)) continue;
284
+            if (! is_dir($newdir)) {
285
+                continue;
286
+            }
267 287
 
268 288
             $handle=opendir($newdir);
269 289
             if (is_resource($handle))
@@ -272,7 +292,9 @@  discard block
 block discarded – undo
272 292
                 {
273 293
                     if (is_readable($newdir.'/'.$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/',$file,$reg))
274 294
                     {
275
-                        if (preg_match('/\.back$/',$file)) continue;
295
+                        if (preg_match('/\.back$/',$file)) {
296
+                            continue;
297
+                        }
276 298
 
277 299
 						$part1=$reg[1];
278 300
 						$part2=$reg[2];
@@ -284,8 +306,7 @@  discard block
 block discarded – undo
284 306
                         {
285 307
                             $langs->load("errors");
286 308
                             print '<div class="error">'.$langs->trans("Error").' : '.$langs->trans("ErrorDuplicateTrigger",$modName,"/htdocs/core/triggers/").'</div>';
287
-                        }
288
-                        else
309
+                        } else
289 310
                         {
290 311
                             include_once $newdir.'/'.$file;
291 312
                         }
@@ -313,7 +334,9 @@  discard block
 block discarded – undo
313 334
         foreach ($orders as $key => $value)
314 335
         {
315 336
             $modName = $modules[$key];
316
-            if (empty($modName)) continue;
337
+            if (empty($modName)) {
338
+                continue;
339
+            }
317 340
 
318 341
             if (! class_exists($modName))
319 342
             {
@@ -329,14 +352,19 @@  discard block
 block discarded – undo
329 352
             $module='';
330 353
 
331 354
             // Check if trigger file is disabled by name
332
-            if (preg_match('/NORUN$/i',$files[$key])) $disabledbyname=1;
355
+            if (preg_match('/NORUN$/i',$files[$key])) {
356
+                $disabledbyname=1;
357
+            }
333 358
             // Check if trigger file is for a particular module
334 359
             if (preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/i',$files[$key],$reg))
335 360
             {
336 361
                 $module=preg_replace('/^mod/i','',$reg[2]);
337 362
                 $constparam='MAIN_MODULE_'.strtoupper($module);
338
-                if (strtolower($module) == 'all') $disabledbymodule=0;
339
-                else if (empty($conf->global->$constparam)) $disabledbymodule=2;
363
+                if (strtolower($module) == 'all') {
364
+                    $disabledbymodule=0;
365
+                } else if (empty($conf->global->$constparam)) {
366
+                    $disabledbymodule=2;
367
+                }
340 368
                 $triggers[$j]['module']=strtolower($module);
341 369
             }
342 370
 
@@ -348,7 +376,9 @@  discard block
 block discarded – undo
348 376
             $triggers[$j]['iscoreorexternal'] = $iscoreorexternal[$key];
349 377
             $triggers[$j]['version'] = $objMod->getVersion();
350 378
             $triggers[$j]['status'] = img_picto($langs->trans("Active"),'tick');
351
-            if ($disabledbyname > 0 || $disabledbymodule > 1) $triggers[$j]['status'] = '';
379
+            if ($disabledbyname > 0 || $disabledbymodule > 1) {
380
+                $triggers[$j]['status'] = '';
381
+            }
352 382
 
353 383
             $text ='<b>'.$langs->trans("Description").':</b><br>';
354 384
             $text.=$objMod->getDesc().'<br>';
@@ -356,13 +386,20 @@  discard block
 block discarded – undo
356 386
             if ($disabledbyname == 1)
357 387
             {
358 388
                 $text.=$langs->trans("TriggerDisabledByName").'<br>';
359
-                if ($disabledbymodule == 2) $text.=$langs->trans("TriggerDisabledAsModuleDisabled",$module).'<br>';
360
-            }
361
-            else
389
+                if ($disabledbymodule == 2) {
390
+                    $text.=$langs->trans("TriggerDisabledAsModuleDisabled",$module).'<br>';
391
+                }
392
+            } else
362 393
             {
363
-                if ($disabledbymodule == 0) $text.=$langs->trans("TriggerAlwaysActive").'<br>';
364
-                if ($disabledbymodule == 1) $text.=$langs->trans("TriggerActiveAsModuleActive",$module).'<br>';
365
-                if ($disabledbymodule == 2) $text.=$langs->trans("TriggerDisabledAsModuleDisabled",$module).'<br>';
394
+                if ($disabledbymodule == 0) {
395
+                    $text.=$langs->trans("TriggerAlwaysActive").'<br>';
396
+                }
397
+                if ($disabledbymodule == 1) {
398
+                    $text.=$langs->trans("TriggerActiveAsModuleActive",$module).'<br>';
399
+                }
400
+                if ($disabledbymodule == 2) {
401
+                    $text.=$langs->trans("TriggerDisabledAsModuleDisabled",$module).'<br>';
402
+                }
366 403
             }
367 404
 
368 405
             $triggers[$j]['info'] = $text;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/class/commoninvoice.class.php 1 patch
Braces   +204 added lines, -117 removed lines patch added patch discarded remove patch
@@ -132,10 +132,12 @@  discard block
 block discarded – undo
132 132
 		{
133 133
 			$obj = $this->db->fetch_object($resql);
134 134
 			$this->db->free($resql);
135
-			if ($multicurrency) return $obj->multicurrency_amount;
136
-			else return $obj->amount;
137
-		}
138
-		else
135
+			if ($multicurrency) {
136
+			    return $obj->multicurrency_amount;
137
+			} else {
138
+			    return $obj->amount;
139
+			}
140
+		} else
139 141
 		{
140 142
 			$this->error=$this->db->lasterror();
141 143
 			return -1;
@@ -164,8 +166,7 @@  discard block
 block discarded – undo
164 166
 	    if ($result >= 0)
165 167
 	    {
166 168
 	        return $result;
167
-	    }
168
-	    else
169
+	    } else
169 170
 	    {
170 171
 	        $this->error=$discountstatic->error;
171 172
 	        return -1;
@@ -187,8 +188,7 @@  discard block
 block discarded – undo
187 188
 	    if ($result >= 0)
188 189
 	    {
189 190
 	        return $result;
190
-	    }
191
-	    else
191
+	    } else
192 192
 	    {
193 193
 	        $this->error=$discountstatic->error;
194 194
 	        return -1;
@@ -219,8 +219,7 @@  discard block
 block discarded – undo
219 219
 				$idarray[]=$row[0];
220 220
 				$i++;
221 221
 			}
222
-		}
223
-		else
222
+		} else
224 223
 		{
225 224
 			dol_print_error($this->db);
226 225
 		}
@@ -239,7 +238,9 @@  discard block
 block discarded – undo
239 238
 		$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
240 239
 		$sql.= ' WHERE fk_facture_source = '.$this->id;
241 240
 		$sql.= ' AND type < 2';
242
-		if ($option == 'validated') $sql.= ' AND fk_statut = 1';
241
+		if ($option == 'validated') {
242
+		    $sql.= ' AND fk_statut = 1';
243
+		}
243 244
 		// PROTECTION BAD DATA
244 245
 		// Au cas ou base corrompue et qu'il y a une facture de remplacement validee
245 246
 		// et une autre non, on donne priorite a la validee.
@@ -255,14 +256,12 @@  discard block
 block discarded – undo
255 256
 			{
256 257
 				// Si il y en a
257 258
 				return $obj->rowid;
258
-			}
259
-			else
259
+			} else
260 260
 			{
261 261
 				// Si aucune facture ne remplace
262 262
 				return 0;
263 263
 			}
264
-		}
265
-		else
264
+		} else
266 265
 		{
267 266
 			return -1;
268 267
 		}
@@ -299,7 +298,9 @@  discard block
 block discarded – undo
299 298
 		$sql.= ' AND pf.'.$field2.' = p.rowid';
300 299
 		$sql.= ' AND p.fk_paiement = t.id';
301 300
 		$sql.= ' AND p.entity IN (' . getEntity($sharedentity).')';
302
-		if ($filtertype) $sql.=" AND t.code='PRE'";
301
+		if ($filtertype) {
302
+		    $sql.=" AND t.code='PRE'";
303
+		}
303 304
 
304 305
 		dol_syslog(get_class($this)."::getListOfPayments", LOG_DEBUG);
305 306
 		$resql=$this->db->query($sql);
@@ -315,8 +316,7 @@  discard block
 block discarded – undo
315 316
 			}
316 317
 			$this->db->free($resql);
317 318
 			return $retarray;
318
-		}
319
-		else
319
+		} else
320 320
 		{
321 321
 			$this->error=$this->db->lasterror();
322 322
 			dol_print_error($this->db);
@@ -347,28 +347,39 @@  discard block
 block discarded – undo
347 347
 		// We check if invoice is a temporary number (PROVxxxx)
348 348
 		$tmppart = substr($this->ref, 1, 4);
349 349
 
350
-		if ($this->statut == self::STATUS_DRAFT && $tmppart === 'PROV') // If draft invoice and ref not yet defined
350
+		if ($this->statut == self::STATUS_DRAFT && $tmppart === 'PROV') {
351
+		    // If draft invoice and ref not yet defined
351 352
 		{
352 353
 			return 1;
353 354
 		}
355
+		}
354 356
 
355
-		if (! empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) return 0;
357
+		if (! empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) {
358
+		    return 0;
359
+		}
356 360
 
357 361
 		// If not a draft invoice and not temporary invoice
358 362
 		if ($tmppart !== 'PROV')
359 363
 		{
360 364
 			$ventilExportCompta = $this->getVentilExportCompta();
361
-			if ($ventilExportCompta != 0) return -1;
365
+			if ($ventilExportCompta != 0) {
366
+			    return -1;
367
+			}
362 368
 
363 369
 			// Get last number of validated invoice
364 370
 			if ($this->element != 'invoice_supplier')
365 371
 			{
366
-				if (empty($this->thirdparty)) $this->fetch_thirdparty();	// We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag).
372
+				if (empty($this->thirdparty)) {
373
+				    $this->fetch_thirdparty();
374
+				}
375
+				// We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag).
367 376
 				$maxref = $this->getNextNumRef($this->thirdparty,'last');
368 377
 
369 378
 				// If there is no invoice into the reset range and not already dispatched, we can delete
370 379
 				// If invoice to delete is last one and not already dispatched, we can delete
371
-				if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $maxref != '' && $maxref != $this->ref) return -2;
380
+				if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $maxref != '' && $maxref != $this->ref) {
381
+				    return -2;
382
+				}
372 383
 
373 384
 				// TODO If there is payment in bookkeeping, check payment is not dispatched in accounting
374 385
 				// ...
@@ -376,13 +387,17 @@  discard block
 block discarded – undo
376 387
 				if ($this->situation_cycle_ref && method_exists($this, 'is_last_in_cycle'))
377 388
 				{
378 389
 					$last = $this->is_last_in_cycle();
379
-					if (! $last) return -3;
390
+					if (! $last) {
391
+					    return -3;
392
+					}
380 393
 				}
381 394
 			}
382 395
 		}
383 396
 
384 397
 		// Test if there is at least one payment. If yes, refuse to delete.
385
-		if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $this->getSommePaiement() > 0) return -4;
398
+		if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $this->getSommePaiement() > 0) {
399
+		    return -4;
400
+		}
386 401
 
387 402
 		return 2;
388 403
 	}
@@ -397,7 +412,9 @@  discard block
 block discarded – undo
397 412
 		$alreadydispatched = 0;
398 413
 
399 414
 		$type = 'customer_invoice';
400
-		if ($this->element == 'invoice_supplier') $type = 'supplier_invoice';
415
+		if ($this->element == 'invoice_supplier') {
416
+		    $type = 'supplier_invoice';
417
+		}
401 418
 
402 419
 		$sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$type."' AND ab.fk_doc = ".$this->id;
403 420
 		$resql = $this->db->query($sql);
@@ -408,8 +425,7 @@  discard block
 block discarded – undo
408 425
 			{
409 426
 				$alreadydispatched = $obj->nb;
410 427
 			}
411
-		}
412
-		else
428
+		} else
413 429
 		{
414 430
 			$this->error = $this->db->lasterror();
415 431
 			return -1;
@@ -431,12 +447,21 @@  discard block
 block discarded – undo
431 447
 	function getLibType()
432 448
 	{
433 449
 		global $langs;
434
-        if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard");
435
-        elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement");
436
-        elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir");
437
-        elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit");
438
-        elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma");           // Not used.
439
-        elseif ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation");
450
+        if ($this->type == CommonInvoice::TYPE_STANDARD) {
451
+            return $langs->trans("InvoiceStandard");
452
+        } elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) {
453
+            return $langs->trans("InvoiceReplacement");
454
+        } elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) {
455
+            return $langs->trans("InvoiceAvoir");
456
+        } elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) {
457
+            return $langs->trans("InvoiceDeposit");
458
+        } elseif ($this->type == CommonInvoice::TYPE_PROFORMA) {
459
+            return $langs->trans("InvoiceProForma");
460
+        }
461
+        // Not used.
462
+        elseif ($this->type == CommonInvoice::TYPE_SITUATION) {
463
+            return $langs->trans("InvoiceSituation");
464
+        }
440 465
 		return $langs->trans("Unknown");
441 466
 	}
442 467
 
@@ -475,112 +500,167 @@  discard block
 block discarded – undo
475 500
 			$prefix='';
476 501
 			if (! $paye)
477 502
 			{
478
-				if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft');
479
-				elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid');
480
-				elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
481
-				elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid');
482
-				else return $langs->trans('Bill'.$prefix.'StatusStarted');
483
-			}
484
-			else
503
+				if ($status == 0) {
504
+				    return $langs->trans('Bill'.$prefix.'StatusDraft');
505
+				} elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) {
506
+				    return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid');
507
+				} elseif (($status == 3 || $status == 2) && $alreadypaid > 0) {
508
+				    return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
509
+				} elseif ($alreadypaid <= 0) {
510
+				    return $langs->trans('Bill'.$prefix.'StatusNotPaid');
511
+				} else {
512
+				    return $langs->trans('Bill'.$prefix.'StatusStarted');
513
+				}
514
+			} else
485 515
 			{
486
-				if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted');       // credit note
487
-				elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted');             // deposit invoice
488
-				else return $langs->trans('Bill'.$prefix.'StatusPaid');
516
+				if ($type == self::TYPE_CREDIT_NOTE) {
517
+				    return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted');
518
+				}
519
+				// credit note
520
+				elseif ($type == self::TYPE_DEPOSIT) {
521
+				    return $langs->trans('Bill'.$prefix.'StatusConverted');
522
+				}
523
+				// deposit invoice
524
+				else {
525
+				    return $langs->trans('Bill'.$prefix.'StatusPaid');
526
+				}
489 527
 			}
490
-		}
491
-		elseif ($mode == 1)
528
+		} elseif ($mode == 1)
492 529
 		{
493 530
 			$prefix='Short';
494 531
 			if (! $paye)
495 532
 			{
496
-				if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft');
497
-				elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusCanceled');
498
-				elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
499
-				elseif ($alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusNotPaid');
500
-				else return $langs->trans('Bill'.$prefix.'StatusStarted');
501
-			}
502
-			else
533
+				if ($status == 0) {
534
+				    return $langs->trans('Bill'.$prefix.'StatusDraft');
535
+				} elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) {
536
+				    return $langs->trans('Bill'.$prefix.'StatusCanceled');
537
+				} elseif (($status == 3 || $status == 2) && $alreadypaid > 0) {
538
+				    return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
539
+				} elseif ($alreadypaid <= 0) {
540
+				    return $langs->trans('Bill'.$prefix.'StatusNotPaid');
541
+				} else {
542
+				    return $langs->trans('Bill'.$prefix.'StatusStarted');
543
+				}
544
+			} else
503 545
 			{
504
-				if ($type == self::TYPE_CREDIT_NOTE) return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted');
505
-				elseif ($type == self::TYPE_DEPOSIT) return $langs->trans('Bill'.$prefix.'StatusConverted');
506
-				else return $langs->trans('Bill'.$prefix.'StatusPaid');
546
+				if ($type == self::TYPE_CREDIT_NOTE) {
547
+				    return $langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted');
548
+				} elseif ($type == self::TYPE_DEPOSIT) {
549
+				    return $langs->trans('Bill'.$prefix.'StatusConverted');
550
+				} else {
551
+				    return $langs->trans('Bill'.$prefix.'StatusPaid');
552
+				}
507 553
 			}
508
-		}
509
-		elseif ($mode == 2)
554
+		} elseif ($mode == 2)
510 555
 		{
511 556
 			$prefix='Short';
512 557
 			if (! $paye)
513 558
 			{
514
-				if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft');
515
-				elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled');
516
-				elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
517
-				elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid');
518
-				else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted');
519
-			}
520
-			else
559
+				if ($status == 0) {
560
+				    return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft');
561
+				} elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) {
562
+				    return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled');
563
+				} elseif (($status == 3 || $status == 2) && $alreadypaid > 0) {
564
+				    return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
565
+				} elseif ($alreadypaid <= 0) {
566
+				    return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid');
567
+				} else {
568
+				    return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted');
569
+				}
570
+			} else
521 571
 			{
522
-				if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted');
523
-				elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted');
524
-				else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid');
572
+				if ($type == self::TYPE_CREDIT_NOTE) {
573
+				    return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted');
574
+				} elseif ($type == self::TYPE_DEPOSIT) {
575
+				    return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusConverted');
576
+				} else {
577
+				    return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid');
578
+				}
525 579
 			}
526
-		}
527
-		elseif ($mode == 3)
580
+		} elseif ($mode == 3)
528 581
 		{
529 582
 			$prefix='Short';
530 583
 			if (! $paye)
531 584
 			{
532
-				if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0');
533
-				elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5');
534
-				elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9');
535
-				elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1');
536
-				else return img_picto($langs->trans('BillStatusStarted'),'statut3');
537
-			}
538
-			else
585
+				if ($status == 0) {
586
+				    return img_picto($langs->trans('BillStatusDraft'),'statut0');
587
+				} elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) {
588
+				    return img_picto($langs->trans('BillStatusCanceled'),'statut5');
589
+				} elseif (($status == 3 || $status == 2) && $alreadypaid > 0) {
590
+				    return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9');
591
+				} elseif ($alreadypaid <= 0) {
592
+				    return img_picto($langs->trans('BillStatusNotPaid'),'statut1');
593
+				} else {
594
+				    return img_picto($langs->trans('BillStatusStarted'),'statut3');
595
+				}
596
+			} else
539 597
 			{
540
-				if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6');
541
-				elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6');
542
-				else return img_picto($langs->trans('BillStatusPaid'),'statut6');
598
+				if ($type == self::TYPE_CREDIT_NOTE) {
599
+				    return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6');
600
+				} elseif ($type == self::TYPE_DEPOSIT) {
601
+				    return img_picto($langs->trans('BillStatusConverted'),'statut6');
602
+				} else {
603
+				    return img_picto($langs->trans('BillStatusPaid'),'statut6');
604
+				}
543 605
 			}
544
-		}
545
-		elseif ($mode == 4)
606
+		} elseif ($mode == 4)
546 607
 		{
547 608
 			$prefix='';
548 609
 			if (! $paye)
549 610
 			{
550
-				if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft');
551
-				elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled');
552
-				elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
553
-				elseif ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid');
554
-				else return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted');
555
-			}
556
-			else
611
+				if ($status == 0) {
612
+				    return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft');
613
+				} elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) {
614
+				    return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled');
615
+				} elseif (($status == 3 || $status == 2) && $alreadypaid > 0) {
616
+				    return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially');
617
+				} elseif ($alreadypaid <= 0) {
618
+				    return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid');
619
+				} else {
620
+				    return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted');
621
+				}
622
+			} else
557 623
 			{
558
-				if ($type == self::TYPE_CREDIT_NOTE) return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted');
559
-				elseif ($type == self::TYPE_DEPOSIT) return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('BillStatusConverted');
560
-				else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('BillStatusPaid');
624
+				if ($type == self::TYPE_CREDIT_NOTE) {
625
+				    return img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6').' '.$langs->trans('BillStatusPaidBackOrConverted');
626
+				} elseif ($type == self::TYPE_DEPOSIT) {
627
+				    return img_picto($langs->trans('BillStatusConverted'),'statut6').' '.$langs->trans('BillStatusConverted');
628
+				} else {
629
+				    return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('BillStatusPaid');
630
+				}
561 631
 			}
562
-		}
563
-		elseif ($mode == 5 || $mode == 6)
632
+		} elseif ($mode == 5 || $mode == 6)
564 633
 		{
565 634
 			$prefix='';
566
-			if ($mode == 5) $prefix='Short';
635
+			if ($mode == 5) {
636
+			    $prefix='Short';
637
+			}
567 638
 			if (! $paye)
568 639
 			{
569
-				if ($status == 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'),'statut0');
570
-				elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'),'statut5');
571
-				elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9');
572
-				elseif ($alreadypaid <= 0)
640
+				if ($status == 0) {
641
+				    return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusDraft').' </span>'.img_picto($langs->trans('BillStatusDraft'),'statut0');
642
+				} elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) {
643
+				    return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusCanceled').' </span>'.img_picto($langs->trans('BillStatusCanceled'),'statut5');
644
+				} elseif (($status == 3 || $status == 2) && $alreadypaid > 0) {
645
+				    return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' </span>'.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9');
646
+				} elseif ($alreadypaid <= 0)
573 647
 				{
574
-				    if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'),'statut1');
648
+				    if ($type == self::TYPE_CREDIT_NOTE) {
649
+				        return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' </span>'.img_picto($langs->trans('StatusNotRefunded'),'statut1');
650
+				    }
575 651
 				    return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusNotPaid').' </span>'.img_picto($langs->trans('BillStatusNotPaid'),'statut1');
652
+				} else {
653
+				    return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusStarted').' </span>'.img_picto($langs->trans('BillStatusStarted'),'statut3');
576 654
 				}
577
-				else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusStarted').' </span>'.img_picto($langs->trans('BillStatusStarted'),'statut3');
578
-			}
579
-			else
655
+			} else
580 656
 			{
581
-				if ($type == self::TYPE_CREDIT_NOTE) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' </span>'.img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6');
582
-				elseif ($type == self::TYPE_DEPOSIT) return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusConverted').' </span>'.img_picto($langs->trans('BillStatusConverted'),'statut6');
583
-				else return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaid').' </span>'.img_picto($langs->trans('BillStatusPaid'),'statut6');
657
+				if ($type == self::TYPE_CREDIT_NOTE) {
658
+				    return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaidBackOrConverted').' </span>'.img_picto($langs->trans('BillStatusPaidBackOrConverted'),'statut6');
659
+				} elseif ($type == self::TYPE_DEPOSIT) {
660
+				    return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusConverted').' </span>'.img_picto($langs->trans('BillStatusConverted'),'statut6');
661
+				} else {
662
+				    return '<span class="xhideonsmartphone">'.$langs->trans('Bill'.$prefix.'StatusPaid').' </span>'.img_picto($langs->trans('BillStatusPaid'),'statut6');
663
+				}
584 664
 			}
585 665
 		}
586 666
 	}
@@ -596,8 +676,12 @@  discard block
 block discarded – undo
596 676
 	function calculate_date_lim_reglement($cond_reglement=0)
597 677
 	{
598 678
         // phpcs:enable
599
-		if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code;
600
-		if (! $cond_reglement) $cond_reglement=$this->cond_reglement_id;
679
+		if (! $cond_reglement) {
680
+		    $cond_reglement=$this->cond_reglement_code;
681
+		}
682
+		if (! $cond_reglement) {
683
+		    $cond_reglement=$this->cond_reglement_id;
684
+		}
601 685
 
602 686
 		$cdr_nbjour=0;
603 687
         $cdr_type=0;
@@ -605,8 +689,9 @@  discard block
 block discarded – undo
605 689
 
606 690
 		$sqltemp = 'SELECT c.type_cdr, c.nbjour, c.decalage';
607 691
 		$sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c';
608
-		if (is_numeric($cond_reglement)) $sqltemp.= " WHERE c.rowid=".$cond_reglement;
609
-		else {
692
+		if (is_numeric($cond_reglement)) {
693
+		    $sqltemp.= " WHERE c.rowid=".$cond_reglement;
694
+		} else {
610 695
 			$sqltemp.= " WHERE c.entity IN (".getEntity('c_payment_term').")";
611 696
 			$sqltemp.= " AND c.code='".$this->db->escape($cond_reglement)."'";
612 697
 		}
@@ -622,8 +707,7 @@  discard block
 block discarded – undo
622 707
 				$cdr_type = $obj->type_cdr;
623 708
 				$cdr_decalage = $obj->decalage;
624 709
 			}
625
-		}
626
-		else
710
+		} else
627 711
 		{
628 712
 			$this->error=$this->db->error();
629 713
 			return -1;
@@ -650,8 +734,7 @@  discard block
 block discarded – undo
650 734
 			{
651 735
 				$mois = 1;
652 736
 				$annee += 1;
653
-			}
654
-			else
737
+			} else
655 738
 			{
656 739
 				$mois += 1;
657 740
 			}
@@ -672,10 +755,14 @@  discard block
 block discarded – undo
672 755
 
673 756
 			$diff = $date_piece - $date_lim_current;
674 757
 
675
-			if ($diff < 0) $datelim = $date_lim_current;
676
-			else $datelim = $date_lim_next;
758
+			if ($diff < 0) {
759
+			    $datelim = $date_lim_current;
760
+			} else {
761
+			    $datelim = $date_lim_next;
762
+			}
763
+		} else {
764
+		    return 'Bad value for type_cdr in database for record cond_reglement = '.$cond_reglement;
677 765
 		}
678
-		else return 'Bad value for type_cdr in database for record cond_reglement = '.$cond_reglement;
679 766
 
680 767
 		return $datelim;
681 768
 	}
Please login to merge, or discard this patch.