Passed
Branch develop (66e4de)
by Laurent
33:03
created
htdocs/core/class/extrafields.class.php 1 patch
Braces   +224 added lines, -75 removed lines patch added patch discarded remove patch
@@ -230,12 +230,20 @@  discard block
 block discarded – undo
230 230
 	 */
231 231
 	public function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique = 0, $required = 0, $default_value = '', $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0)
232 232
 	{
233
-		if (empty($attrname)) return -1;
234
-		if (empty($label)) return -1;
233
+		if (empty($attrname)) {
234
+			return -1;
235
+		}
236
+		if (empty($label)) {
237
+			return -1;
238
+		}
235 239
 
236 240
 		if ($type == 'separate') { $unique = 0; $required = 0; }	// Force unique and not required if this is a separator field to avoid troubles.
237
-		if ($elementtype == 'thirdparty') $elementtype = 'societe';
238
-		if ($elementtype == 'contact') $elementtype = 'socpeople';
241
+		if ($elementtype == 'thirdparty') {
242
+			$elementtype = 'societe';
243
+		}
244
+		if ($elementtype == 'contact') {
245
+			$elementtype = 'socpeople';
246
+		}
239 247
 
240 248
 		// Create field into database except for separator type which is not stored in database
241 249
 		if ($type != 'separate')
@@ -253,7 +261,9 @@  discard block
 block discarded – undo
253 261
 				$this->error = '';
254 262
 				$this->errno = 0;
255 263
 				return 1;
256
-			} else return -2;
264
+			} else {
265
+				return -2;
266
+			}
257 267
 		} else {
258 268
 			return -1;
259 269
 		}
@@ -279,11 +289,17 @@  discard block
 block discarded – undo
279 289
 	 */
280 290
 	private function create($attrname, $type = 'varchar', $length = 255, $elementtype = 'member', $unique = 0, $required = 0, $default_value = '', $param = '', $perms = '', $list = '0', $computed = '', $help = '')
281 291
 	{
282
-		if ($elementtype == 'thirdparty') $elementtype = 'societe';
283
-		if ($elementtype == 'contact') $elementtype = 'socpeople';
292
+		if ($elementtype == 'thirdparty') {
293
+			$elementtype = 'societe';
294
+		}
295
+		if ($elementtype == 'contact') {
296
+			$elementtype = 'socpeople';
297
+		}
284 298
 
285 299
 		$table = $elementtype.'_extrafields';
286
-		if ($elementtype == 'categorie') $table = 'categories_extrafields';
300
+		if ($elementtype == 'categorie') {
301
+			$table = 'categories_extrafields';
302
+		}
287 303
 
288 304
 		if (!empty($attrname) && preg_match("/^\w[a-zA-Z0-9_]*$/", $attrname) && !is_numeric($attrname))
289 305
 		{
@@ -317,7 +333,9 @@  discard block
 block discarded – undo
317 333
 			} else {
318 334
 				$typedb = $type;
319 335
 				$lengthdb = $length;
320
-				if ($type == 'varchar' && empty($lengthdb)) $lengthdb = '255';
336
+				if ($type == 'varchar' && empty($lengthdb)) {
337
+					$lengthdb = '255';
338
+				}
321 339
 			}
322 340
 			$field_desc = array(
323 341
 				'type'=>$typedb,
@@ -377,17 +395,35 @@  discard block
 block discarded – undo
377 395
 		// phpcs:enable
378 396
 		global $conf, $user;
379 397
 
380
-		if ($elementtype == 'thirdparty') $elementtype = 'societe';
381
-		if ($elementtype == 'contact') $elementtype = 'socpeople';
398
+		if ($elementtype == 'thirdparty') {
399
+			$elementtype = 'societe';
400
+		}
401
+		if ($elementtype == 'contact') {
402
+			$elementtype = 'socpeople';
403
+		}
382 404
 
383 405
 		// Clean parameters
384
-		if (empty($pos)) $pos = 0;
385
-		if (empty($list)) $list = '0';
386
-		if (empty($required)) $required = 0;
387
-		if (empty($unique)) $unique = 0;
388
-		if (empty($printable)) $printable = 0;
389
-		if (empty($alwayseditable)) $alwayseditable = 0;
390
-		if (empty($totalizable)) $totalizable = 0;
406
+		if (empty($pos)) {
407
+			$pos = 0;
408
+		}
409
+		if (empty($list)) {
410
+			$list = '0';
411
+		}
412
+		if (empty($required)) {
413
+			$required = 0;
414
+		}
415
+		if (empty($unique)) {
416
+			$unique = 0;
417
+		}
418
+		if (empty($printable)) {
419
+			$printable = 0;
420
+		}
421
+		if (empty($alwayseditable)) {
422
+			$alwayseditable = 0;
423
+		}
424
+		if (empty($totalizable)) {
425
+			$totalizable = 0;
426
+		}
391 427
 
392 428
 		if (!empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname) && !is_numeric($attrname))
393 429
 		{
@@ -472,11 +508,17 @@  discard block
 block discarded – undo
472 508
 	 */
473 509
 	public function delete($attrname, $elementtype = 'member')
474 510
 	{
475
-		if ($elementtype == 'thirdparty') $elementtype = 'societe';
476
-		if ($elementtype == 'contact') $elementtype = 'socpeople';
511
+		if ($elementtype == 'thirdparty') {
512
+			$elementtype = 'societe';
513
+		}
514
+		if ($elementtype == 'contact') {
515
+			$elementtype = 'socpeople';
516
+		}
477 517
 
478 518
 		$table = $elementtype.'_extrafields';
479
-		if ($elementtype == 'categorie') $table = 'categories_extrafields';
519
+		if ($elementtype == 'categorie') {
520
+			$table = 'categories_extrafields';
521
+		}
480 522
 
481 523
 		$error = 0;
482 524
 
@@ -533,8 +575,12 @@  discard block
 block discarded – undo
533 575
 		// phpcs:enable
534 576
 		global $conf;
535 577
 
536
-		if ($elementtype == 'thirdparty') $elementtype = 'societe';
537
-		if ($elementtype == 'contact') $elementtype = 'socpeople';
578
+		if ($elementtype == 'thirdparty') {
579
+			$elementtype = 'societe';
580
+		}
581
+		if ($elementtype == 'contact') {
582
+			$elementtype = 'socpeople';
583
+		}
538 584
 
539 585
 		if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname))
540 586
 		{
@@ -585,11 +631,17 @@  discard block
 block discarded – undo
585 631
 	 */
586 632
 	public function update($attrname, $label, $type, $length, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0)
587 633
 	{
588
-		if ($elementtype == 'thirdparty') $elementtype = 'societe';
589
-		if ($elementtype == 'contact') $elementtype = 'socpeople';
634
+		if ($elementtype == 'thirdparty') {
635
+			$elementtype = 'societe';
636
+		}
637
+		if ($elementtype == 'contact') {
638
+			$elementtype = 'socpeople';
639
+		}
590 640
 
591 641
 		$table = $elementtype.'_extrafields';
592
-		if ($elementtype == 'categorie') $table = 'categories_extrafields';
642
+		if ($elementtype == 'categorie') {
643
+			$table = 'categories_extrafields';
644
+		}
593 645
 
594 646
 		if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname))
595 647
 		{
@@ -625,10 +677,12 @@  discard block
 block discarded – undo
625 677
 			}
626 678
 			$field_desc = array('type'=>$typedb, 'value'=>$lengthdb, 'null'=>($required ? 'NOT NULL' : 'NULL'), 'default'=>$default);
627 679
 
628
-			if ($type != 'separate') // No table update when separate type
680
+			if ($type != 'separate') {
681
+				// No table update when separate type
629 682
 			{
630 683
 				$result = $this->db->DDLUpdateField(MAIN_DB_PREFIX.$table, $attrname, $field_desc);
631 684
 			}
685
+			}
632 686
 			if ($result > 0 || $type == 'separate')
633 687
 			{
634 688
 				if ($label)
@@ -694,17 +748,31 @@  discard block
 block discarded – undo
694 748
 		dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$default.", ".$computed.", ".$entity.", ".$langfile.", ".$enabled.", ".$totalizable.", ".$printable);
695 749
 
696 750
 		// Clean parameters
697
-		if ($elementtype == 'thirdparty') $elementtype = 'societe';
698
-		if ($elementtype == 'contact') $elementtype = 'socpeople';
751
+		if ($elementtype == 'thirdparty') {
752
+			$elementtype = 'societe';
753
+		}
754
+		if ($elementtype == 'contact') {
755
+			$elementtype = 'socpeople';
756
+		}
699 757
 
700
-		if (empty($pos)) $pos = 0;
701
-		if (empty($list)) $list = '0';
758
+		if (empty($pos)) {
759
+			$pos = 0;
760
+		}
761
+		if (empty($list)) {
762
+			$list = '0';
763
+		}
702 764
 		if (empty($totalizable)) {
703 765
 			$totalizable = 0;
704 766
 		}
705
-		if (empty($required)) $required = 0;
706
-		if (empty($unique)) $unique = 0;
707
-		if (empty($alwayseditable)) $alwayseditable = 0;
767
+		if (empty($required)) {
768
+			$required = 0;
769
+		}
770
+		if (empty($unique)) {
771
+			$unique = 0;
772
+		}
773
+		if (empty($alwayseditable)) {
774
+			$alwayseditable = 0;
775
+		}
708 776
 
709 777
 		if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/", $attrname))
710 778
 		{
@@ -816,12 +884,22 @@  discard block
 block discarded – undo
816 884
 		// phpcs:enable
817 885
 		global $conf;
818 886
 
819
-		if (empty($elementtype)) return array();
887
+		if (empty($elementtype)) {
888
+			return array();
889
+		}
820 890
 
821
-		if ($elementtype == 'thirdparty')     $elementtype = 'societe';
822
-		if ($elementtype == 'contact')        $elementtype = 'socpeople';
823
-		if ($elementtype == 'order_supplier') $elementtype = 'commande_fournisseur';
824
-		if ($elementtype == 'stock_mouvement') $elementtype = 'movement';
891
+		if ($elementtype == 'thirdparty') {
892
+			$elementtype = 'societe';
893
+		}
894
+		if ($elementtype == 'contact') {
895
+			$elementtype = 'socpeople';
896
+		}
897
+		if ($elementtype == 'order_supplier') {
898
+			$elementtype = 'commande_fournisseur';
899
+		}
900
+		if ($elementtype == 'stock_mouvement') {
901
+			$elementtype = 'movement';
902
+		}
825 903
 
826 904
 		$array_name_label = array();
827 905
 
@@ -829,7 +907,10 @@  discard block
 block discarded – undo
829 907
 		$sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,printable,totalizable,fielddefault,fieldcomputed,entity,enabled,help";
830 908
 		$sql .= " FROM ".MAIN_DB_PREFIX."extrafields";
831 909
 		//$sql.= " WHERE entity IN (0,".$conf->entity.")";    // Filter is done later
832
-		if ($elementtype) $sql .= " WHERE elementtype = '".$this->db->escape($elementtype)."'"; // Filed with object->table_element
910
+		if ($elementtype) {
911
+			$sql .= " WHERE elementtype = '".$this->db->escape($elementtype)."'";
912
+		}
913
+		// Filed with object->table_element
833 914
 		$sql .= " ORDER BY pos";
834 915
 
835 916
 		$resql = $this->db->query($sql);
@@ -897,7 +978,10 @@  discard block
 block discarded – undo
897 978
 					$this->attributes[$tab->elementtype]['loaded'] = 1;
898 979
 				}
899 980
 			}
