Passed
Push — master ( 853f8f...c34860 )
by Alxarafe
25:12
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/html.formactions.class.php 1 patch
Braces   +87 added lines, -41 removed lines patch added patch discarded remove patch
@@ -128,9 +128,13 @@  discard block
 block discarded – undo
128 128
         if (! empty($conf->use_javascript_ajax) || $onlyselect)
129 129
         {
130 130
         	//var_dump($selected);
131
-        	if ($selected == 'done') $selected='100';
131
+        	if ($selected == 'done') {
132
+        	    $selected='100';
133
+        	}
132 134
             print '<select '.($canedit?'':'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss?' '.$morecss:'').'">';
133
-            if ($showempty) print '<option value=""'.($selected == ''?' selected':'').'></option>';
135
+            if ($showempty) {
136
+                print '<option value=""'.($selected == ''?' selected':'').'></option>';
137
+            }
134 138
             foreach($listofstatus as $key => $val)
135 139
             {
136 140
                 print '<option value="'.$key.'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected' : '').'>'.$val.'</option>';
@@ -140,15 +144,16 @@  discard block
 block discarded – undo
140 144
                 }
141 145
             }
142 146
             print '</select>';
143
-            if ($selected == 0 || $selected == 100) $canedit=0;
147
+            if ($selected == 0 || $selected == 100) {
148
+                $canedit=0;
149
+            }
144 150
 
145 151
             if (empty($onlyselect))
146 152
             {
147 153
 	            print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit&&($selected>=0)?'':' disabled').'>';
148 154
     	        print '<span class="hideonsmartphone hideifna">%</span>';
149 155
             }
150
-        }
151
-        else
156
+        } else
152 157
 		{
153 158
             print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected>=0?$selected:'').'" size="2"'.($canedit?'':' disabled').'>%';
154 159
         }
@@ -179,28 +184,45 @@  discard block
 block discarded – undo
179 184
         $sortorder='DESC,DESC';
180 185
 
181 186
         $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max?($max+1):0));
182
-		if (! is_array($listofactions)) dol_print_error($this->db,'FailedToGetActions');
187
+		if (! is_array($listofactions)) {
188
+		    dol_print_error($this->db,'FailedToGetActions');
189
+		}
183 190
 
184 191
         $num = count($listofactions);
185 192
         if ($num || $forceshowtitle)
186 193
         {
187
-        	if ($typeelement == 'invoice')               $title=$langs->trans('ActionsOnBill');
188
-        	elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnBill');
189
-        	elseif ($typeelement == 'propal')            $title=$langs->trans('ActionsOnPropal');
190
-        	elseif ($typeelement == 'supplier_proposal') $title=$langs->trans('ActionsOnSupplierProposal');
191
-        	elseif ($typeelement == 'order')             $title=$langs->trans('ActionsOnOrder');
192
-        	elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order')   $title=$langs->trans('ActionsOnOrder');
193
-        	elseif ($typeelement == 'shipping')          $title=$langs->trans('ActionsOnShipping');
194
-            elseif ($typeelement == 'fichinter')         $title=$langs->trans('ActionsOnFicheInter');
195
-            elseif ($typeelement == 'project')           $title=$langs->trans('LatestLinkedEvents', $max?$max:'');
196
-            elseif ($typeelement == 'task')              $title=$langs->trans('LatestLinkedEvents', $max?$max:'');
197
-            elseif ($typeelement == 'member')            $title=$langs->trans('LatestLinkedEvents', $max?$max:'');
198
-            else $title=$langs->trans("LatestLinkedEvents", $max?$max:'');
194
+        	if ($typeelement == 'invoice') {
195
+        	    $title=$langs->trans('ActionsOnBill');
196
+        	} elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') {
197
+        	    $title=$langs->trans('ActionsOnBill');
198
+        	} elseif ($typeelement == 'propal') {
199
+        	    $title=$langs->trans('ActionsOnPropal');
200
+        	} elseif ($typeelement == 'supplier_proposal') {
201
+        	    $title=$langs->trans('ActionsOnSupplierProposal');
202
+        	} elseif ($typeelement == 'order') {
203
+        	    $title=$langs->trans('ActionsOnOrder');
204
+        	} elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') {
205
+        	    $title=$langs->trans('ActionsOnOrder');
206
+        	} elseif ($typeelement == 'shipping') {
207
+        	    $title=$langs->trans('ActionsOnShipping');
208
+        	} elseif ($typeelement == 'fichinter') {
209
+                $title=$langs->trans('ActionsOnFicheInter');
210
+            } elseif ($typeelement == 'project') {
211
+                $title=$langs->trans('LatestLinkedEvents', $max?$max:'');
212
+            } elseif ($typeelement == 'task') {
213
+                $title=$langs->trans('LatestLinkedEvents', $max?$max:'');
214
+            } elseif ($typeelement == 'member') {
215
+                $title=$langs->trans('LatestLinkedEvents', $max?$max:'');
216
+            } else {
217
+                $title=$langs->trans("LatestLinkedEvents", $max?$max:'');
218
+            }
199 219
 
200 220
             $urlbacktopage=$_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage?'&'.$moreparambacktopage:'');
201 221
 
202 222
             $projectid = $object->fk_project;
203
-            if ($typeelement == 'project') $projectid = $object->id;
223
+            if ($typeelement == 'project') {
224
+                $projectid = $object->id;
225
+            }
204 226
 
