Completed
Branch develop (c23a95)
by
unknown
18:46
created
htdocs/product/admin/inventory_extrafields.php 1 patch
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,16 +29,28 @@  discard block
 block discarded – undo
29 29
 // Load Dolibarr environment
30 30
 $res = 0;
31 31
 // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
32
-if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
32
+if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
33
+	$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
34
+}
33 35
 // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
34 36
 $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
35 37
 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
36
-if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
37
-if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
38
+if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
39
+	$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
40
+}
41
+if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
42
+	$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
43
+}
38 44
 // Try main.inc.php using relative path
39
-if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
40
-if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
41
-if (!$res) die("Include of main fails");
45
+if (!$res && file_exists("../../main.inc.php")) {
46
+	$res = @include "../../main.inc.php";
47
+}
48
+if (!$res && file_exists("../../../main.inc.php")) {
49
+	$res = @include "../../../main.inc.php";
50
+}
51
+if (!$res) {
52
+	die("Include of main fails");
53
+}
42 54
 
43 55
 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
44 56
 require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php';
@@ -52,13 +64,17 @@  discard block
 block discarded – undo
52 64
 // List of supported format
53 65
 $tmptype2label = ExtraFields::$type2label;
54 66
 $type2label = array('');
55
-foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
67
+foreach ($tmptype2label as $key => $val) {
68
+	$type2label[$key] = $langs->transnoentitiesnoconv($val);
69
+}
56 70
 
57 71
 $action = GETPOST('action', 'aZ09');
58 72
 $attrname = GETPOST('attrname', 'alpha');
59 73
 $elementtype = 'inventory'; //Must be the $table_element of the class that manage extrafield
60 74
 
61
-if (!$user->admin) accessforbidden();
75
+if (!$user->admin) {
76
+	accessforbidden();
77
+}
62 78
 
63 79
 
64 80
 /*
Please login to merge, or discard this patch.
htdocs/asset/model/note.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -55,12 +55,20 @@
 block discarded – undo
55 55
 $permissionnote = $permissiontoadd; // Used by the include of actions_setnotes.inc.php
56 56
 
57 57
 // Security check (enable the most restrictive one)
58
-if ($user->socid > 0) accessforbidden();
59
-if ($user->socid > 0) $socid = $user->socid;
58
+if ($user->socid > 0) {
59
+	accessforbidden();
60
+}
61
+if ($user->socid > 0) {
62
+	$socid = $user->socid;
63
+}
60 64
 $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
61 65
 restrictedArea($user, 'asset', $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
62
-if (empty($conf->asset->enabled)) accessforbidden();
63
-if (!$permissiontoread) accessforbidden();
66
+if (empty($conf->asset->enabled)) {
67
+	accessforbidden();
68
+}
69
+if (!$permissiontoread) {
70
+	accessforbidden();
71
+}
64 72
 
65 73
 
66 74
 /*
Please login to merge, or discard this patch.
htdocs/asset/class/asset.class.php 1 patch
Braces   +38 added lines, -13 removed lines patch added patch discarded remove patch
@@ -225,14 +225,20 @@  discard block
 block discarded – undo
225 225
 	 */
226 226
 	public function create(User $user, $notrigger = false)