900
-			if ($elementtype) $this->attributes[$elementtype]['loaded'] = 1; // If nothing found, we also save tag 'loaded'
981
+			if ($elementtype) {
982
+				$this->attributes[$elementtype]['loaded'] = 1;
983
+			}
984
+			// If nothing found, we also save tag 'loaded'
901 985
 		} else {
902 986
 			$this->error = $this->db->lasterror();
903 987
 			dol_syslog(get_class($this)."::fetch_name_optionals_label ".$this->error, LOG_ERR);
@@ -934,10 +1018,12 @@  discard block
 block discarded – undo
934 1018
 
935 1019
 		$out = '';
936 1020
 
937
-		if (!preg_match('/options_$/', $keyprefix))	// Because we work on extrafields, we add 'options_' to prefix if not already added
1021
+		if (!preg_match('/options_$/', $keyprefix)) {
1022
+			// Because we work on extrafields, we add 'options_' to prefix if not already added
938 1023
 		{
939 1024
 			$keyprefix = $keyprefix.'options_';
940 1025
 		}
1026
+		}
941 1027
 
942 1028
 		if (!empty($extrafieldsobjectkey))
943 1029
 		{
@@ -974,8 +1060,11 @@  discard block
 block discarded – undo
974 1060
 
975 1061
 		if ($computed)
976 1062
 		{
977
-			if (!preg_match('/^search_/', $keyprefix)) return '<span class="opacitymedium">'.$langs->trans("AutomaticallyCalculated").'</span>';
978
-			else return '';
1063
+			if (!preg_match('/^search_/', $keyprefix)) {
1064
+				return '<span class="opacitymedium">'.$langs->trans("AutomaticallyCalculated").'</span>';
1065
+			} else {
1066
+				return '';
1067
+			}
979 1068
 		}
980 1069
 
981 1070
 		if (empty($morecss))
@@ -1019,7 +1108,9 @@  discard block
 block discarded – undo
1019 1108
 			$showtime = in_array($type, array('datetime')) ? 1 : 0;
1020 1109
 
1021 1110
 			// Do not show current date when field not required (see selectDate() method)
1022
-			if (!$required && $value == '') $value = '-1';
1111
+			if (!$required && $value == '') {
1112
+				$value = '-1';
1113
+			}
1023 1114
 
1024 1115
 			// TODO Must also support $moreparam
1025 1116
 			$out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1);
@@ -1036,9 +1127,11 @@  discard block
 block discarded – undo
1036 1127
 			$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam ? $moreparam : '').'>';
1037 1128
 		} elseif ($type == 'text')
1038 1129
 		{
1039
-			if (!preg_match('/search_/', $keyprefix))		// If keyprefix is search_ or search_options_, we must just use a simple text field
1130
+			if (!preg_match('/search_/', $keyprefix)) {
1131
+				// If keyprefix is search_ or search_options_, we must just use a simple text field
1040 1132
 			{
1041 1133
 				require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1134
+			}
1042 1135
 				$doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%');
1043 1136
 				$out = $doleditor->Create(1);
1044 1137
 			} else {
@@ -1046,9 +1139,11 @@  discard block
 block discarded – undo
1046 1139
 			}
1047 1140
 		} elseif ($type == 'html')
1048 1141
 		{
1049
-			if (!preg_match('/search_/', $keyprefix))		// If keyprefix is search_ or search_options_, we must just use a simple text field
1142
+			if (!preg_match('/search_/', $keyprefix)) {
1143
+				// If keyprefix is search_ or search_options_, we must just use a simple text field
1050 1144
 			{
1051 1145
 				require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1146
+			}
1052 1147
 				$doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, !empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, '90%');
1053 1148
 				$out = $doleditor->Create(1);
1054 1149
 			} else {
@@ -1093,14 +1188,19 @@  discard block
 block discarded – undo
1093 1188
 			$out .= '<option value="0">&nbsp;</option>';
1094 1189
 			foreach ($param['options'] as $key => $val)
1095 1190
 			{
1096
-				if ((string) $key == '') continue;
1191
+				if ((string) $key == '') {
1192
+					continue;
1193
+				}
1097 1194
 				list($val, $parent) = explode('|', $val);
1098 1195
 				$out .= '<option value="'.$key.'"';
1099 1196
 				$out .= (((string) $value == (string) $key) ? ' selected' : '');
1100 1197
 				$out .= (!empty($parent) ? ' parent="'.$parent.'"' : '');
1101 1198
 				$out .= '>';
1102
-				if ($langfile && $val) $out .= $langs->trans($val);
1103
-				else $out .= $val;
1199
+				if ($langfile && $val) {
1200
+					$out .= $langs->trans($val);
1201
+				} else {
1202
+					$out .= $val;
1203
+				}
1104 1204
 				$out .= '</option>';
1105 1205
 			}
1106 1206
 			$out .= '</select>';
@@ -1233,7 +1333,9 @@  discard block
 block discarded – undo
1233 1333
 									$translabel = $langs->trans($obj->{$InfoFieldList[1]});
1234 1334
 									$labeltoshow = $translabel;
1235 1335
 								}
1236
-								if (empty($labeltoshow)) $labeltoshow = '(not defined)';
1336
+								if (empty($labeltoshow)) {
1337
+									$labeltoshow = '(not defined)';
1338
+								}
1237 1339
 
1238 1340
 								if (!empty($InfoFieldList[3]) && $parentField) {
1239 1341
 									$parent = $parentName.':'.$obj->{$parentField};
@@ -1452,8 +1554,9 @@  discard block
 block discarded – undo
1452 1554
 										$labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18);
1453 1555
 									}
1454 1556
 								}
1455
-								if (empty($labeltoshow))
1456
-									$labeltoshow = '(not defined)';
1557
+								if (empty($labeltoshow)) {
1558
+																	$labeltoshow = '(not defined)';
1559
+								}
1457 1560
 
1458 1561
 								if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1459 1562
 									$data[$obj->rowid] = $labeltoshow;
@@ -1551,7 +1654,10 @@  discard block
 block discarded – undo
1551 1654
 			$hidden = (empty($list) ? 1 : 0); // If $list empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller)
1552 1655
 		}
1553 1656
 
1554
-		if ($hidden) return ''; // This is a protection. If field is hidden, we should just not call this method.
1657
+		if ($hidden) {
1658
+			return '';
1659
+		}
1660
+		// This is a protection. If field is hidden, we should just not call this method.
1555 1661
 
1556 1662
 		//if ($computed) $value =		// $value is already calculated into $value before calling this method
1557 1663
 
@@ -1594,15 +1700,20 @@  discard block
 block discarded – undo
1594 1700
 		} elseif ($type == 'price')
1595 1701
 		{
1596 1702
 			//$value = price($value, 0, $langs, 0, 0, -1, $conf->currency);
1597
-			if ($value || $value == '0') $value = price($value, 0, $langs, 0, 0, -1);
1703
+			if ($value || $value == '0') {
1704
+				$value = price($value, 0, $langs, 0, 0, -1);
1705
+			}
1598 1706
 		} elseif ($type == 'select') {
1599 1707
 			$valstr = $param['options'][$value];
1600 1708
 			if (($pos = strpos($valstr, "|")) !== false)
1601 1709
 			{
1602 1710
 				$valstr = substr($valstr, 0, $pos);
1603 1711
 			}
1604
-			if ($langfile && $valstr) $value = $langs->trans($valstr);
1605
-			else $value = $valstr;
1712
+			if ($langfile && $valstr) {
1713
+				$value = $langs->trans($valstr);
1714
+			} else {
1715
+				$value = $valstr;
1716
+			}
1606 1717
 		} elseif ($type == 'sellist') {
1607 1718
 			$param_list = array_keys($param['options']);
1608 1719
 			$InfoFieldList = explode(":", $param_list[0]);
@@ -1693,7 +1804,9 @@  discard block
 block discarded – undo
1693 1804
 					}
1694 1805
 					$value = '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>';
1695 1806
 				}
1696
-			} else dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
1807
+			} else {
1808
+				dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
1809
+			}
1697 1810
 		} elseif ($type == 'radio')