205 227
             $newcardbutton='';
206 228
 			if (! empty($conf->agenda->enabled))
@@ -236,7 +258,9 @@  discard block
 block discarded – undo
236 258
 	        	$cursorevent = 0;
237 259
 	        	foreach($listofactions as $action)
238 260
 	        	{
239
-	        		if ($max && $cursorevent >= $max) break;
261
+	        		if ($max && $cursorevent >= $max) {
262
+	        		    break;
263
+	        		}
240 264
 
241 265
 	        		$ref=$action->getNomUrl(1,-1);
242 266
 	        		$label=$action->getNomUrl(0,38);
@@ -257,14 +281,22 @@  discard block
 block discarded – undo
257 281
 					$imgpicto='';
258 282
 					if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
259 283
 					{
260
-						if ($action->type_picto) $imgpicto=img_picto('', $action->type_picto);
261
-						else {
262
-							if ($action->type_code == 'AC_RDV')       $imgpicto=img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' ';
263
-							elseif ($action->type_code == 'AC_TEL')   $imgpicto=img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' ';
264
-							elseif ($action->type_code == 'AC_FAX')   $imgpicto=img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' ';
265
-							elseif ($action->type_code == 'AC_EMAIL') $imgpicto=img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' ';
266
-							elseif ($action->type_code == 'AC_INT')   $imgpicto=img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' ';
267
-							elseif (! preg_match('/_AUTO/', $action->type_code)) $imgpicto=img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' ';
284
+						if ($action->type_picto) {
285
+						    $imgpicto=img_picto('', $action->type_picto);
286
+						} else {
287
+							if ($action->type_code == 'AC_RDV') {
288
+							    $imgpicto=img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' ';
289
+							} elseif ($action->type_code == 'AC_TEL') {
290
+							    $imgpicto=img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' ';
291
+							} elseif ($action->type_code == 'AC_FAX') {
292
+							    $imgpicto=img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' ';
293
+							} elseif ($action->type_code == 'AC_EMAIL') {
294
+							    $imgpicto=img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' ';
295
+							} elseif ($action->type_code == 'AC_INT') {
296
+							    $imgpicto=img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' ';
297
+							} elseif (! preg_match('/_AUTO/', $action->type_code)) {
298
+							    $imgpicto=img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' ';
299
+							}
268 300
 						}
269 301
 					}
270 302
 					print $imgpicto;
@@ -280,9 +312,12 @@  discard block
 block discarded – undo
280 312
 		        		$tmpb=dol_getdate($action->datef);
281 313
 		        		if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year'])
282 314
 		        		{
283
-		        			if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($action->datef, 'hour', 'tzuserrel');
315
+		        			if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) {
316
+		        			    print '-'.dol_print_date($action->datef, 'hour', 'tzuserrel');
317
+		        			}
318
+		        		} else {
319
+		        		    print '-'.dol_print_date($action->datef, 'dayhour', 'tzuserrel');
284 320
 		        		}
285
-		        		else print '-'.dol_print_date($action->datef, 'dayhour', 'tzuserrel');
286 321
 	        		}
287 322
 	        		print '</td>';
288 323
 	        		print '<td align="right">';
@@ -295,8 +330,7 @@  discard block
 block discarded – undo
295 330
 
296 331
 	        		$cursorevent++;
297 332
 	        	}
298
-        	}
299
-        	else
333
+        	} else
300 334
         	{
301 335
         		print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
302 336
         	}
@@ -332,7 +366,9 @@  discard block
 block discarded – undo
332 366
         // phpcs:enable
333 367
         global $langs,$user,$form,$conf;
334 368
 
335
-        if (! is_object($form)) $form=new Form($this->db);
369
+        if (! is_object($form)) {
370
+            $form=new Form($this->db);
371
+        }
336 372
 
337 373
         require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
338 374
         require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
@@ -343,19 +379,26 @@  discard block
 block discarded – undo
343 379
        	array_unshift($arraylist,'&nbsp;');     // Add empty line at start
344 380
        	//asort($arraylist);
345 381
 
346
-       	if ($selected == 'manual') $selected='AC_OTH';
347
-       	if ($selected == 'auto')   $selected='AC_OTH_AUTO';
382
+       	if ($selected == 'manual') {
383
+       	    $selected='AC_OTH';
384
+       	}
385
+       	if ($selected == 'auto') {
386
+       	    $selected='AC_OTH_AUTO';
387
+       	}
348 388
 
349
-       	if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']);
389
+       	if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) {
390
+       	    unset($arraylist['AC_OTH_AUTO']);
391
+       	}
350 392
 
351 393
        	$out='';
352 394
 
353 395
 		if (! empty($multiselect))
354 396
 		{
355
-	        if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected);
397
+	        if (!is_array($selected) && !empty($selected)) {
398
+	            $selected = explode(',', $selected);
399
+	        }
356 400
 			$out.=$form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0);
357
-		}
358
-		else
401
+		} else
359 402
 		{
360 403
 			$out.=$form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1);
361 404
 		}
@@ -365,8 +408,11 @@  discard block
 block discarded – undo
365 408
             $out.=info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''),1);
366 409
         }
367 410
 
368
-        if ($nooutput) return $out;
369
-        else print $out;
411
+        if ($nooutput) {
412
+            return $out;
413
+        } else {
414
+            print $out;
415
+        }
370 416
         return '';
371 417
     }
372 418
 }
Please login to merge, or discard this patch.