227 227
 	{
228
-		if (!isset($this->date_start) || $this->date_start === "") $this->date_start = $this->date_acquisition;
228
+		if (!isset($this->date_start) || $this->date_start === "") {
229
+			$this->date_start = $this->date_acquisition;
230
+		}
229 231
 
230 232
 		$this->db->begin();
231 233
 
232 234
 		$result = $result_create = $this->createCommon($user, $notrigger);
233
-		if ($result > 0 && $this->fk_asset_model > 0) $result = $this->setDataFromAssetModel($user, $notrigger);
235
+		if ($result > 0 && $this->fk_asset_model > 0) {
236
+			$result = $this->setDataFromAssetModel($user, $notrigger);
237
+		}
234 238
 		if ($result > 0) {
235
-			if ($this->supplier_invoice_id > 0) $this->add_object_linked('invoice_supplier', $this->supplier_invoice_id);
239
+			if ($this->supplier_invoice_id > 0) {
240
+				$this->add_object_linked('invoice_supplier', $this->supplier_invoice_id);
241
+			}
236 242
 		}
237 243
 
238 244
 		if ($result < 0) {
@@ -355,7 +361,9 @@  discard block
 block discarded – undo
355 361
 	{
356 362
 		$result = $this->fetchCommon($id, $ref);
357 363
 		if ($result > 0) {
358
-			if (!empty($this->table_element_line)) $this->fetchLines();
364
+			if (!empty($this->table_element_line)) {
365
+				$this->fetchLines();
366
+			}
359 367
 
360 368
 			$res = $this->hasDepreciationLinesInBookkeeping();
361 369
 			if ($res < 0) {
@@ -474,7 +482,9 @@  discard block
 block discarded – undo
474 482
 	 */
475 483
 	public function update(User $user, $notrigger = false)
476 484
 	{
477
-		if (!isset($this->date_start) || $this->date_start === "") $this->date_start = $this->date_acquisition;
485
+		if (!isset($this->date_start) || $this->date_start === "") {
486
+			$this->date_start = $this->date_acquisition;
487
+		}
478 488
 
479 489
 		$this->db->begin();
480 490
 
@@ -669,7 +679,9 @@  discard block
 block discarded – undo
669 679
 		}
670 680
 
671 681
 		while ($obj = $this->db->fetch_object($resql)) {
672
-			if (!isset($this->depreciation_lines[$obj->depreciation_mode])) $this->depreciation_lines[$obj->depreciation_mode] = array();
682
+			if (!isset($this->depreciation_lines[$obj->depreciation_mode])) {
683
+				$this->depreciation_lines[$obj->depreciation_mode] = array();
684
+			}
673 685
 			$this->depreciation_lines[$obj->depreciation_mode][] = array(
674 686
 				'id' => $obj->rowid,
675 687
 				'ref' => $obj->ref,
@@ -907,7 +919,9 @@  discard block
 block discarded – undo
907 919
 				$sql .= " WHERE " . MAIN_DB_PREFIX . "asset_depreciation.fk_asset = " . (int) $this->id;
908 920
 				$sql .= " AND " . MAIN_DB_PREFIX . "asset_depreciation.depreciation_mode = '" . $this->db->escape($mode_key) . "'";
909 921
 				$sql .= " AND ab.fk_docdet IS NULL";
910
-				if ($last_depreciation_date !== "") $sql .= " AND " . MAIN_DB_PREFIX . "asset_depreciation.ref != ''";
922
+				if ($last_depreciation_date !== "") {
923
+					$sql .= " AND " . MAIN_DB_PREFIX . "asset_depreciation.ref != ''";
924
+				}
911 925
 				$resql = $this->db->query($sql);
912 926
 				if (!$resql) {
913 927
 					$this->errors[] = $langs->trans('AssetErrorClearDepreciationLines') . ': ' . $this->db->lasterror();
@@ -985,7 +999,9 @@  discard block
 block discarded – undo
985 999
 				do {
986 1000
 					// Loop security
987 1001
 					$idx_loop++;
988
-					if ($idx_loop > $max_loop) break;
1002
+					if ($idx_loop > $max_loop) {
1003
+						break;
1004
+					}
989 1005
 
990 1006
 					if ($last_depreciation_date < $fiscal_period_end && ($first_period_date <= $start_date || $first_period_found)) {
991 1007
 						// Disposal not depreciated
@@ -1152,10 +1168,14 @@  discard block
 block discarded – undo
1152 1168
 			$this->fields[$field]['notnull'] = 0;
1153 1169
 		}
1154 1170
 		if ($result > 0) {
1155
-			if ($disposal_invoice_id > 0) $this->add_object_linked('facture', $disposal_invoice_id);
1171
+			if ($disposal_invoice_id > 0) {
1172
+				$this->add_object_linked('facture', $disposal_invoice_id);
1173
+			}
1156 1174
 			$result = $this->setStatusCommon($user, self::STATUS_DISPOSED, $notrigger, 'ASSET_DISPOSED');
1157 1175
 		}
1158
-		if ($result > 0) $result = $this->calculationDepreciation();
1176
+		if ($result > 0) {
1177
+			$result = $this->calculationDepreciation();
1178
+		}
1159 1179
 
1160 1180
 		if ($result < 0) {
1161 1181
 			$this->db->rollback();
@@ -1218,7 +1238,9 @@  discard block
 block discarded – undo
1218 1238
 			$this->deleteObjectLinked(null, 'facture');
1219 1239
 			$result = $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'ASSET_REOPEN');
1220 1240
 		}
1221
-		if ($result > 0) $result = $this->calculationDepreciation();
1241
+		if ($result > 0) {
1242
+			$result = $this->calculationDepreciation();
1243
+		}
1222 1244
 
1223 1245
 		if ($result < 0) {
1224 1246
 			$this->db->rollback();
@@ -1352,8 +1374,11 @@  discard block
 block discarded – undo
1352 1374
 
1353 1375
 		if ($withpicto != 2) {
1354 1376
 			$name = $this->ref;
1355
-			if ($option == 'label') $name = $this->label;
1356
-			elseif ($option == 'with_label') $name .= ' - ' . $this->label;
1377
+			if ($option == 'label') {
1378
+				$name = $this->label;
1379
+			} elseif ($option == 'with_label') {
1380
+				$name .= ' - ' . $this->label;
1381
+			}
1357 1382
 			$result .= dol_escape_htmltag($maxlen ? dol_trunc($name, $maxlen) : $name);
1358 1383
 		}
1359 1384
 
Please login to merge, or discard this patch.
htdocs/asset/class/assetaccountancycodes.class.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,7 +90,9 @@  discard block
 block discarded – undo
90 90
 			$this->accountancy_codes[$mode_key] = array();
91 91
 			foreach ($mode_info['fields'] as $field_key => $field_info) {
92 92
 				$accountancy_code = GETPOST($mode_key . '_' . $field_key, 'aZ09');
93
-				if (empty($accountancy_code) || $accountancy_code == '-1') $accountancy_code = '';
93
+				if (empty($accountancy_code) || $accountancy_code == '-1') {
94
+					$accountancy_code = '';
95
+				}
94 96
 				$this->accountancy_codes[$mode_key][$field_key] = $accountancy_code;
95 97
 			}
96 98
 		}
@@ -251,7 +253,9 @@  discard block
 block discarded – undo
251 253
 			require_once DOL_DOCUMENT_ROOT . '/asset/class/asset.class.php';
252 254
 			$asset = new Asset($this->db);
253 255
 			$result = $asset->fetch($asset_id);
254
-			if ($result > 0) $result = $asset->calculationDepreciation();
256
+			if ($result > 0) {
257
+				$result = $asset->calculationDepreciation();
258
+			}
255 259
 			if ($result < 0) {
256 260
 				$this->errors[] = $langs->trans('AssetErrorCalculationDepreciationLines');
257 261
 				$this->errors[] = $asset->errorsToString();
Please login to merge, or discard this patch.
htdocs/asset/class/assetdepreciationoptions.class.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -352,7 +352,9 @@  discard block
 block discarded – undo
352 352
 				$error++;
353 353
 			} elseif ($result > 0) {
354 354
 				foreach ($this->fields as $field_key => $field_info) {
355
-					if (in_array($field_key, array('rowid', 'fk_asset', 'fk_asset_model', 'tms', 'fk_user_modif'))) continue;
355
+					if (in_array($field_key, array('rowid', 'fk_asset', 'fk_asset_model', 'tms', 'fk_user_modif'))) {
356
+						continue;
357
+					}
356 358
 					$deprecation_options[$mode_key][$field_key] = $this->{$field_key};
357 359
 				}
358 360
 			}
@@ -504,7 +506,9 @@  discard block
 block discarded – undo
504 506
 			require_once DOL_DOCUMENT_ROOT . '/asset/class/asset.class.php';
505 507
 			$asset = new Asset($this->db);
506 508
 			$result = $asset->fetch($this->fk_asset);
507
-			if ($result > 0) $result = $asset->calculationDepreciation();
509
+			if ($result > 0) {
510
+				$result = $asset->calculationDepreciation();
511
+			}
508 512
 			if ($result < 0) {
509 513
 				$this->errors[] = $langs->trans('AssetErrorCalculationDepreciationLines');
510 514
 				$this->errors[] = $asset->errorsToString();
Please login to merge, or discard this patch.
htdocs/core/tpl/objectline_view.tpl.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -397,9 +397,15 @@
 block discarded – undo
397 397
 		) {
398 398
 			$accountancy_category_asset = $conf->global->ASSET_ACCOUNTANCY_CATEGORY;
399 399
 			$filters = array();
400
-			if (!empty($product_static->accountancy_code_buy)) $filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy) . "'";
401
-			if (!empty($product_static->accountancy_code_buy_intra)) $filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy_intra) . "'";
402
-			if (!empty($product_static->accountancy_code_buy_export)) $filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy_export) . "'";
400
+			if (!empty($product_static->accountancy_code_buy)) {
401
+				$filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy) . "'";
402
+			}
403
+			if (!empty($product_static->accountancy_code_buy_intra)) {
404
+				$filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy_intra) . "'";
405
+			}
406
+			if (!empty($product_static->accountancy_code_buy_export)) {
407
+				$filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy_export) . "'";
408
+			}
403 409
 			$sql = "SELECT COUNT(*) AS found";
404 410
 			$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account";
405 411
 			$sql .= " WHERE pcg_type = '" . $this->db->escape($conf->global->ASSET_ACCOUNTANCY_CATEGORY) . "'";
Please login to merge, or discard this patch.
htdocs/reception/list.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -349,8 +349,9 @@  discard block
 block discarded – undo
349 349
 
350 350
 							$rang = $i;
351 351
 							//there may already be rows from previous receptions
352
-							if (!empty($createbills_onebythird))
353
-								$rang = $TFactThirdNbLines[$rcp->socid];
352
+							if (!empty($createbills_onebythird)) {
353
+															$rang = $TFactThirdNbLines[$rcp->socid];
354
+							}
354 355
 
355 356
 							$result = $objecttmp->addline(
356 357
 								$desc,
@@ -380,8 +381,10 @@  discard block
 block discarded – undo
380 381
 
381 382
 							if ($result > 0) {
382 383
 								$lineid = $result;
383
-								if (!empty($createbills_onebythird)) //increment rang to keep order
384
+								if (!empty($createbills_onebythird)) {
385
+									//increment rang to keep order
384 386
 									$TFactThirdNbLines[$rcp->socid]++;
387
+								}
385 388
 							} else {
386 389
 								$lineid = 0;
387 390
 								$error++;
Please login to merge, or discard this patch.
htdocs/fourn/class/fournisseur.facture-rec.class.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -479,7 +479,9 @@
 block discarded – undo
479 479
 		$sql .= " titre = '" . (!empty($this->titre) ? $this->db->escape($this->titre) : "")."'," ;
480 480
 		$sql .= " ref_supplier = '". (!empty($this->ref_supplier) ? $this->db->escape($this->ref_supplier) : "")."',";
481 481
 		$sql .= " entity = ". (!empty($this->entity) ? ((int) $this->entity) : 1) . ',';
482
-		if ($this->fk_soc > 0) $sql .= " fk_soc = ". (int) $this->fk_soc. ',';
482
+		if ($this->fk_soc > 0) {
483
+			$sql .= " fk_soc = ". (int) $this->fk_soc. ',';
484
+		}
483 485
 		$sql .= " suspended = ". (!empty($this->suspended) ? ((int) $this->suspended) : 0) . ',';
484 486
 		$sql .= " libelle = ". (!empty($this->libelle) ? "'".$this->db->escape($this->libelle)."'" : 'NULL') . ",";
485 487
 		$sql .= " vat_src_code = ". (!empty($this->vat_src_code) ? "'".$this->db->escape($this->vat_src_code)."'" : 'NULL') . ',';
Please login to merge, or discard this patch.
htdocs/fourn/class/fournisseur.facture.class.php 1 patch
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1204,8 +1204,11 @@  discard block
 block discarded – undo
1204 1204
 			$this->fk_facture_source = trim($this->fk_facture_source);
1205 1205
 		}
1206 1206
 		if (isset($this->fk_project)) {
1207
-			if (empty($this->fk_project)) $this->fk_project = null;
1208
-			else $this->fk_project = intval($this->fk_project);
1207
+			if (empty($this->fk_project)) {
1208
+				$this->fk_project = null;
1209
+			} else {
1210
+				$this->fk_project = intval($this->fk_project);
1211
+			}
1209 1212
 		}
1210 1213
 		if (isset($this->cond_reglement_id)) {
1211 1214
 			$this->cond_reglement_id = trim($this->cond_reglement_id);
@@ -3654,8 +3657,11 @@  discard block
 block discarded – undo
3654 3657
 		$sql .= ", pu_ttc = ".price2num($this->pu_ttc);
3655 3658
 		$sql .= ", qty = ".price2num($this->qty);
3656 3659
 		$sql .= ", remise_percent = ".price2num($this->remise_percent);
3657
-		if ($this->fk_remise_except > 0) $sql .= ", fk_remise_except=".((int) $this->fk_remise_except);
3658
-		else $sql .= ", fk_remise_except=null";
3660
+		if ($this->fk_remise_except > 0) {
3661
+			$sql .= ", fk_remise_except=".((int) $this->fk_remise_except);
3662
+		} else {
3663
+			$sql .= ", fk_remise_except=null";
3664
+		}
3659 3665
 		$sql .= ", vat_src_code = '".$this->db->escape(empty($this->vat_src_code) ? '' : $this->vat_src_code)."'";
3660 3666
 		$sql .= ", tva_tx = ".price2num($this->tva_tx);
3661 3667
 		$sql .= ", localtax1_tx = ".price2num($this->localtax1_tx);
Please login to merge, or discard this patch.