1698 1811
 		{
1699 1812
 			$value = $param['options'][$value];
@@ -1804,9 +1917,12 @@  discard block
 block discarded – undo
1804 1917
 			$out = '';
1805 1918
 
1806 1919
 			// Only if something to display (perf)
1807
-			if ($value)		// If we have -1 here, pb is into insert, not into ouptut (fix insert instead of changing code here to compensate)
1920
+			if ($value) {
1921
+				// If we have -1 here, pb is into insert, not into ouptut (fix insert instead of changing code here to compensate)
1808 1922
 			{
1809
-				$param_list = array_keys($param['options']); // $param_list='ObjectName:classPath'
1923
+				$param_list = array_keys($param['options']);
1924
+			}
1925
+			// $param_list='ObjectName:classPath'
1810 1926
 
1811 1927
 				$InfoFieldList = explode(":", $param_list[0]);
1812 1928
 				$classname = $InfoFieldList[0];
@@ -1836,7 +1952,9 @@  discard block
 block discarded – undo
1836 1952
 			$value = dol_trunc(preg_replace('/./i', '*', $value), 8, 'right', 'UTF-8', 1);
1837 1953
 		} else {
1838 1954
 			$showsize = round($size);
1839
-			if ($showsize > 48) $showsize = 48;
1955
+			if ($showsize > 48) {
1956
+				$showsize = 48;
1957
+			}
1840 1958
 		}
1841 1959
 
1842 1960
 		//print $type.'-'.$size;
@@ -1856,8 +1974,11 @@  discard block
 block discarded – undo
1856 1974
 	{
1857 1975
 		global $conf, $langs;
1858 1976
 
1859
-		if (!empty($extrafieldsobjectkey)) $type = $this->attributes[$extrafieldsobjectkey]['type'][$key];
1860
-		else $type = $this->attribute_type[$key];
1977
+		if (!empty($extrafieldsobjectkey)) {
1978
+			$type = $this->attributes[$extrafieldsobjectkey]['type'][$key];
1979
+		} else {
1980
+			$type = $this->attribute_type[$key];
1981
+		}
1861 1982
 
1862 1983
 		$align = '';
1863 1984
 
@@ -1967,18 +2088,26 @@  discard block
 block discarded – undo
1967 2088
 		$nofillrequired = 0; // For error when required field left blank
1968 2089
 		$error_field_required = array();
1969 2090
 
1970
-		if (is_array($this->attributes[$object->table_element]['label'])) $extralabels = $this->attributes[$object->table_element]['label'];
2091
+		if (is_array($this->attributes[$object->table_element]['label'])) {
2092
+			$extralabels = $this->attributes[$object->table_element]['label'];
2093
+		}
1971 2094
 
1972 2095
 		if (is_array($extralabels))
1973 2096
 		{
1974 2097
 			// Get extra fields
1975 2098
 			foreach ($extralabels as $key => $value)
1976 2099
 			{
1977
-				if (!empty($onlykey) && $onlykey != '@GETPOSTISSET' && $key != $onlykey) continue;
1978
-				if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && !GETPOSTISSET('options_'.$key)) continue;
2100
+				if (!empty($onlykey) && $onlykey != '@GETPOSTISSET' && $key != $onlykey) {
2101
+					continue;
2102
+				}
2103
+				if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && !GETPOSTISSET('options_'.$key)) {
2104
+					continue;
2105
+				}
1979 2106
 
1980 2107
 				$key_type = $this->attributes[$object->table_element]['type'][$key];
1981
-				if ($key_type == 'separate') continue;
2108
+				if ($key_type == 'separate') {
2109
+					continue;
2110
+				}
1982 2111
 
1983 2112
 				$enabled = 1;
1984 2113
 				if (isset($this->attributes[$object->table_element]['list'][$key]))
@@ -1990,10 +2119,15 @@  discard block
 block discarded – undo
1990 2119
 				{
1991 2120
 					$perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1);
1992 2121
 				}
1993
-				if (empty($enabled)) continue;
1994
-				if (empty($perms)) continue;
2122
+				if (empty($enabled)) {
2123
+					continue;
2124
+				}
2125
+				if (empty($perms)) {
2126
+					continue;
2127
+				}
1995 2128
 
1996
-				if ($this->attributes[$object->table_element]['required'][$key])	// Value is required
2129
+				if ($this->attributes[$object->table_element]['required'][$key]) {
2130
+					// Value is required
1997 2131
 				{
1998 2132
 					// Check if empty without using GETPOST, value can be alpha, int, array, etc...
1999 2133
 					if ((!is_array($_POST["options_".$key]) && empty($_POST["options_".$key]) && $this->attributes[$object->table_element]['type'][$key] != 'select' && $_POST["options_".$key] != '0')
@@ -2002,6 +2136,7 @@  discard block
 block discarded – undo
2002 2136
 					{
2003 2137
 						//print 'ccc'.$value.'-'.$this->attributes[$object->table_element]['required'][$key];
2004 2138
 						$nofillrequired++;
2139
+				}
2005 2140
 						$error_field_required[] = $langs->transnoentitiesnoconv($value);
2006 2141
 					}
2007 2142
 				}
@@ -2030,7 +2165,9 @@  discard block
 block discarded – undo
2030 2165
 					$value_key = GETPOST("options_".$key, 'alphanohtml');
2031 2166
 				} else {
2032 2167
 					$value_key = GETPOST("options_".$key);
2033
-					if (in_array($key_type, array('link')) && $value_key == '-1') $value_key = '';
2168
+					if (in_array($key_type, array('link')) && $value_key == '-1') {
2169
+						$value_key = '';
2170
+					}
2034 2171
 				}
2035 2172
 
2036 2173
 				$object->array_options["options_".$key] = $value_key;
@@ -2082,23 +2219,35 @@  discard block
 block discarded – undo
2082 2219
 
2083 2220
 				if (in_array($key_type, array('date', 'datetime')))
2084 2221
 				{
2085
-					if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix."year")) continue; // Value was not provided, we should not set it.
2222
+					if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix."year")) {
2223
+						continue;
2224
+					}
2225
+					// Value was not provided, we should not set it.
2086 2226
 					// Clean parameters
2087 2227
 					$value_key = dol_mktime(GETPOST($keysuffix."options_".$key.$keyprefix."hour", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."min", 'int'), 0, GETPOST($keysuffix."options_".$key.$keyprefix."month", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."day", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."year", 'int'));
2088 2228
 				} elseif (in_array($key_type, array('checkbox', 'chkbxlst')))
2089 2229
 				{
2090
-					if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it.
2230
+					if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) {
2231
+						continue;
2232
+					}
2233
+					// Value was not provided, we should not set it.
2091 2234
 					$value_arr = GETPOST($keysuffix."options_".$key.$keyprefix);
2092 2235
 					// Make sure we get an array even if there's only one checkbox
2093 2236
 					$value_arr = (array) $value_arr;
2094 2237
 					$value_key = implode(',', $value_arr);
2095 2238
 				} elseif (in_array($key_type, array('price', 'double', 'int')))
2096 2239
 				{
2097
-					if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it.
2240
+					if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) {
2241
+						continue;
2242
+					}
2243
+					// Value was not provided, we should not set it.
2098 2244
 					$value_arr = GETPOST($keysuffix."options_".$key.$keyprefix);
2099 2245
 					$value_key = price2num($value_arr);
2100 2246
 				} else {
2101
-					if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) continue; // Value was not provided, we should not set it.
2247
+					if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) {
2248
+						continue;
2249
+					}
2250
+					// Value was not provided, we should not set it.
2102 2251
 					$value_key = GETPOST($keysuffix."options_".$key.$keyprefix);
2103 2252
 				}
2104 2253
 
Please login to merge, or discard this patch.
htdocs/compta/bank/graph.php 1 patch
Braces   +90 added lines, -30 removed lines patch added patch discarded remove patch
@@ -40,12 +40,16 @@  discard block
 block discarded – undo
40 40
 	$id = isset($_GET["account"]) ? $_GET["account"] : (isset($_GET["ref"]) ? $_GET["ref"] : '');
41 41
 }
42 42
 $fieldid = isset($_GET["ref"]) ? 'ref' : 'rowid';
43
-if ($user->socid) $socid = $user->socid;
43
+if ($user->socid) {
44
+	$socid = $user->socid;
45
+}
44 46
 $result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid);
45 47
 
46 48
 $account = GETPOST("account");
47 49
 $mode = 'standard';
48
-if (GETPOST("mode") == 'showalltime') $mode = 'showalltime';
50
+if (GETPOST("mode") == 'showalltime') {
51
+	$mode = 'showalltime';
52
+}
49 53
 $error = 0;
50 54
 
51 55
 
@@ -63,15 +67,21 @@  discard block
 block discarded – undo
63 67
 $year = dol_print_date($datetime, "%Y");
64 68
 $month = dol_print_date($datetime, "%m");
65 69
 $day = dol_print_date($datetime, "%d");
66
-if (GETPOST("year"))  $year = sprintf("%04d", GETPOST("year"));
67
-if (GETPOST("month")) $month = sprintf("%02d", GETPOST("month"));
70
+if (GETPOST("year")) {
71
+	$year = sprintf("%04d", GETPOST("year"));
72
+}
73
+if (GETPOST("month")) {
74
+	$month = sprintf("%02d", GETPOST("month"));
75
+}
68 76
 
69 77
 
70 78
 $object = new Account($db);
71
-if ($_GET["account"] && !preg_match('/,/', $_GET["account"]))	// if for a particular account and not a list
79
+if ($_GET["account"] && !preg_match('/,/', $_GET["account"])) {
80
+	// if for a particular account and not a list
72 81
 {
73 82
 	$result = $object->fetch(GETPOST("account", "int"));
74 83
 }
84
+}
75 85
 if ($_GET["ref"])
76 86
 {
77 87
 	$result = $object->fetch(0, GETPOST("ref"));
@@ -91,7 +101,9 @@  discard block
 block discarded – undo
91 101
 	$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
92 102
 	$sql .= " WHERE b.fk_account = ba.rowid";
93 103
 	$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
94
-	if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")";
104
+	if ($account && $_GET["option"] != 'all') {
105
+		$sql .= " AND b.fk_account IN (".$account.")";
106
+	}
95 107
 
96 108
 	$resql = $db->query($sql);
97 109
 	if ($resql)
@@ -103,7 +115,9 @@  discard block
 block discarded – undo
103 115
 	} else {
104 116
 		dol_print_error($db);
105 117
 	}
106
-	if (empty($min)) $min = dol_now() - 3600 * 24;
118
+	if (empty($min)) {
119
+		$min = dol_now() - 3600 * 24;
120
+	}
107 121
 
108 122
 	$log = "graph.php: min=".$min." max=".$max;
109 123
 	dol_syslog($log);
@@ -132,7 +146,9 @@  discard block
 block discarded – undo
132 146
 		$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
133 147
 		$sql .= " AND b.datev >= '".$db->escape($year)."-".$db->escape($month)."-01 00:00:00'";
134 148
 		$sql .= " AND b.datev < '".$db->escape($yearnext)."-".$db->escape($monthnext)."-01 00:00:00'";
135
-		if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")";
149
+		if ($account && $_GET["option"] != 'all') {
150
+			$sql .= " AND b.fk_account IN (".$account.")";
151
+		}
136 152
 		$sql .= " GROUP BY date_format(b.datev,'%Y%m%d')";
137 153
 
138 154
 		$resql = $db->query($sql);
@@ -160,7 +176,9 @@  discard block
 block discarded – undo
160 176
 		$sql .= " WHERE b.fk_account = ba.rowid";
161 177
 		$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
162 178
 		$sql .= " AND b.datev < '".$db->escape($year)."-".sprintf("%02s", $month)."-01'";
163
-		if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")";
179
+		if ($account && $_GET["option"] != 'all') {
180
+			$sql .= " AND b.fk_account IN (".$account.")";
181
+		}
164 182
 
165 183
 		$resql = $db->query($sql);
166 184
 		if ($resql)
@@ -222,15 +240,23 @@  discard block
 block discarded – undo
222 240
 		foreach ($datas as $i => $val)
223 241
 		{
224 242
 			$graph_datas[$i] = array(isset($labels[$i]) ? $labels[$i] : '', $datas[$i]);
225
-			if ($object->min_desired) array_push($graph_datas[$i], $datamin[$i]);
226
-			if ($object->min_allowed) array_push($graph_datas[$i], $dataall[$i]);
243
+			if ($object->min_desired) {
244
+				array_push($graph_datas[$i], $datamin[$i]);
245
+			}
246
+			if ($object->min_allowed) {
247
+				array_push($graph_datas[$i], $dataall[$i]);
248
+			}
227 249
 		}
228 250
 
229 251
 		$px1 = new DolGraph();
230 252
 		$px1->SetData($graph_datas);
231 253
 		$arraylegends = array($langs->transnoentities("Balance"));
232
-		if ($object->min_desired) array_push($arraylegends, $langs->transnoentities("BalanceMinimalDesired"));
233
-		if ($object->min_allowed) array_push($arraylegends, $langs->transnoentities("BalanceMinimalAllowed"));
254
+		if ($object->min_desired) {
255
+			array_push($arraylegends, $langs->transnoentities("BalanceMinimalDesired"));
256
+		}
257
+		if ($object->min_allowed) {
258
+			array_push($arraylegends, $langs->transnoentities("BalanceMinimalAllowed"));
259
+		}
234 260
 		$px1->SetLegend($arraylegends);
235 261
 		$px1->SetLegendWidthMin(180);
236 262
 		$px1->SetMaxValue($px1->GetCeilMaxValue() < 0 ? 0 : $px1->GetCeilMaxValue());
@@ -269,7 +295,9 @@  discard block
 block discarded – undo
269 295
 		$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
270 296
 		$sql .= " AND b.datev >= '".$db->escape($year)."-01-01 00:00:00'";
271 297
 		$sql .= " AND b.datev <= '".$db->escape($year)."-12-31 23:59:59'";
272
-		if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")";
298
+		if ($account && $_GET["option"] != 'all') {
299
+			$sql .= " AND b.fk_account IN (".$account.")";
300
+		}
273 301
 		$sql .= " GROUP BY date_format(b.datev,'%Y%m%d')";
274 302
 
275 303
 		$resql = $db->query($sql);
@@ -297,7 +325,9 @@  discard block
 block discarded – undo
297 325
 		$sql .= " WHERE b.fk_account = ba.rowid";
298 326
 		$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
299 327
 		$sql .= " AND b.datev < '".$db->escape($year)."-01-01'";
300
-		if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")";
328
+		if ($account && $_GET["option"] != 'all') {
329
+			$sql .= " AND b.fk_account IN (".$account.")";
330
+		}
301 331
 
302 332
 		$resql = $db->query($sql);
303 333
 		if ($resql)
@@ -354,14 +384,22 @@  discard block
 block discarded – undo
354 384
 		foreach ($datas as $i => $val)
355 385
 		{
356 386
 			$graph_datas[$i] = array(isset($labels[$i]) ? $labels[$i] : '', $datas[$i]);
357
-			if ($object->min_desired) array_push($graph_datas[$i], $datamin[$i]);
358
-			if ($object->min_allowed) array_push($graph_datas[$i], $dataall[$i]);
387
+			if ($object->min_desired) {
388
+				array_push($graph_datas[$i], $datamin[$i]);
389
+			}
390
+			if ($object->min_allowed) {
391
+				array_push($graph_datas[$i], $dataall[$i]);
392
+			}
359 393
 		}
360 394
 		$px2 = new DolGraph();
361 395
 		$px2->SetData($graph_datas);
362 396
 		$arraylegends = array($langs->transnoentities("Balance"));
363
-		if ($object->min_desired) array_push($arraylegends, $langs->transnoentities("BalanceMinimalDesired"));
364
-		if ($object->min_allowed) array_push($arraylegends, $langs->transnoentities("BalanceMinimalAllowed"));
397
+		if ($object->min_desired) {
398
+			array_push($arraylegends, $langs->transnoentities("BalanceMinimalDesired"));
399
+		}
400
+		if ($object->min_allowed) {
401
+			array_push($arraylegends, $langs->transnoentities("BalanceMinimalAllowed"));
402
+		}
365 403
 		$px2->SetLegend($arraylegends);
366 404
 		$px2->SetLegendWidthMin(180);
367 405
 		$px2->SetMaxValue($px2->GetCeilMaxValue() < 0 ? 0 : $px2->GetCeilMaxValue());
@@ -400,7 +438,9 @@  discard block
 block discarded – undo
400 438
 		$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
401 439
 		$sql .= " WHERE b.fk_account = ba.rowid";
402 440
 		$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
403
-		if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")";
441
+		if ($account && $_GET["option"] != 'all') {
442
+			$sql .= " AND b.fk_account IN (".$account.")";
443
+		}
404 444
 		$sql .= " GROUP BY date_format(b.datev,'%Y%m%d')";
405 445
 
406 446
 		$resql = $db->query($sql);
@@ -434,9 +474,11 @@  discard block
 block discarded – undo
434 474
 		$textdate = strftime("%Y%m%d", $day);
435 475
 		//print "x".$textdate;
436 476
 		$i = 0;
437
-		while ($day <= ($max + 86400))	// On va au dela du dernier jour
477
+		while ($day <= ($max + 86400)) {
478
+			// On va au dela du dernier jour
438 479
 		{
439 480
 			$subtotal = $subtotal + (isset($amounts[$textdate]) ? $amounts[$textdate] : 0);
481
+		}
440 482
 			//print strftime ("%e %d %m %y",$day)." ".$subtotal."\n<br>";
441 483
 			if ($day > ($max + 86400))
442 484
 			{
@@ -465,15 +507,23 @@  discard block
 block discarded – undo
465 507
 		foreach ($datas as $i => $val)
466 508
 		{
467 509
 			$graph_datas[$i] = array(isset($labels[$i]) ? $labels[$i] : '', $datas[$i]);
468
-			if ($object->min_desired) array_push($graph_datas[$i], $datamin[$i]);
469
-			if ($object->min_allowed) array_push($graph_datas[$i], $dataall[$i]);
510
+			if ($object->min_desired) {
511
+				array_push($graph_datas[$i], $datamin[$i]);
512
+			}
513
+			if ($object->min_allowed) {
514
+				array_push($graph_datas[$i], $dataall[$i]);
515
+			}
470 516
 		}
471 517
 
472 518
 		$px3 = new DolGraph();
473 519
 		$px3->SetData($graph_datas);
474 520
 		$arraylegends = array($langs->transnoentities("Balance"));
475
-		if ($object->min_desired) array_push($arraylegends, $langs->transnoentities("BalanceMinimalDesired"));
476
-		if ($object->min_allowed) array_push($arraylegends, $langs->transnoentities("BalanceMinimalAllowed"));
521
+		if ($object->min_desired) {
522
+			array_push($arraylegends, $langs->transnoentities("BalanceMinimalDesired"));
523
+		}
524
+		if ($object->min_allowed) {
525
+			array_push($arraylegends, $langs->transnoentities("BalanceMinimalAllowed"));
526
+		}
477 527
 		$px3->SetLegend($arraylegends);
478 528
 		$px3->SetLegendWidthMin(180);
479 529
 		$px3->SetMaxValue($px3->GetCeilMaxValue() < 0 ? 0 : $px3->GetCeilMaxValue());
@@ -522,7 +572,9 @@  discard block
 block discarded – undo
522 572
 		$sql .= " AND b.datev >= '".$db->escape($year)."-".$db->escape($month)."-01 00:00:00'";
523 573
 		$sql .= " AND b.datev < '".$db->escape($yearnext)."-".$db->escape($monthnext)."-01 00:00:00'";
524 574
 		$sql .= " AND b.amount > 0";
525
-		if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")";
575
+		if ($account && $_GET["option"] != 'all') {
576
+			$sql .= " AND b.fk_account IN (".$account.")";
577
+		}
526 578
 		$sql .= " GROUP BY date_format(b.datev,'%d')";
527 579
 
528 580
 		$resql = $db->query($sql);
@@ -558,7 +610,9 @@  discard block
 block discarded – undo
558 610
 		$sql .= " AND b.datev >= '".$db->escape($year)."-".$db->escape($month)."-01 00:00:00'";
559 611
 		$sql .= " AND b.datev < '".$db->escape($yearnext)."-".$db->escape($monthnext)."-01 00:00:00'";
560 612
 		$sql .= " AND b.amount < 0";
561
-		if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")";
613
+		if ($account && $_GET["option"] != 'all') {
614
+			$sql .= " AND b.fk_account IN (".$account.")";
615
+		}
562 616
 		$sql .= " GROUP BY date_format(b.datev,'%d')";
563 617
 
564 618
 		$resql = $db->query($sql);
@@ -635,7 +689,9 @@  discard block
 block discarded – undo
635 689
 		$sql .= " AND b.datev >= '".$db->escape($year)."-01-01 00:00:00'";
636 690
 		$sql .= " AND b.datev <= '".$db->escape($year)."-12-31 23:59:59'";
637 691
 		$sql .= " AND b.amount > 0";
638
-		if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")";
692
+		if ($account && $_GET["option"] != 'all') {
693
+			$sql .= " AND b.fk_account IN (".$account.")";
694
+		}
639 695
 		$sql .= " GROUP BY date_format(b.datev,'%m');";
640 696
 
641 697
 		$resql = $db->query($sql);
@@ -662,7 +718,9 @@  discard block
 block discarded – undo
662 718
 		$sql .= " AND b.datev >= '".$db->escape($year)."-01-01 00:00:00'";
663 719
 		$sql .= " AND b.datev <= '".$db->escape($year)."-12-31 23:59:59'";
664 720
 		$sql .= " AND b.amount < 0";
665
-		if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")";
721
+		if ($account && $_GET["option"] != 'all') {
722
+			$sql .= " AND b.fk_account IN (".$account.")";
723
+		}
666 724
 		$sql .= " GROUP BY date_format(b.datev,'%m')";
667 725
 
668 726
 		$resql = $db->query($sql);
@@ -755,7 +813,9 @@  discard block
 block discarded – undo
755 813
 			$bankaccount->fetch($id);
756 814
 			$bankaccount->label = $bankaccount->ref;
757 815
 			print $bankaccount->getNomUrl(1);
758
-			if ($key < (count($listid) - 1)) print ', ';
816
+			if ($key < (count($listid) - 1)) {
817
+				print ', ';
818
+			}
759 819
 		}
760 820
 	}
761 821
 } else {
Please login to merge, or discard this patch.
htdocs/accountancy/expensereport/index.php 1 patch
Braces   +44 added lines, -16 removed lines patch added patch discarded remove patch
@@ -36,16 +36,22 @@  discard block
 block discarded – undo
36 36
 if (empty($conf->accounting->enabled)) {
37 37
 	accessforbidden();
38 38
 }
39
-if ($user->socid > 0)
39
+if ($user->socid > 0) {
40 40
 	accessforbidden();
41
-if (!$user->rights->accounting->bind->write)
41
+}
42
+if (!$user->rights->accounting->bind->write) {
42 43
 	accessforbidden();
44
+}
43 45
 
44 46
 $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
45
-if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
46
-else {
47
+if (GETPOST("year", 'int')) {
48
+	$year_start = GETPOST("year", 'int');
49
+} else {
47 50
 	$year_start = dol_print_date(dol_now(), '%Y');
48
-	if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
51
+	if (dol_print_date(dol_now(), '%m') < $month_start) {
52
+		$year_start--;
53
+	}
54
+	// If current month is lower that starting fiscal month, we start last year
49 55
 }
50 56
 $year_end = $year_start + 1;
51 57
 $month_end = $month_start - 1;
@@ -156,7 +162,9 @@  discard block
 block discarded – undo
156 162
 print '<td width="200" class="left">'.$langs->trans("Label").'</td>';
157 163
 for ($i = 1; $i <= 12; $i++) {
158 164
 	$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
159
-	if ($j > 12) $j -= 12;
165
+	if ($j > 12) {
166
+		$j -= 12;
167
+	}
160 168
 	print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
161 169
 }
162 170
 print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@@ -165,7 +173,9 @@  discard block
 block discarded – undo
165 173
 $sql .= "  ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
166 174
 for ($i = 1; $i <= 12; $i++) {
167 175
 	$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
168
-	if ($j > 12) $j -= 12;
176
+	if ($j > 12) {
177
+		$j -= 12;
178
+	}
169 179
 	$sql .= "  SUM(".$db->ifsql('MONTH(er.date_debut)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
170 180
 }
171 181
 $sql .= " SUM(erd.total_ht) as total";
@@ -193,13 +203,17 @@  discard block
 block discarded – undo
193 203
 		if ($row[0] == 'tobind')
194 204
 		{
195 205
 			print $langs->trans("Unknown");
196
-		} else print length_accountg($row[0]);
206
+		} else {
207
+			print length_accountg($row[0]);
208
+		}
197 209
 		print '</td>';
198 210
 		print '<td class="left">';
199 211
 		if ($row[0] == 'tobind')
200 212
 		{
201 213
 			print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
202
-		} else print $row[1];
214
+		} else {
215
+			print $row[1];
216
+		}
203 217
 		print '</td>';
204 218
 		for ($i = 2; $i <= 12; $i++) {
205 219
 			print '<td class="nowrap right">'.price($row[$i]).'</td>';
@@ -229,7 +243,9 @@  discard block
 block discarded – undo
229 243
 print '<td width="200" class="left">'.$langs->trans("Label").'</td>';
230 244
 for ($i = 1; $i <= 12; $i++) {
231 245
 	$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
232
-	if ($j > 12) $j -= 12;
246
+	if ($j > 12) {
247
+		$j -= 12;
248
+	}
233 249
 	print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
234 250
 }
235 251
 print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@@ -238,7 +254,9 @@  discard block
 block discarded – undo
238 254
 $sql .= "  ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
239 255
 for ($i = 1; $i <= 12; $i++) {
240 256
 	$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
241
-	if ($j > 12) $j -= 12;
257
+	if ($j > 12) {
258
+		$j -= 12;
259
+	}
242 260
 	$sql .= "  SUM(".$db->ifsql('MONTH(er.date_debut)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
243 261
 }
244 262
 $sql .= " ROUND(SUM(erd.total_ht),2) as total";
@@ -266,14 +284,18 @@  discard block
 block discarded – undo
266 284
 		if ($row[0] == 'tobind')
267 285
 		{
268 286
 			print $langs->trans("Unknown");
269
-		} else print length_accountg($row[0]);
287
+		} else {
288
+			print length_accountg($row[0]);
289
+		}
270 290
 		print '</td>';
271 291
 
272 292
 		print '<td class="left">';
273 293
 		if ($row[0] == 'tobind')
274 294
 		{
275 295
 			print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
276
-		} else print $row[1];
296
+		} else {
297
+			print $row[1];
298
+		}
277 299
 		print '</td>';
278 300
 		for ($i = 2; $i <= 12; $i++) {
279 301
 			print '<td class="nowrap right">'.price($row[$i]).'</td>';
@@ -291,9 +313,11 @@  discard block
 block discarded – undo
291 313
 
292 314
 
293 315
 
294
-if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report where results depends on next step (so not yet available) ?
316
+if ($conf->global->MAIN_FEATURES_LEVEL > 0) {
317
+	// This part of code looks strange. Why showing a report where results depends on next step (so not yet available) ?
295 318
 {
296 319
 	print '<br>';
320
+}
297 321
 	print '<br>';
298 322
 
299 323
 	print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
@@ -304,7 +328,9 @@  discard block
 block discarded – undo
304 328
 	print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>';
305 329
 	for ($i = 1; $i <= 12; $i++) {
306 330
 		$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
307
-		if ($j > 12) $j -= 12;
331
+		if ($j > 12) {
332
+			$j -= 12;
333
+		}
308 334
 		print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
309 335
 	}
310 336
 	print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@@ -312,7 +338,9 @@  discard block
 block discarded – undo
312 338
 	$sql = "SELECT '".$db->escape($langs->trans("TotalExpenseReport"))."' AS label,";
313 339
 	for ($i = 1; $i <= 12; $i++) {
314 340
 		$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
315
-		if ($j > 12) $j -= 12;
341
+		if ($j > 12) {
342
+			$j -= 12;
343
+		}
316 344
 		$sql .= " SUM(".$db->ifsql('MONTH(er.date_create)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
317 345
 	}
318 346
 	$sql .= " SUM(erd.total_ht) as total";
Please login to merge, or discard this patch.
htdocs/accountancy/supplier/index.php 1 patch
Braces   +44 added lines, -16 removed lines patch added patch discarded remove patch
@@ -37,17 +37,23 @@  discard block
 block discarded – undo
37 37
 if (empty($conf->accounting->enabled)) {
38 38
 	accessforbidden();
39 39
 }
40
-if ($user->socid > 0)
40
+if ($user->socid > 0) {
41 41
 	accessforbidden();
42
-if (!$user->rights->accounting->bind->write)
42
+}
43
+if (!$user->rights->accounting->bind->write) {
43 44
 	accessforbidden();
45
+}
44 46
 
45 47
 
46 48
 $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
47
-if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
48
-else {
49
+if (GETPOST("year", 'int')) {
50
+	$year_start = GETPOST("year", 'int');
51
+} else {
49 52
 	$year_start = dol_print_date(dol_now(), '%Y');
50
-	if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
53
+	if (dol_print_date(dol_now(), '%m') < $month_start) {
54
+		$year_start--;
55
+	}
56
+	// If current month is lower that starting fiscal month, we start last year
51 57
 }
52 58
 $year_end = $year_start + 1;
53 59
 $month_end = $month_start - 1;
@@ -227,7 +233,9 @@  discard block
 block discarded – undo
227 233
 print '<td width="200" class="left">'.$langs->trans("Label").'</td>';
228 234
 for ($i = 1; $i <= 12; $i++) {
229 235
 	$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
230
-	if ($j > 12) $j -= 12;
236
+	if ($j > 12) {
237
+		$j -= 12;
238
+	}
231 239
 	print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
232 240
 }
233 241
 print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@@ -236,7 +244,9 @@  discard block
 block discarded – undo
236 244
 $sql .= "  ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
237 245
 for ($i = 1; $i <= 12; $i++) {
238 246
 	$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
239
-	if ($j > 12) $j -= 12;
247
+	if ($j > 12) {
248
+		$j -= 12;
249
+	}
240 250
 	$sql .= "  SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
241 251
 }
242 252
 $sql .= "  SUM(ffd.total_ht) as total";
@@ -265,13 +275,17 @@  discard block
 block discarded – undo
265 275
 		if ($row[0] == 'tobind')
266 276
 		{
267 277
 			print $langs->trans("Unknown");
268
-		} else print length_accountg($row[0]);
278
+		} else {
279
+			print length_accountg($row[0]);
280
+		}
269 281
 		print '</td>';
270 282
 		print '<td class="left">';
271 283
 		if ($row[0] == 'tobind')
272 284
 		{
273 285
 			print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
274
-		} else print $row[1];
286
+		} else {
287
+			print $row[1];
288
+		}
275 289
 		print '</td>';
276 290
 		for ($i = 2; $i <= 12; $i++) {
277 291
 			print '<td class="nowrap right">'.price($row[$i]).'</td>';
@@ -300,7 +314,9 @@  discard block
 block discarded – undo
300 314
 print '<td width="200" class="left">'.$langs->trans("Label").'</td>';
301 315
 for ($i = 1; $i <= 12; $i++) {
302 316
 	$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
303
-	if ($j > 12) $j -= 12;
317
+	if ($j > 12) {
318
+		$j -= 12;
319
+	}
304 320
 	print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
305 321
 }
306 322
 print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@@ -309,7 +325,9 @@  discard block
 block discarded – undo
309 325
 $sql .= "  ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
310 326
 for ($i = 1; $i <= 12; $i++) {
311 327
 	$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
312
-	if ($j > 12) $j -= 12;
328
+	if ($j > 12) {
329
+		$j -= 12;
330
+	}
313 331
 	$sql .= "  SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
314 332
 }
315 333
 $sql .= "  SUM(ffd.total_ht) as total";
@@ -338,13 +356,17 @@  discard block
 block discarded – undo
338 356
 		if ($row[0] == 'tobind')
339 357
 		{
340 358
 			print $langs->trans("Unknown");
341
-		} else print length_accountg($row[0]);
359
+		} else {
360
+			print length_accountg($row[0]);
361
+		}
342 362
 		print '</td>';
343 363
 		print '<td class="left">';
344 364
 		if ($row[0] == 'tobind')
345 365
 		{
346 366
 			print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
347
-		} else print $row[1];
367
+		} else {
368
+			print $row[1];
369
+		}
348 370
 		print '</td>';
349 371
 		for ($i = 2; $i <= 12; $i++) {
350 372
 			print '<td class="nowrap right">'.price($row[$i]).'</td>';
@@ -362,9 +384,11 @@  discard block
 block discarded – undo
362 384
 
363 385
 
364 386
 
365
-if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ?
387
+if ($conf->global->MAIN_FEATURES_LEVEL > 0) {
388
+	// This part of code looks strange. Why showing a report that should rely on result of this step ?
366 389
 {
367 390
 	print '<br>';
391
+}
368 392
 	print '<br>';
369 393
 
370 394
 	print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
@@ -375,7 +399,9 @@  discard block
 block discarded – undo
375 399
 	print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>';
376 400
 	for ($i = 1; $i <= 12; $i++) {
377 401
 		$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
378
-		if ($j > 12) $j -= 12;
402
+		if ($j > 12) {
403
+			$j -= 12;
404
+		}
379 405
 		print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
380 406
 	}
381 407
 	print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@@ -383,7 +409,9 @@  discard block
 block discarded – undo
383 409
 	$sql = "SELECT '".$db->escape($langs->trans("CAHTF"))."' AS label,";
384 410
 	for ($i = 1; $i <= 12; $i++) {
385 411
 		$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
386
-		if ($j > 12) $j -= 12;
412
+		if ($j > 12) {
413
+			$j -= 12;
414
+		}
387 415
 		$sql .= "  SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
388 416
 	}
389 417
 	$sql .= "  SUM(ffd.total_ht) as total";
Please login to merge, or discard this patch.
htdocs/accountancy/class/lettering.class.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -67,12 +67,15 @@  discard block
 block discarded – undo
67 67
 		$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk";
68 68
 		$sql .= " LEFT JOIN  ".MAIN_DB_PREFIX."bank_url as bu ON(bk.fk_doc = bu.fk_bank AND bu.type IN ('payment', 'payment_supplier') ) ";
69 69
 		$sql .= " WHERE ( ";
70
-		if ($object->code_compta != "")
71
-			$sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."'  ";
72
-		if ($object->code_compta != "" && $object->code_compta_fournisseur != "")
73
-			$sql .= " OR ";
74
-		if ($object->code_compta_fournisseur != "")
75
-			$sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_fournisseur)."' ";
70
+		if ($object->code_compta != "") {
71
+					$sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."'  ";
72
+		}
73
+		if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
74
+					$sql .= " OR ";
75
+		}
76
+		if ($object->code_compta_fournisseur != "") {
77
+					$sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_fournisseur)."' ";
78
+		}
76 79
 
77 80
 		$sql .= " ) AND (bk.date_lettering ='' OR bk.date_lettering IS NULL) ";
78 81
 		$sql .= "  AND (bk.lettering_code != '' OR bk.lettering_code IS NULL) ";
@@ -244,8 +247,9 @@  discard block
 block discarded – undo
244 247
 		if ($result) {
245 248
 			$obj = $this->db->fetch_object($result);
246 249
 			$lettre = (empty($obj->lettering_code) ? 'AAA' : $obj->lettering_code);
247
-			if (!empty($obj->lettering_code))
248
-				$lettre++;
250
+			if (!empty($obj->lettering_code)) {
251
+							$lettre++;
252
+			}
249 253
 		} else {
250 254
 			$this->errors[] = 'Error'.$this->db->lasterror();
251 255
 			$error++;
Please login to merge, or discard this patch.
htdocs/accountancy/customer/index.php 1 patch
Braces   +50 added lines, -18 removed lines patch added patch discarded remove patch
@@ -39,17 +39,23 @@  discard block
 block discarded – undo
39 39
 if (empty($conf->accounting->enabled)) {
40 40
 	accessforbidden();
41 41
 }
42
-if ($user->socid > 0)
42
+if ($user->socid > 0) {
43 43
 	accessforbidden();
44
-if (!$user->rights->accounting->bind->write)
44
+}
45
+if (!$user->rights->accounting->bind->write) {
45 46
 	accessforbidden();
47
+}
46 48
 
47 49
 
48 50
 $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
49
-if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
50
-else {
51
+if (GETPOST("year", 'int')) {
52
+	$year_start = GETPOST("year", 'int');
53
+} else {
51 54
 	$year_start = dol_print_date(dol_now(), '%Y');
52
-	if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
55
+	if (dol_print_date(dol_now(), '%m') < $month_start) {
56
+		$year_start--;
57
+	}
58
+	// If current month is lower that starting fiscal month, we start last year
53 59
 }
54 60
 $year_end = $year_start + 1;
55 61
 $month_end = $month_start - 1;
@@ -238,7 +244,9 @@  discard block
 block discarded – undo
238 244
 print '<td width="200" class="left">'.$langs->trans("Label").'</td>';
239 245
 for ($i = 1; $i <= 12; $i++) {
240 246
 	$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
241
-	if ($j > 12) $j -= 12;
247
+	if ($j > 12) {
248
+		$j -= 12;
249
+	}
242 250
 	print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
243 251
 }
244 252
 print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@@ -247,7 +255,9 @@  discard block
 block discarded – undo
247 255
 $sql .= "  ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
248 256
 for ($i = 1; $i <= 12; $i++) {
249 257
 	$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
250
-	if ($j > 12) $j -= 12;
258
+	if ($j > 12) {
259
+		$j -= 12;
260
+	}
251 261
 	$sql .= "  SUM(".$db->ifsql('MONTH(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
252 262
 }
253 263
 $sql .= "  SUM(fd.total_ht) as total";
@@ -281,13 +291,17 @@  discard block
 block discarded – undo
281 291
 		if ($row[0] == 'tobind')
282 292
 		{
283 293
 			print $langs->trans("Unknown");
284
-		} else print length_accountg($row[0]);
294
+		} else {
295
+			print length_accountg($row[0]);
296
+		}
285 297
 		print '</td>';
286 298
 		print '<td class="left">';
287 299
 		if ($row[0] == 'tobind')
288 300
 		{
289 301
 			print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
290
-		} else print $row[1];
302
+		} else {
303
+			print $row[1];
304
+		}
291 305
 		print '</td>';
292 306
 		for ($i = 2; $i <= 12; $i++) {
293 307
 			print '<td class="nowrap right">'.price($row[$i]).'</td>';
@@ -316,7 +330,9 @@  discard block
 block discarded – undo
316 330
 print '<td width="200" class="left">'.$langs->trans("Label").'</td>';
317 331
 for ($i = 1; $i <= 12; $i++) {
318 332
 	$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
319
-	if ($j > 12) $j -= 12;
333
+	if ($j > 12) {
334
+		$j -= 12;
335
+	}
320 336
 	print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
321 337
 }
322 338
 print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@@ -325,7 +341,9 @@  discard block
 block discarded – undo
325 341
 $sql .= "  ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
326 342
 for ($i = 1; $i <= 12; $i++) {
327 343
 	$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
328
-	if ($j > 12) $j -= 12;
344
+	if ($j > 12) {
345
+		$j -= 12;
346
+	}
329 347
 	$sql .= "  SUM(".$db->ifsql('MONTH(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
330 348
 }
331 349
 $sql .= "  SUM(fd.total_ht) as total";
@@ -359,14 +377,18 @@  discard block
 block discarded – undo
359 377
 		if ($row[0] == 'tobind')
360 378
 		{
361 379
 			print $langs->trans("Unknown");
362
-		} else print length_accountg($row[0]);
380
+		} else {
381
+			print length_accountg($row[0]);
382
+		}
363 383
 		print '</td>';
364 384
 
365 385
 		print '<td class="left">';
366 386
 		if ($row[0] == 'tobind')
367 387
 		{
368 388
 			print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
369
-		} else print $row[1];
389
+		} else {
390
+			print $row[1];
391
+		}
370 392
 		print '</td>';
371 393
 
372 394
 		for ($i = 2; $i <= 12; $i++) {
@@ -384,9 +406,11 @@  discard block
 block discarded – undo
384 406
 print '</div>';
385 407
 
386 408
 
387
-if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ?
409
+if ($conf->global->MAIN_FEATURES_LEVEL > 0) {
410
+	// This part of code looks strange. Why showing a report that should rely on result of this step ?
388 411
 {
389 412
 	print '<br>';
413
+}
390 414
 	print '<br>';
391 415
 
392 416
 	print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
@@ -397,7 +421,9 @@  discard block
 block discarded – undo
397 421
 	print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("TotalVente").'</td>';
398 422
 	for ($i = 1; $i <= 12; $i++) {
399 423
 		$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
400
-		if ($j > 12) $j -= 12;
424
+		if ($j > 12) {
425
+			$j -= 12;
426
+		}
401 427
 		print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
402 428
 	}
403 429
 	print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@@ -405,7 +431,9 @@  discard block
 block discarded – undo
405 431
 	$sql = "SELECT '".$db->escape($langs->trans("TotalVente"))."' AS total,";
406 432
 	for ($i = 1; $i <= 12; $i++) {
407 433
 		$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
408
-		if ($j > 12) $j -= 12;
434
+		if ($j > 12) {
435
+			$j -= 12;
436
+		}
409 437
 		$sql .= "  SUM(".$db->ifsql('MONTH(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
410 438
 	}
411 439
 	$sql .= "  SUM(fd.total_ht) as total";
@@ -454,7 +482,9 @@  discard block
 block discarded – undo
454 482
 		print '<tr class="liste_titre"><td width="400">'.$langs->trans("TotalMarge").'</td>';
455 483
 		for ($i = 1; $i <= 12; $i++) {
456 484
 			$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
457
-			if ($j > 12) $j -= 12;
485
+			if ($j > 12) {
486
+				$j -= 12;
487
+			}
458 488
 			print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
459 489
 		}
460 490
 		print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@@ -462,7 +492,9 @@  discard block
 block discarded – undo
462 492
 		$sql = "SELECT '".$db->escape($langs->trans("Vide"))."' AS marge,";
463 493
 		for ($i = 1; $i <= 12; $i++) {
464 494
 			$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
465
-			if ($j > 12) $j -= 12;
495
+			if ($j > 12) {
496
+				$j -= 12;
497
+			}
466 498
 			$sql .= "  SUM(".$db->ifsql('MONTH(f.datef)='.$j, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
467 499
 		}
468 500
 		$sql .= "  SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total";
Please login to merge, or discard this patch.
htdocs/install/lib/repair.lib.php 1 patch
Braces   +40 added lines, -15 removed lines patch added patch discarded remove patch
@@ -38,9 +38,15 @@  discard block
 block discarded – undo
38 38
 	if ($resql)
39 39
 	{
40 40
 		$num = $db->num_rows($resql);
41
-		if ($num > 0) return true;
42
-		else return false;
43
-	} else return true; // for security
41
+		if ($num > 0) {
42
+			return true;
43
+		} else {
44
+			return false;
45
+		}
46
+	} else {
47
+		return true;
48
+	}
49
+	// for security
44 50
 }
45 51
 
46 52
 /**
@@ -60,14 +66,26 @@  discard block
 block discarded – undo
60 66
 	$sourcetable = $sourcetype;
61 67
 	$targettable = $targettype;
62 68
 
63
-	if ($sourcetype == 'shipping') $sourcetable = 'expedition';
64
-	elseif ($targettype == 'shipping') $targettable = 'expedition';
65
-	if ($sourcetype == 'delivery') $sourcetable = 'livraison';
66
-	elseif ($targettype == 'delivery') $targettable = 'livraison';
67
-	if ($sourcetype == 'order_supplier') $sourcetable = 'commande_fournisseur';
68
-	elseif ($targettype == 'order_supplier') $targettable = 'commande_fournisseur';
69
-	if ($sourcetype == 'invoice_supplier') $sourcetable = 'facture_fourn';
70
-	elseif ($targettype == 'invoice_supplier') $targettable = 'facture_fourn';
69
+	if ($sourcetype == 'shipping') {
70
+		$sourcetable = 'expedition';
71
+	} elseif ($targettype == 'shipping') {
72
+		$targettable = 'expedition';
73
+	}
74
+	if ($sourcetype == 'delivery') {
75
+		$sourcetable = 'livraison';
76
+	} elseif ($targettype == 'delivery') {
77
+		$targettable = 'livraison';
78
+	}
79
+	if ($sourcetype == 'order_supplier') {
80
+		$sourcetable = 'commande_fournisseur';
81
+	} elseif ($targettype == 'order_supplier') {
82
+		$targettable = 'commande_fournisseur';
83
+	}
84
+	if ($sourcetype == 'invoice_supplier') {
85
+		$sourcetable = 'facture_fourn';
86
+	} elseif ($targettype == 'invoice_supplier') {
87
+		$targettable = 'facture_fourn';
88
+	}
71 89
 
72 90
 	$out = $langs->trans('SourceType').': '.$sourcetype.' => '.$langs->trans('TargetType').': '.$targettype.' ';
73 91
 
@@ -103,8 +121,11 @@  discard block
 block discarded – undo
103 121
 		}
104 122
 	}
105 123
 
106
-	if ($deleted) $out .= '('.$langs->trans('LinkedElementsInvalidDeleted', $deleted).')<br>';
107
-	else $out .= '('.$langs->trans('NothingToDelete').')<br>';
124
+	if ($deleted) {
125
+		$out .= '('.$langs->trans('LinkedElementsInvalidDeleted', $deleted).')<br>';
126
+	} else {
127
+		$out .= '('.$langs->trans('NothingToDelete').')<br>';
128
+	}
108 129
 
109 130
 	return $out;
110 131
 }
@@ -133,10 +154,14 @@  discard block
 block discarded – undo
133 154
 				$sqlupdate = "UPDATE ".MAIN_DB_PREFIX."ecm_directories set label='".$db->escape($newlabel)."' WHERE rowid=".$id;
134 155
 				print '<tr><td>'.$sqlupdate."</td></tr>\n";
135 156
 				$resqlupdate = $db->query($sqlupdate);
136
-				if (!$resqlupdate) dol_print_error($db, 'Failed to update');
157
+				if (!$resqlupdate) {
158
+					dol_print_error($db, 'Failed to update');
159
+				}
137 160
 			}
138 161
 		}
139
-	} else dol_print_error($db, 'Failed to run request');
162
+	} else {
163
+		dol_print_error($db, 'Failed to run request');
164
+	}
140 165
 
141 166
 	return;
142 167
 }
Please login to merge, or discard this patch.
htdocs/core/tpl/commonfields_view.tpl.php 1 patch
Braces   +69 added lines, -22 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 	print "Error, template page can't be called as URL";
30 30
 	exit;
31 31
 }
32
-if (!is_object($form)) $form = new Form($db);
32
+if (!is_object($form)) {
33
+	$form = new Form($db);
34
+}
33 35
 
34 36
 ?>
35 37
 <!-- BEGIN PHP TEMPLATE commonfields_view.tpl.php -->
@@ -39,32 +41,56 @@  discard block
 block discarded – undo
39 41
 
40 42
 foreach ($object->fields as $key => $val)
41 43
 {
42
-	if (!empty($keyforbreak) && $key == $keyforbreak) break; // key used for break on second column
44
+	if (!empty($keyforbreak) && $key == $keyforbreak) {
45
+		break;
46
+	}
47
+	// key used for break on second column
43 48
 
44 49
 	// Discard if extrafield is a hidden field on form
45
-	if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4 && abs($val['visible']) != 5) continue;
50
+	if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4 && abs($val['visible']) != 5) {
51
+		continue;
52
+	}
46 53
 
47
-	if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) continue; // We don't want this field
48
-	if (in_array($key, array('ref', 'status'))) continue; // Ref and status are already in dol_banner
54
+	if (array_key_exists('enabled', $val) && isset($val['enabled']) && !verifCond($val['enabled'])) {
55
+		continue;
56
+	}
57
+	// We don't want this field
58
+	if (in_array($key, array('ref', 'status'))) {
59
+		continue;
60
+	}
61
+	// Ref and status are already in dol_banner
49 62
 
50 63
 	$value = $object->$key;
51 64
 
52 65
 	print '<tr><td';
53 66
 	print ' class="titlefield fieldname_'.$key;
54 67
 	//if ($val['notnull'] > 0) print ' fieldrequired';     // No fieldrequired on the view output
55
-	if ($val['type'] == 'text' || $val['type'] == 'html') print ' tdtop';
68
+	if ($val['type'] == 'text' || $val['type'] == 'html') {
69
+		print ' tdtop';
70
+	}
56 71
 	print '">';
57
-	if (!empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help']));
58
-	else print $langs->trans($val['label']);
72
+	if (!empty($val['help'])) {
73
+		print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help']));
74
+	} else {
75
+		print $langs->trans($val['label']);
76
+	}
59 77
 	print '</td>';
60 78
 	print '<td class="valuefield fieldname_'.$key;
61
-	if ($val['type'] == 'text') print ' wordbreak';
62
-	if ($val['cssview']) print ' '.$val['cssview'];
79
+	if ($val['type'] == 'text') {
80
+		print ' wordbreak';
81
+	}
82
+	if ($val['cssview']) {
83
+		print ' '.$val['cssview'];
84
+	}
63 85
 	print '">';
64
-	if (in_array($val['type'], array('text', 'html'))) print '<div class="longmessagecut">';
86
+	if (in_array($val['type'], array('text', 'html'))) {
87
+		print '<div class="longmessagecut">';
88
+	}
65 89
 	print $object->showOutputField($val, $key, $value, '', '', '', 0);
66 90
 	//print dol_escape_htmltag($object->$key, 1, 1);
67
-	if (in_array($val['type'], array('text', 'html'))) print '</div>';
91
+	if (in_array($val['type'], array('text', 'html'))) {
92
+		print '</div>';
93
+	}
68 94
 	print '</td>';
69 95
 	print '</tr>';
70 96
 }
@@ -91,29 +117,50 @@  discard block
 block discarded – undo
91 117
 	}
92 118
 
93 119
 	// Discard if extrafield is a hidden field on form
94
-	if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4 && abs($val['visible']) != 5) continue;
120
+	if (abs($val['visible']) != 1 && abs($val['visible']) != 3 && abs($val['visible']) != 4 && abs($val['visible']) != 5) {
121
+		continue;
122
+	}
95 123
 
96
-	if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled']) continue; // We don't want this field
97
-	if (in_array($key, array('ref', 'status'))) continue; // Ref and status are already in dol_banner
124
+	if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled']) {
125
+		continue;
126
+	}
127
+	// We don't want this field
128
+	if (in_array($key, array('ref', 'status'))) {
129
+		continue;
130
+	}
131
+	// Ref and status are already in dol_banner
98 132
 
99 133
 	$value = $object->$key;
100 134
 
101 135
 	print '<tr><td';
102 136
 	print ' class="titlefield fieldname_'.$key;
103 137
 	//if ($val['notnull'] > 0) print ' fieldrequired';		// No fieldrequired inthe view output
104
-	if ($val['type'] == 'text' || $val['type'] == 'html') print ' tdtop';
138
+	if ($val['type'] == 'text' || $val['type'] == 'html') {
139
+		print ' tdtop';
140
+	}
105 141
 	print '">';
106
-	if (!empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help']));
107
-	else print $langs->trans($val['label']);
142
+	if (!empty($val['help'])) {
143
+		print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help']));
144
+	} else {
145
+		print $langs->trans($val['label']);
146
+	}
108 147
 	print '</td>';
109 148
 	print '<td class="valuefield fieldname_'.$key;
110
-	if ($val['type'] == 'text') print ' wordbreak';
111
-	if ($val['cssview']) print ' '.$val['cssview'];
149
+	if ($val['type'] == 'text') {
150
+		print ' wordbreak';
151
+	}
152
+	if ($val['cssview']) {
153
+		print ' '.$val['cssview'];
154
+	}
112 155
 	print '">';
113
-	if (in_array($val['type'], array('text', 'html'))) print '<div class="longmessagecut">';
156
+	if (in_array($val['type'], array('text', 'html'))) {
157
+		print '<div class="longmessagecut">';
158
+	}
114 159
 	print $object->showOutputField($val, $key, $value, '', '', '', 0);
115 160
 	//print dol_escape_htmltag($object->$key, 1, 1);
116
-	if (in_array($val['type'], array('text', 'html'))) print '</div>';
161
+	if (in_array($val['type'], array('text', 'html'))) {
162
+		print '</div>';
163
+	}
117 164
 	print '</td>';
118 165
 	print '</tr>';
119 166
 }
Please login to merge, or discard this patch.
htdocs/core/login/functions_ldap.php 1 patch
Braces   +45 added lines, -15 removed lines patch added patch discarded remove patch
@@ -45,7 +45,9 @@  discard block
 block discarded – undo
45 45
 
46 46
 	// Force master entity in transversal mode
47 47
 	$entity = $entitytotest;
48
-	if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $entity = 1;
48
+	if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
49
+		$entity = 1;
50
+	}
49 51
 
50 52
 	$login = '';
51 53
 	$resultFetchUser = '';
@@ -78,7 +80,9 @@  discard block
 block discarded – undo
78 80
 		$ldapadminpass = $dolibarr_main_auth_ldap_admin_pass;
79 81
 		$ldapdebug = (empty($dolibarr_main_auth_ldap_debug) || $dolibarr_main_auth_ldap_debug == "false" ? false : true);
80 82
 
81
-		if ($ldapdebug) print "DEBUG: Logging LDAP steps<br>\n";
83
+		if ($ldapdebug) {
84
+			print "DEBUG: Logging LDAP steps<br>\n";
85
+		}
82 86
 
83 87
 		require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
84 88
 		$ldap = new Ldap();
@@ -116,10 +120,14 @@  discard block
 block discarded – undo
116 120
 			{
117 121
 				$resultFetchLdapUser = $ldap->fetch($usertotest, $userSearchFilter);
118 122
 				//dol_syslog('functions_ldap::check_user_password_ldap resultFetchLdapUser='.$resultFetchLdapUser);
119
-				if ($resultFetchLdapUser > 0 && $ldap->pwdlastset == 0) // If ok but password need to be reset
123
+				if ($resultFetchLdapUser > 0 && $ldap->pwdlastset == 0) {
124
+					// If ok but password need to be reset
120 125
 				{
121 126
 					dol_syslog('functions_ldap::check_user_password_ldap '.$usertotest.' must change password next logon');
122
-					if ($ldapdebug) print "DEBUG: User ".$usertotest." must change password<br>\n";
127
+				}
128
+					if ($ldapdebug) {
129
+						print "DEBUG: User ".$usertotest." must change password<br>\n";
130
+					}
123 131
 					$ldap->close();
124 132
 					sleep(1);
125 133
 					$langs->load('ldap');
@@ -127,7 +135,9 @@  discard block
 block discarded – undo
127 135
 					return '';
128 136
 				}
129 137
 			} else {
130
-				 if ($ldapdebug) print "DEBUG: ".$ldap->error."<br>\n";
138
+				 if ($ldapdebug) {
139
+				 	print "DEBUG: ".$ldap->error."<br>\n";
140
+				 }
131 141
 			}
132 142
 			$ldap->close();
133 143
 		}
@@ -138,7 +148,9 @@  discard block
 block discarded – undo
138 148
 		$ldap->searchUser = $ldapuserattr."=".$usertotest.",".$ldapdn; // Default dn (will work if LDAP accept a dn with login value inside)
139 149
 		// But if LDAP need a dn with name like "cn=Jhon Bloggs,ou=People,dc=foo,dc=com", previous part must have been executed to have
140 150
 		// dn detected into ldapUserDN.
141
-		if ($resultFetchLdapUser && !empty($ldap->ldapUserDN)) $ldap->searchUser = $ldap->ldapUserDN;
151
+		if ($resultFetchLdapUser && !empty($ldap->ldapUserDN)) {
152
+			$ldap->searchUser = $ldap->ldapUserDN;
153
+		}
142 154
 		$ldap->searchPassword = $passwordtotest;
143 155
 
144 156
 		// Test with this->seachUser and this->searchPassword
@@ -146,9 +158,11 @@  discard block
 block discarded – undo
146 158
 		$result = $ldap->connect_bind();
147 159
 		if ($result > 0)
148 160
 		{
149
-			if ($result == 2)	// Connection is ok for user/pass into LDAP
161
+			if ($result == 2) {
162
+				// Connection is ok for user/pass into LDAP
150 163
 			{
151 164
 				dol_syslog("functions_ldap::check_user_password_ldap Authentification ok");
165
+			}
152 166
 				$login = $usertotest;
153 167
 
154 168
 				require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
@@ -173,24 +187,36 @@  discard block
 block discarded – undo
173 187
 				}
174 188
 
175 189
 				// ldap2dolibarr synchronisation
176
-				if ($login && !empty($conf->ldap->enabled) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr')	// ldap2dolibarr synchronisation
190
+				if ($login && !empty($conf->ldap->enabled) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') {
191
+					// ldap2dolibarr synchronisation
177 192
 				{
178 193
 					dol_syslog("functions_ldap::check_user_password_ldap Sync ldap2dolibarr");
194
+				}
179 195
 
180 196
 					// On charge les attributs du user ldap
181
-					if ($ldapdebug) print "DEBUG: login ldap = ".$login."<br>\n";
197
+					if ($ldapdebug) {
198
+						print "DEBUG: login ldap = ".$login."<br>\n";
199
+					}
182 200
 					$resultFetchLdapUser = $ldap->fetch($login, $userSearchFilter);
183 201
 
184
-					if ($ldapdebug) print "DEBUG: UACF = ".join(',', $ldap->uacf)."<br>\n";
185
-					if ($ldapdebug) print "DEBUG: pwdLastSet = ".dol_print_date($ldap->pwdlastset, 'day')."<br>\n";
186
-					if ($ldapdebug) print "DEBUG: badPasswordTime = ".dol_print_date($ldap->badpwdtime, 'day')."<br>\n";
202
+					if ($ldapdebug) {
203
+						print "DEBUG: UACF = ".join(',', $ldap->uacf)."<br>\n";
204
+					}
205
+					if ($ldapdebug) {
206
+						print "DEBUG: pwdLastSet = ".dol_print_date($ldap->pwdlastset, 'day')."<br>\n";
207
+					}
208
+					if ($ldapdebug) {
209
+						print "DEBUG: badPasswordTime = ".dol_print_date($ldap->badpwdtime, 'day')."<br>\n";
210
+					}
187 211
 
188 212
 					// On recherche le user dolibarr en fonction de son SID ldap (only for Active Directory)
189 213
 					$sid = null;
190 214
 					if ($conf->global->LDAP_SERVER_TYPE == "activedirectory")
191 215
 					{
192 216
 						$sid = $ldap->getObjectSid($login);
193
-						if ($ldapdebug) print "DEBUG: sid = ".$sid."<br>\n";
217
+						if ($ldapdebug) {
218
+							print "DEBUG: sid = ".$sid."<br>\n";
219
+						}
194 220
 					}
195 221
 
196 222
 					$usertmp = new User($db);
@@ -213,9 +239,11 @@  discard block
 block discarded – undo
213 239
 					unset($usertmp);
214 240
 				}
215 241
 
216
-				if (!empty($conf->multicompany->enabled))	// We must check entity (even if sync is not active)
242
+				if (!empty($conf->multicompany->enabled)) {
243
+					// We must check entity (even if sync is not active)
217 244
 				{
218 245
 					global $mc;
246
+				}
219 247
 
220 248
 					$usertmp = new User($db);
221 249
 					$usertmp->fetch('', $login);
@@ -248,9 +276,11 @@  discard block
 block discarded – undo
248 276
              ** 53 - Account inactive (manually locked out by administrator)
249 277
              */
250 278
 			dol_syslog("functions_ldap::check_user_password_ldap Authentication KO failed to connect to LDAP for '".$usertotest."'", LOG_NOTICE);
251
-			if (is_resource($ldap->connection))    // If connection ok but bind ko
279
+			if (is_resource($ldap->connection)) {
280
+				// If connection ok but bind ko
252 281
 			{
253 282
 				$ldap->ldapErrorCode = ldap_errno($ldap->connection);
283
+			}
254 284
 				$ldap->ldapErrorText = ldap_error($ldap->connection);
255 285
 				dol_syslog("functions_ldap::check_user_password_ldap ".$ldap->ldapErrorCode." ".$ldap->ldapErrorText);
256 286
 			}
Please login to merge, or discard this patch.