Completed
Branch develop (b66a18)
by
unknown
14:24
created
htdocs/asset/disposal.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@
 block discarded – undo
91 91
 
92 92
 	// Object card
93 93
 	// ------------------------------------------------------------
94
-	$linkback = '<a href="' . DOL_URL_ROOT . '/asset/list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
94
+	$linkback = '<a href="'.DOL_URL_ROOT.'/asset/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
95 95
 
96 96
 	$morehtmlref = '<div class="refidno">';
97 97
 	$morehtmlref .= '</div>';
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -55,11 +55,17 @@
 block discarded – undo
55 55
 $permissiontoadd = $user->hasRight('asset', 'write'); // Used by the include of actions_addupdatedelete.inc.php
56 56
 
57 57
 // Security check (enable the most restrictive one)
58
-if ($user->socid > 0) accessforbidden();
58
+if ($user->socid > 0) {
59
+	accessforbidden();
60
+}
59 61
 $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
60 62
 restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
61
-if (!isModEnabled('asset')) accessforbidden();
62
-if (!isset($object->disposal_date) || $object->disposal_date === "") accessforbidden();
63
+if (!isModEnabled('asset')) {
64
+	accessforbidden();
65
+}
66
+if (!isset($object->disposal_date) || $object->disposal_date === "") {
67
+	accessforbidden();
68
+}
63 69
 
64 70
 
65 71
 /*
Please login to merge, or discard this patch.
htdocs/asset/model/list.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
 $show_files		= GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
38 38
 $confirm		= GETPOST('confirm', 'alpha'); // Result of a confirmation
39 39
 $cancel			= GETPOST('cancel', 'alpha'); // We click on a Cancel button
40
-$toselect		= GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
40
+$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
41 41
 $contextpage	= GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'assetmodellist'; // To manage different context of search
42 42
 $backtopage		= GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
43
-$optioncss		= GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
43
+$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
44 44
 
45 45
 $id = GETPOST('id', 'int');
46 46
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
 // Default sort order (if not yet defined by previous GETPOST)
72 72
 if (!$sortfield) {
73
-	reset($object->fields);					// Reset is required to avoid key() to return null.
73
+	reset($object->fields); // Reset is required to avoid key() to return null.
74 74
 	$sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
75 75
 }
76 76
 if (!$sortorder) {
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 					$sql .= " AND t.".$columnName." >= '".$db->idate($search[$key])."'";
255 255
 				}
256 256
 				if (preg_match('/_dtend$/', $key)) {
257
-					$sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'";
257
+					$sql .= " AND t.".$columnName." <= '".$db->idate($search[$key])."'";
258 258
 				}
259 259
 			}
260 260
 		}
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -140,8 +140,12 @@  discard block
 block discarded – undo
140 140
 }
141 141
 $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
142 142
 restrictedArea($user, 'asset', $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
143
-if (!isModEnabled('asset')) accessforbidden();
144
-if (!$permissiontoread) accessforbidden();
143
+if (!isModEnabled('asset')) {
144
+	accessforbidden();
145
+}
146
+if (!$permissiontoread) {
147
+	accessforbidden();
148
+}
145 149
 
146 150
 /*
147 151
  * Actions
@@ -169,7 +173,9 @@  discard block
 block discarded – undo
169 173
 	if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
170 174
 		foreach ($object->fields as $key => $val) {
171 175
 			$search[$key] = '';
172
-			if ($key == 'fk_pays') $search[$key] = $mysoc->country_id;
176
+			if ($key == 'fk_pays') {
177
+				$search[$key] = $mysoc->country_id;
178
+			}
173 179
 			if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
174 180
 				$search[$key.'_dtstart'] = '';
175 181
 				$search[$key.'_dtend'] = '';
Please login to merge, or discard this patch.
htdocs/asset/model/note.php 2 patches
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.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
 
25 25
 // Load Dolibarr environment
26 26
 require '../../main.inc.php';
27
-require_once DOL_DOCUMENT_ROOT . '/core/lib/asset.lib.php';
28
-require_once DOL_DOCUMENT_ROOT . '/asset/class/assetmodel.class.php';
27
+require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php';
28
+require_once DOL_DOCUMENT_ROOT.'/asset/class/assetmodel.class.php';
29 29
 
30 30
 // Load translation files required by the page
31 31
 $langs->loadLangs(array("assets", "companies"));
@@ -40,15 +40,15 @@  discard block
 block discarded – undo
40 40
 // Initialize technical objects
41 41
 $object = new AssetModel($db);
42 42
 $extrafields = new ExtraFields($db);
43
-$diroutputmassaction = $conf->asset->dir_output . '/temp/massgeneration/' . $user->id;
43
+$diroutputmassaction = $conf->asset->dir_output.'/temp/massgeneration/'.$user->id;
44 44
 $hookmanager->initHooks(array('assetmodelnote', 'globalcard')); // Note that conf->hooks_modules contains array
45 45
 // Fetch optionals attributes and labels
46 46
 $extrafields->fetch_name_optionals_label($object->table_element);
47 47
 
48 48
 // Load object
49
-include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once  // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
49
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once  // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
50 50
 if ($id > 0 || !empty($ref)) {
51
-	$upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id;
51
+	$upload_dir = $conf->asset->multidir_output[$object->entity]."/".$object->id;
52 52
 }
53 53
 
54 54
 $permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'read')) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('asset', 'model_advance', 'read')));
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
75 75
 }
76 76
 if (empty($reshook)) {
77
-	include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not include_once
77
+	include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
78 78
 }
79 79
 
80 80
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
 	// Object card
98 98
 	// ------------------------------------------------------------
99
-	$linkback = '<a href="' . DOL_URL_ROOT . '/asset/model/list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
99
+	$linkback = '<a href="'.DOL_URL_ROOT.'/asset/model/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
100 100
 
101 101
 	$morehtmlref = '<div class="refidno">';
102 102
 	$morehtmlref .= '</div>';
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
 
112 112
 	$cssclass = "titlefield";
113
-	include DOL_DOCUMENT_ROOT . '/core/tpl/notes.tpl.php';
113
+	include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
114 114
 
115 115
 	print '</div>';
116 116
 
Please login to merge, or discard this patch.
htdocs/asset/class/asset.class.php 2 patches
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.
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 	 */
61 61
 	public $picto = 'asset';
62 62
 
63
-	const STATUS_DRAFT = 0; 	// In progress
64
-	const STATUS_DISPOSED = 9;	// Disposed
63
+	const STATUS_DRAFT = 0; // In progress
64
+	const STATUS_DISPOSED = 9; // Disposed
65 65
 
66 66
 	/**
67 67
 	 *  'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter[:Sortfield]]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	/**
95 95
 	 * @var array  Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
96 96
 	 */
97
-	public $fields=array(
97
+	public $fields = array(
98 98
 		'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
99 99
 		'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'noteditable'=>'0', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'validate'=>'1', 'comment'=>"Reference of object"),
100 100
 		'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'showoncombobox'=>'2', 'validate'=>'1',),
@@ -536,11 +536,11 @@  discard block
 block discarded – undo
536 536
 		// Check parameters
537 537
 		$error = 0;
538 538
 		if (empty($this->id)) {
539
-			$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Asset") . ' (' . $langs->transnoentitiesnoconv("TechnicalID") . ')');
539
+			$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Asset").' ('.$langs->transnoentitiesnoconv("TechnicalID").')');
540 540
 			$error++;
541 541
 		}
542 542
 		if (empty($this->fk_asset_model)) {
543
-			$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AssetModel") . ' (' . $langs->transnoentitiesnoconv("TechnicalID") . ')');
543
+			$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AssetModel").' ('.$langs->transnoentitiesnoconv("TechnicalID").')');
544 544
 			$error++;
545 545
 		}
546 546
 		if ($error) {
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
 
552 552
 		// Get depreciation options
553 553
 		//---------------------------
554
-		require_once DOL_DOCUMENT_ROOT . '/asset/class/assetdepreciationoptions.class.php';
554
+		require_once DOL_DOCUMENT_ROOT.'/asset/class/assetdepreciationoptions.class.php';
555 555
 		$options_model = new AssetDepreciationOptions($this->db);
556 556
 		$result = $options_model->fetchDeprecationOptions(0, $this->fk_asset_model);
557 557
 		if ($result < 0) {
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 		// Get accountancy codes
587 587
 		//---------------------------
588 588
 		if (!$error) {
589
-			require_once DOL_DOCUMENT_ROOT . '/asset/class/assetaccountancycodes.class.php';
589
+			require_once DOL_DOCUMENT_ROOT.'/asset/class/assetaccountancycodes.class.php';
590 590
 			$accountancy_codes_model = new AssetAccountancyCodes($this->db);
591 591
 			$result = $accountancy_codes_model->fetchAccountancyCodes(0, $this->fk_asset_model);
592 592
 			if ($result < 0) {
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
 		// Check parameters
646 646
 		$error = 0;
647 647
 		if (empty($this->id)) {
648
-			$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Asset") . ' (' . $langs->transnoentitiesnoconv("TechnicalID") . ')');
648
+			$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Asset").' ('.$langs->transnoentitiesnoconv("TechnicalID").')');
649 649
 			$error++;
650 650
 		}
651 651
 		if ($error) {
@@ -668,15 +668,15 @@  discard block
 block discarded – undo
668 668
 		*/
669 669
 
670 670
 		$sql = "SELECT ad.rowid, ad.depreciation_mode, ad.ref, ad.depreciation_date, ad.depreciation_ht, ad.cumulative_depreciation_ht";
671
-		$sql .= ", " . $this->db->ifsql('iab.fk_docdet IS NOT NULL', 1, 0) . " AS bookkeeping";
672
-		$sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation AS ad";
673
-		$sql .= " LEFT JOIN (SELECT DISTINCT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE doc_type = 'asset') AS iab ON iab.fk_docdet = ad.rowid";
674
-		$sql .= " WHERE ad.fk_asset = " . (int) $this->id;
671
+		$sql .= ", ".$this->db->ifsql('iab.fk_docdet IS NOT NULL', 1, 0)." AS bookkeeping";
672
+		$sql .= " FROM ".MAIN_DB_PREFIX."asset_depreciation AS ad";
673
+		$sql .= " LEFT JOIN (SELECT DISTINCT fk_docdet FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE doc_type = 'asset') AS iab ON iab.fk_docdet = ad.rowid";
674
+		$sql .= " WHERE ad.fk_asset = ".(int) $this->id;
675 675
 		$sql .= " ORDER BY ad.depreciation_date ASC";
676 676
 
677 677
 		$resql = $this->db->query($sql);
678 678
 		if (!$resql) {
679
-			$this->errors[] = $langs->trans('AssetErrorFetchDepreciationLines') . ': ' . $this->db->lasterror();
679
+			$this->errors[] = $langs->trans('AssetErrorFetchDepreciationLines').': '.$this->db->lasterror();
680 680
 			return -1;
681 681
 		}
682 682
 
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
 		// Check parameters
712 712
 		$error = 0;
713 713
 		if (empty($this->id)) {
714
-			$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Asset") . ' (' . $langs->transnoentitiesnoconv("TechnicalID") . ')');
714
+			$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Asset").' ('.$langs->transnoentitiesnoconv("TechnicalID").')');
715 715
 			$error++;
716 716
 		}
717 717
 		if ($error) {
@@ -733,14 +733,14 @@  discard block
 block discarded – undo
733 733
 		*/
734 734
 
735 735
 		$sql = "SELECT COUNT(*) AS has_bookkeeping";
736
-		$sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation AS ad";
737
-		$sql .= " LEFT JOIN (SELECT DISTINCT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE doc_type = 'asset') AS iab ON iab.fk_docdet = ad.rowid";
738
-		$sql .= " WHERE ad.fk_asset = " . (int) $this->id;
736
+		$sql .= " FROM ".MAIN_DB_PREFIX."asset_depreciation AS ad";
737
+		$sql .= " LEFT JOIN (SELECT DISTINCT fk_docdet FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE doc_type = 'asset') AS iab ON iab.fk_docdet = ad.rowid";
738
+		$sql .= " WHERE ad.fk_asset = ".(int) $this->id;
739 739
 		$sql .= " AND iab.fk_docdet IS NOT NULL";
740 740
 
741 741
 		$resql = $this->db->query($sql);
742 742
 		if (!$resql) {
743
-			$this->errors[] = $langs->trans('AssetErrorFetchDepreciationLines') . ': ' . $this->db->lasterror();
743
+			$this->errors[] = $langs->trans('AssetErrorFetchDepreciationLines').': '.$this->db->lasterror();
744 744
 			return -1;
745 745
 		}
746 746
 
@@ -778,28 +778,28 @@  discard block
 block discarded – undo
778 778
 		// Check parameters
779 779
 		$error = 0;
780 780
 		if (empty($this->id)) {
781
-			$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Asset") . ' (' . $langs->transnoentitiesnoconv("TechnicalID") . ')');
781
+			$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Asset").' ('.$langs->transnoentitiesnoconv("TechnicalID").')');
782 782
 			$error++;
783 783
 		}
784 784
 		if ($error) {
785 785
 			return -1;
786 786
 		}
787 787
 
788
-		$sql = "INSERT INTO " . MAIN_DB_PREFIX . "asset_depreciation(fk_asset, depreciation_mode, ref, depreciation_date, depreciation_ht, cumulative_depreciation_ht, accountancy_code_debit, accountancy_code_credit)";
788
+		$sql = "INSERT INTO ".MAIN_DB_PREFIX."asset_depreciation(fk_asset, depreciation_mode, ref, depreciation_date, depreciation_ht, cumulative_depreciation_ht, accountancy_code_debit, accountancy_code_credit)";
789 789
 		$sql .= " VALUES ( ";
790
-		$sql .= " " . (int) $this->id;
791
-		$sql .= ", '" . $this->db->escape($mode) . "'";
792
-		$sql .= ", '" . $this->db->escape($ref) . "'";
793
-		$sql .= ", '" . $this->db->idate($depreciation_date) . "'";
794
-		$sql .= ", " . (double) $depreciation_ht;
795
-		$sql .= ", " . (double) $cumulative_depreciation_ht;
796
-		$sql .= ", '" . $this->db->escape($accountancy_code_debit) . "'";
797
-		$sql .= ", '" . $this->db->escape($accountancy_code_credit) . "'";
790
+		$sql .= " ".(int) $this->id;
791
+		$sql .= ", '".$this->db->escape($mode)."'";
792
+		$sql .= ", '".$this->db->escape($ref)."'";
793
+		$sql .= ", '".$this->db->idate($depreciation_date)."'";
794
+		$sql .= ", ".(double) $depreciation_ht;
795
+		$sql .= ", ".(double) $cumulative_depreciation_ht;
796
+		$sql .= ", '".$this->db->escape($accountancy_code_debit)."'";
797
+		$sql .= ", '".$this->db->escape($accountancy_code_credit)."'";
798 798
 		$sql .= ")";
799 799
 
800 800
 		$resql = $this->db->query($sql);
801 801
 		if (!$resql) {
802
-			$this->errors[] = $langs->trans('AssetErrorAddDepreciationLine') . ': ' . $this->db->lasterror();
802
+			$this->errors[] = $langs->trans('AssetErrorAddDepreciationLine').': '.$this->db->lasterror();
803 803
 			return -1;
804 804
 		}
805 805
 
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
 		// Check parameters
823 823
 		$error = 0;
824 824
 		if (empty($this->id)) {
825
-			$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Asset") . ' (' . $langs->transnoentitiesnoconv("TechnicalID") . ')');
825
+			$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Asset").' ('.$langs->transnoentitiesnoconv("TechnicalID").')');
826 826
 			$error++;
827 827
 		}
828 828
 		if ($error) {
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
 
832 832
 		// Get depreciation options
833 833
 		//---------------------------
834
-		require_once DOL_DOCUMENT_ROOT . '/asset/class/assetdepreciationoptions.class.php';
834
+		require_once DOL_DOCUMENT_ROOT.'/asset/class/assetdepreciationoptions.class.php';
835 835
 		$options = new AssetDepreciationOptions($this->db);
836 836
 		$result = $options->fetchDeprecationOptions($this->id);
837 837
 		if ($result < 0) {
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 
843 843
 		// Get accountancy codes
844 844
 		//---------------------------
845
-		require_once DOL_DOCUMENT_ROOT . '/asset/class/assetaccountancycodes.class.php';
845
+		require_once DOL_DOCUMENT_ROOT.'/asset/class/assetaccountancycodes.class.php';
846 846
 		$accountancy_codes = new AssetAccountancyCodes($this->db);
847 847
 		$result = $accountancy_codes->fetchAccountancyCodes($this->id);
848 848
 		if ($result < 0) {
@@ -858,20 +858,20 @@  discard block
 block discarded – undo
858 858
 		foreach ($options->deprecation_options as $mode_key => $fields) {
859 859
 			$modes[$mode_key] = $this->db->escape($mode_key);
860 860
 		}
861
-		$sql = "DELETE FROM " . MAIN_DB_PREFIX . "asset_depreciation";
862
-		$sql .= " WHERE fk_asset = " . (int) $this->id;
863
-		$sql .= " AND depreciation_mode NOT IN ('" . $this->db->sanitize(implode("', '", $modes)) . "')";
861
+		$sql = "DELETE FROM ".MAIN_DB_PREFIX."asset_depreciation";
862
+		$sql .= " WHERE fk_asset = ".(int) $this->id;
863
+		$sql .= " AND depreciation_mode NOT IN ('".$this->db->sanitize(implode("', '", $modes))."')";
864 864
 
865 865
 		$resql = $this->db->query($sql);
866 866
 		if (!$resql) {
867
-			$this->errors[] = $langs->trans('AssetErrorClearDepreciationLines') . ': ' . $this->db->lasterror();
867
+			$this->errors[] = $langs->trans('AssetErrorClearDepreciationLines').': '.$this->db->lasterror();
868 868
 			$error++;
869 869
 		}
870 870
 
871 871
 		if (!$error) {
872 872
 			// Get fiscal period
873
-			require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
874
-			require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
873
+			require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
874
+			require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
875 875
 			$dates = getDefaultDatesForTransfer();
876 876
 			$init_fiscal_period_start = $dates['date_start'];
877 877
 			$init_fiscal_period_end = $dates['date_end'];
@@ -904,17 +904,17 @@  discard block
 block discarded – undo
904 904
 				*/
905 905
 
906 906
 				$sql = "SELECT ad.depreciation_date, ad.cumulative_depreciation_ht";
907
-				$sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation AS ad";
908
-				$sql .= " LEFT JOIN (SELECT DISTINCT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE doc_type = 'asset') AS iab ON iab.fk_docdet = ad.rowid";
909
-				$sql .= " WHERE ad.fk_asset = " . (int) $this->id;
910
-				$sql .= " AND ad.depreciation_mode = '" . $this->db->escape($mode_key) . "'";
907
+				$sql .= " FROM ".MAIN_DB_PREFIX."asset_depreciation AS ad";
908
+				$sql .= " LEFT JOIN (SELECT DISTINCT fk_docdet FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE doc_type = 'asset') AS iab ON iab.fk_docdet = ad.rowid";
909
+				$sql .= " WHERE ad.fk_asset = ".(int) $this->id;
910
+				$sql .= " AND ad.depreciation_mode = '".$this->db->escape($mode_key)."'";
911 911
 				$sql .= " AND iab.fk_docdet IS NOT NULL";
912 912
 				$sql .= " ORDER BY ad.depreciation_date DESC";
913 913
 				$sql .= " LIMIT 1";
914 914
 
915 915
 				$resql = $this->db->query($sql);
916 916
 				if (!$resql) {
917
-					$this->errors[] = $langs->trans('AssetErrorFetchMaxDepreciationDateForMode', $mode_key) . ': ' . $this->db->lasterror();
917
+					$this->errors[] = $langs->trans('AssetErrorFetchMaxDepreciationDateForMode', $mode_key).': '.$this->db->lasterror();
918 918
 					$error++;
919 919
 					break;
920 920
 				}
@@ -926,26 +926,26 @@  discard block
 block discarded – undo
926 926
 				}
927 927
 
928 928
 				// Set last cumulative depreciation
929
-				$sql = "UPDATE " . MAIN_DB_PREFIX . $options->deprecation_options_fields[$mode_key]['table'];
930
-				$sql .= " SET total_amount_last_depreciation_ht = " . (empty($last_cumulative_depreciation_ht) ? 0 : $last_cumulative_depreciation_ht);
931
-				$sql .= " WHERE fk_asset = " . (int) $this->id;
929
+				$sql = "UPDATE ".MAIN_DB_PREFIX.$options->deprecation_options_fields[$mode_key]['table'];
930
+				$sql .= " SET total_amount_last_depreciation_ht = ".(empty($last_cumulative_depreciation_ht) ? 0 : $last_cumulative_depreciation_ht);
931
+				$sql .= " WHERE fk_asset = ".(int) $this->id;
932 932
 				$resql = $this->db->query($sql);
933 933
 				if (!$resql) {
934
-					$this->errors[] = $langs->trans('AssetErrorSetLastCumulativeDepreciation') . ': ' . $this->db->lasterror();
934
+					$this->errors[] = $langs->trans('AssetErrorSetLastCumulativeDepreciation').': '.$this->db->lasterror();
935 935
 					$error++;
936 936
 					break;
937 937
 				}
938 938
 
939 939
 				// Delete old lines
940
-				$sql = "DELETE " . MAIN_DB_PREFIX . "asset_depreciation FROM " . MAIN_DB_PREFIX . "asset_depreciation";
941
-				$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab ON ab.doc_type = 'asset' AND ab.fk_docdet = " . MAIN_DB_PREFIX . "asset_depreciation.rowid";
942
-				$sql .= " WHERE " . MAIN_DB_PREFIX . "asset_depreciation.fk_asset = " . (int) $this->id;
943
-				$sql .= " AND " . MAIN_DB_PREFIX . "asset_depreciation.depreciation_mode = '" . $this->db->escape($mode_key) . "'";
940
+				$sql = "DELETE ".MAIN_DB_PREFIX."asset_depreciation FROM ".MAIN_DB_PREFIX."asset_depreciation";
941
+				$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as ab ON ab.doc_type = 'asset' AND ab.fk_docdet = ".MAIN_DB_PREFIX."asset_depreciation.rowid";
942
+				$sql .= " WHERE ".MAIN_DB_PREFIX."asset_depreciation.fk_asset = ".(int) $this->id;
943
+				$sql .= " AND ".MAIN_DB_PREFIX."asset_depreciation.depreciation_mode = '".$this->db->escape($mode_key)."'";
944 944
 				$sql .= " AND ab.fk_docdet IS NULL";
945
-				if ($last_depreciation_date !== "") $sql .= " AND " . MAIN_DB_PREFIX . "asset_depreciation.ref != ''";
945
+				if ($last_depreciation_date !== "") $sql .= " AND ".MAIN_DB_PREFIX."asset_depreciation.ref != ''";
946 946
 				$resql = $this->db->query($sql);
947 947
 				if (!$resql) {
948
-					$this->errors[] = $langs->trans('AssetErrorClearDepreciationLines') . ': ' . $this->db->lasterror();
948
+					$this->errors[] = $langs->trans('AssetErrorClearDepreciationLines').': '.$this->db->lasterror();
949 949
 					$error++;
950 950
 					break;
951 951
 				}
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
 				$first_period_found = false;
1013 1013
 				$first_period_date = isset($begin_period) && $begin_period > $fiscal_period_start ? $begin_period : $fiscal_period_start;
1014 1014
 
1015
-				$ref_date_format = "%Y" . ($fields['duration_type'] == 1 || $fields['duration_type'] == 2 ? '-%m' : '') . ($fields['duration_type'] == 2 ? '-%d' : '');
1015
+				$ref_date_format = "%Y".($fields['duration_type'] == 1 || $fields['duration_type'] == 2 ? '-%m' : '').($fields['duration_type'] == 2 ? '-%d' : '');
1016 1016
 
1017 1017
 				// Loop security
1018 1018
 				$idx_loop = 0;
@@ -1032,9 +1032,9 @@  discard block
 block discarded – undo
1032 1032
 
1033 1033
 						$period_begin = dol_print_date($fiscal_period_start, $ref_date_format);
1034 1034
 						$period_end = dol_print_date($fiscal_period_end, $ref_date_format);
1035
-						$ref = $period_begin . ($period_begin != $period_end ? ' - ' . $period_end : '');
1035
+						$ref = $period_begin.($period_begin != $period_end ? ' - '.$period_end : '');
1036 1036
 						if ($fiscal_period_start <= $disposal_date && $disposal_date <= $fiscal_period_end) {
1037
-							$ref .= ' - ' . $langs->transnoentitiesnoconv('AssetDisposal');
1037
+							$ref .= ' - '.$langs->transnoentitiesnoconv('AssetDisposal');
1038 1038
 						}
1039 1039
 
1040 1040
 						$begin_date = $fiscal_period_start < $start_date && $start_date <= $fiscal_period_end ? $start_date : $fiscal_period_start;
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
 		// Check parameters
1114 1114
 		$error = 0;
1115 1115
 		if (empty($asset_depreciation_id)) {
1116
-			$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AssetDepreciation") . ' (' . $langs->transnoentitiesnoconv("TechnicalID") . ')');
1116
+			$this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AssetDepreciation").' ('.$langs->transnoentitiesnoconv("TechnicalID").')');
1117 1117
 			$error++;
1118 1118
 		}
1119 1119
 		if ($error) {
@@ -1122,28 +1122,28 @@  discard block
 block discarded – undo
1122 1122
 
1123 1123
 		$this->db->begin();
1124 1124
 
1125
-		require_once DOL_DOCUMENT_ROOT . '/asset/class/assetdepreciationoptions.class.php';
1125
+		require_once DOL_DOCUMENT_ROOT.'/asset/class/assetdepreciationoptions.class.php';
1126 1126
 		$options = new AssetDepreciationOptions($this->db);
1127 1127
 
1128 1128
 		// Get last depreciation lines save in bookkeeping
1129 1129
 		//-----------------------------------------------------
1130 1130
 		$sql = "SELECT fk_asset, depreciation_mode, cumulative_depreciation_ht";
1131
-		$sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation";
1132
-		$sql .= " WHERE rowid = " . (int) $asset_depreciation_id;
1131
+		$sql .= " FROM ".MAIN_DB_PREFIX."asset_depreciation";
1132
+		$sql .= " WHERE rowid = ".(int) $asset_depreciation_id;
1133 1133
 		$resql = $this->db->query($sql);
1134 1134
 		if (!$resql) {
1135
-			$this->errors[] = $langs->trans('AssetErrorFetchCumulativeDepreciation') . ': ' . $this->db->lasterror();
1135
+			$this->errors[] = $langs->trans('AssetErrorFetchCumulativeDepreciation').': '.$this->db->lasterror();
1136 1136
 			$error++;
1137 1137
 		} else {
1138 1138
 			if ($obj = $this->db->fetch_object($resql)) {
1139 1139
 				$mode_key = $obj->depreciation_mode;
1140 1140
 				if (!empty($options->deprecation_options_fields[$mode_key])) {
1141
-					$sql = "UPDATE " . MAIN_DB_PREFIX . $options->deprecation_options_fields[$mode_key]['table'];
1142
-					$sql .= " SET total_amount_last_depreciation_ht = " . $obj->cumulative_depreciation_ht;
1143
-					$sql .= " WHERE fk_asset = " . (int) $obj->fk_asset;
1141
+					$sql = "UPDATE ".MAIN_DB_PREFIX.$options->deprecation_options_fields[$mode_key]['table'];
1142
+					$sql .= " SET total_amount_last_depreciation_ht = ".$obj->cumulative_depreciation_ht;
1143
+					$sql .= " WHERE fk_asset = ".(int) $obj->fk_asset;
1144 1144
 					$resql = $this->db->query($sql);
1145 1145
 					if (!$resql) {
1146
-						$this->errors[] = $langs->trans('AssetErrorSetLastCumulativeDepreciation') . ': ' . $this->db->lasterror();
1146
+						$this->errors[] = $langs->trans('AssetErrorSetLastCumulativeDepreciation').': '.$this->db->lasterror();
1147 1147
 						$error++;
1148 1148
 					}
1149 1149
 				}
@@ -1388,7 +1388,7 @@  discard block
 block discarded – undo
1388 1388
 		if ($withpicto != 2) {
1389 1389
 			$name = $this->ref;
1390 1390
 			if ($option == 'label') $name = $this->label;
1391
-			elseif ($option == 'with_label') $name .= ' - ' . $this->label;
1391
+			elseif ($option == 'with_label') $name .= ' - '.$this->label;
1392 1392
 			$result .= dol_escape_htmltag($maxlen ? dol_trunc($name, $maxlen) : $name);
1393 1393
 		}
1394 1394
 
@@ -1396,7 +1396,7 @@  discard block
 block discarded – undo
1396 1396
 		//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
1397 1397
 
1398 1398
 		global $action;
1399
-		$hookmanager->initHooks(array($this->element . 'dao'));
1399
+		$hookmanager->initHooks(array($this->element.'dao'));
1400 1400
 		$parameters = array('id'=>$this->id, 'getnomurl' => &$result);
1401 1401
 		$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1402 1402
 		if ($reshook > 0) {
Please login to merge, or discard this patch.
htdocs/asset/class/assetmodel.class.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	/**
101 101
 	 * @var array  Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
102 102
 	 */
103
-	public $fields=array(
103
+	public $fields = array(
104 104
 		'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
105 105
 		'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'validate'=>'1'),
106 106
 		'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'showoncombobox'=>'2', 'validate'=>'1',),
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 
447 447
 		// Protection
448 448
 		if ($this->status == self::STATUS_VALIDATED) {
449
-			dol_syslog(get_class($this) . "::validate action abandonned: already validated", LOG_WARNING);
449
+			dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
450 450
 			return 0;
451 451
 		}
452 452
 
@@ -455,17 +455,17 @@  discard block
 block discarded – undo
455 455
 		$this->db->begin();
456 456
 
457 457
 		// Validate
458
-		$sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element;
459
-		$sql .= " SET status = " . self::STATUS_VALIDATED;
458
+		$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
459
+		$sql .= " SET status = ".self::STATUS_VALIDATED;
460 460
 		if (!empty($this->fields['date_validation'])) {
461
-			$sql .= ", date_validation = '" . $this->db->idate($now) . "'";
461
+			$sql .= ", date_validation = '".$this->db->idate($now)."'";
462 462
 		}
463 463
 		if (!empty($this->fields['fk_user_valid'])) {
464
-			$sql .= ", fk_user_valid = " . ((int) $user->id);
464
+			$sql .= ", fk_user_valid = ".((int) $user->id);
465 465
 		}
466
-		$sql .= " WHERE rowid = " . ((int) $this->id);
466
+		$sql .= " WHERE rowid = ".((int) $this->id);
467 467
 
468
-		dol_syslog(get_class($this) . "::validate()", LOG_DEBUG);
468
+		dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
469 469
 		$resql = $this->db->query($sql);
470 470
 		if (!$resql) {
471 471
 			dol_print_error($this->db);
Please login to merge, or discard this patch.
htdocs/asset/class/assetaccountancycodes.class.php 2 patches
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.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		foreach ($this->accountancy_codes_fields as $mode_key => $mode_info) {
90 90
 			$this->accountancy_codes[$mode_key] = array();
91 91
 			foreach ($mode_info['fields'] as $field_key => $field_info) {
92
-				$accountancy_code = GETPOST($mode_key . '_' . $field_key, 'aZ09');
92
+				$accountancy_code = GETPOST($mode_key.'_'.$field_key, 'aZ09');
93 93
 				if (empty($accountancy_code) || $accountancy_code == '-1') $accountancy_code = '';
94 94
 				$this->accountancy_codes[$mode_key][$field_key] = $accountancy_code;
95 95
 			}
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	public function fetchAccountancyCodes($asset_id = 0, $asset_model_id = 0)
108 108
 	{
109 109
 		global $langs, $hookmanager;
110
-		dol_syslog(__METHOD__ . " asset_id=$asset_id, asset_model_id=$asset_model_id");
110
+		dol_syslog(__METHOD__." asset_id=$asset_id, asset_model_id=$asset_model_id");
111 111
 
112 112
 		$error = 0;
113 113
 		$this->errors = array();
@@ -130,15 +130,15 @@  discard block
 block discarded – undo
130 130
 			$error++;
131 131
 		}
132 132
 		if ($error) {
133
-			dol_syslog(__METHOD__ . " Error check parameters: " . $this->errorsToString(), LOG_ERR);
133
+			dol_syslog(__METHOD__." Error check parameters: ".$this->errorsToString(), LOG_ERR);
134 134
 			return -1;
135 135
 		}
136 136
 
137 137
 		$accountancy_codes = array();
138 138
 		foreach ($this->accountancy_codes_fields as $mode_key => $mode_info) {
139
-			$sql = "SELECT " . implode(',', array_keys($mode_info['fields']));
140
-			$sql .= " FROM " . MAIN_DB_PREFIX . $mode_info['table'];
141
-			$sql .= " WHERE " . ($asset_id > 0 ? " fk_asset = " . (int) $asset_id : " fk_asset_model = " . (int) $asset_model_id);
139
+			$sql = "SELECT ".implode(',', array_keys($mode_info['fields']));
140
+			$sql .= " FROM ".MAIN_DB_PREFIX.$mode_info['table'];
141
+			$sql .= " WHERE ".($asset_id > 0 ? " fk_asset = ".(int) $asset_id : " fk_asset_model = ".(int) $asset_model_id);
142 142
 
143 143
 			$resql = $this->db->query($sql);
144 144
 			if ($resql) {
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
 					}
150 150
 				}
151 151
 			} else {
152
-				$this->errors[] = $langs->trans('AssetErrorFetchAccountancyCodesForMode', $mode_key) . ': ' . $this->db->lasterror();
152
+				$this->errors[] = $langs->trans('AssetErrorFetchAccountancyCodesForMode', $mode_key).': '.$this->db->lasterror();
153 153
 				$error++;
154 154
 			}
155 155
 		}
156 156
 
157 157
 		if ($error) {
158
-			dol_syslog(__METHOD__ . " Error fetch accountancy codes: " . $this->errorsToString(), LOG_ERR);
158
+			dol_syslog(__METHOD__." Error fetch accountancy codes: ".$this->errorsToString(), LOG_ERR);
159 159
 			return -1;
160 160
 		} else {
161 161
 			$this->accountancy_codes = $accountancy_codes;
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	public function updateAccountancyCodes($user, $asset_id = 0, $asset_model_id = 0, $notrigger = 0)
176 176
 	{
177 177
 		global $langs, $hookmanager;
178
-		dol_syslog(__METHOD__ . " user_id=".$user->id.", asset_id=".$asset_id.", asset_model_id=".$asset_model_id.", notrigger=".$notrigger);
178
+		dol_syslog(__METHOD__." user_id=".$user->id.", asset_id=".$asset_id.", asset_model_id=".$asset_model_id.", notrigger=".$notrigger);
179 179
 
180 180
 		$error = 0;
181 181
 		$this->errors = array();
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 			$error++;
198 198
 		}
199 199
 		if ($error) {
200
-			dol_syslog(__METHOD__ . " Error check parameters: " . $this->errorsToString(), LOG_ERR);
200
+			dol_syslog(__METHOD__." Error check parameters: ".$this->errorsToString(), LOG_ERR);
201 201
 			return -1;
202 202
 		}
203 203
 
@@ -206,32 +206,32 @@  discard block
 block discarded – undo
206 206
 
207 207
 		foreach ($this->accountancy_codes_fields as $mode_key => $mode_info) {
208 208
 			// Delete old accountancy codes
209
-			$sql = "DELETE FROM " . MAIN_DB_PREFIX . $mode_info['table'];
210
-			$sql .= " WHERE " . ($asset_id > 0 ? " fk_asset = " . (int) $asset_id : " fk_asset_model = " . (int) $asset_model_id);
209
+			$sql = "DELETE FROM ".MAIN_DB_PREFIX.$mode_info['table'];
210
+			$sql .= " WHERE ".($asset_id > 0 ? " fk_asset = ".(int) $asset_id : " fk_asset_model = ".(int) $asset_model_id);
211 211
 			$resql = $this->db->query($sql);
212 212
 			if (!$resql) {
213
-				$this->errors[] = $langs->trans('AssetErrorDeleteAccountancyCodesForMode', $mode_key) . ': ' . $this->db->lasterror();
213
+				$this->errors[] = $langs->trans('AssetErrorDeleteAccountancyCodesForMode', $mode_key).': '.$this->db->lasterror();
214 214
 				$error++;
215 215
 			}
216 216
 
217 217
 			if (!$error && !empty($this->accountancy_codes[$mode_key])) {
218 218
 				// Insert accountancy codes
219
-				$sql = "INSERT INTO " . MAIN_DB_PREFIX . $mode_info['table'] . "(";
219
+				$sql = "INSERT INTO ".MAIN_DB_PREFIX.$mode_info['table']."(";
220 220
 				$sql .= $asset_id > 0 ? "fk_asset," : "fk_asset_model,";
221 221
 				$sql .= implode(',', array_keys($mode_info['fields']));
222 222
 				$sql .= ", tms, fk_user_modif";
223 223
 				$sql .= ") VALUES(";
224 224
 				$sql .= $asset_id > 0 ? $asset_id : $asset_model_id;
225 225
 				foreach ($mode_info['fields'] as $field_key => $field_info) {
226
-					$sql .= ', ' . (empty($this->accountancy_codes[$mode_key][$field_key]) ? 'NULL' : "'" . $this->db->escape($this->accountancy_codes[$mode_key][$field_key]) . "'");
226
+					$sql .= ', '.(empty($this->accountancy_codes[$mode_key][$field_key]) ? 'NULL' : "'".$this->db->escape($this->accountancy_codes[$mode_key][$field_key])."'");
227 227
 				}
228
-				$sql .= ", '" . $this->db->idate($now) . "'";
229
-				$sql .= ", " . $user->id;
228
+				$sql .= ", '".$this->db->idate($now)."'";
229
+				$sql .= ", ".$user->id;
230 230
 				$sql .= ")";
231 231
 
232 232
 				$resql = $this->db->query($sql);
233 233
 				if (!$resql) {
234
-					$this->errors[] = $langs->trans('AssetErrorInsertAccountancyCodesForMode', $mode_key) . ': ' . $this->db->lasterror();
234
+					$this->errors[] = $langs->trans('AssetErrorInsertAccountancyCodesForMode', $mode_key).': '.$this->db->lasterror();
235 235
 					$error++;
236 236
 				}
237 237
 			}
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 
240 240
 		if (!$error && $asset_id > 0) {
241 241
 			// Calculation of depreciation lines (reversal and future)
242
-			require_once DOL_DOCUMENT_ROOT . '/asset/class/asset.class.php';
242
+			require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php';
243 243
 			$asset = new Asset($this->db);
244 244
 			$result = $asset->fetch($asset_id);
245 245
 			if ($result > 0) $result = $asset->calculationDepreciation();
Please login to merge, or discard this patch.
htdocs/asset/class/assetdepreciationoptions.class.php 2 patches
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.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 			'table'	=> 'asset_depreciation_options_economic',
79 79
 			'fields' => array(
80 80
 				'depreciation_type' => array('type'=>'smallint', 'label'=>'AssetDepreciationOptionDepreciationType', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'arrayofkeyval'=>array('0'=>'AssetDepreciationOptionDepreciationTypeLinear', '1'=>'AssetDepreciationOptionDepreciationTypeDegressive', '2'=>'AssetDepreciationOptionDepreciationTypeExceptional'), 'validate'=>'1',),
81
-				'degressive_coefficient' => array('type'=>'double(24,8)', 'label'=>'AssetDepreciationOptionDegressiveRate', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1','enabled_field' => 'economic:depreciation_type:1'),
81
+				'degressive_coefficient' => array('type'=>'double(24,8)', 'label'=>'AssetDepreciationOptionDegressiveRate', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1', 'enabled_field' => 'economic:depreciation_type:1'),
82 82
 				'duration' => array('type'=>'integer', 'label'=>'AssetDepreciationOptionDuration', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1',),
83 83
 				'duration_type' => array('type'=>'smallint', 'label'=>'AssetDepreciationOptionDurationType', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'arrayofkeyval'=>array('0'=>'AssetDepreciationOptionDurationTypeAnnual', '1'=>'AssetDepreciationOptionDurationTypeMonthly'/*, '2'=>'AssetDepreciationOptionDurationTypeDaily'*/), 'validate'=>'1',),
84 84
 				'rate' => array('type'=>'double(24,8)', 'label'=>'AssetDepreciationOptionRate', 'enabled'=>'1', 'position'=>50, 'visible'=>3, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1', 'computed' => '$object->asset_depreciation_options->getRate("economic")',),
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 			'enabled_field' => 'economic:accelerated_depreciation_option:1',
95 95
 			'fields' => array(
96 96
 				'depreciation_type' => array('type'=>'smallint', 'label'=>'AssetDepreciationOptionDepreciationType', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'arrayofkeyval'=>array('0'=>'AssetDepreciationOptionDepreciationTypeLinear', '1'=>'AssetDepreciationOptionDepreciationTypeDegressive', '2'=>'AssetDepreciationOptionDepreciationTypeExceptional'), 'validate'=>'1',),
97
-				'degressive_coefficient' => array('type'=>'double(24,8)', 'label'=>'AssetDepreciationOptionDegressiveRate', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1','enabled_field' => 'accelerated_depreciation:depreciation_type:1'),
97
+				'degressive_coefficient' => array('type'=>'double(24,8)', 'label'=>'AssetDepreciationOptionDegressiveRate', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1', 'enabled_field' => 'accelerated_depreciation:depreciation_type:1'),
98 98
 				'duration' => array('type'=>'integer', 'label'=>'AssetDepreciationOptionDuration', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1',),
99 99
 				'duration_type' => array('type'=>'smallint', 'label'=>'AssetDepreciationOptionDurationType', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'arrayofkeyval'=>array('0'=>'AssetDepreciationOptionDurationTypeAnnual', '1'=>'AssetDepreciationOptionDurationTypeMonthly'/*, '2'=>'AssetDepreciationOptionDurationTypeDaily'*/), 'validate'=>'1',),
100 100
 				'rate' => array('type'=>'double(24,8)', 'label'=>'AssetDepreciationOptionRate', 'enabled'=>'1', 'position'=>50, 'visible'=>3, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1', 'computed' => '$object->asset_depreciation_options->getRate("accelerated_depreciation")',),
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
 					continue;
208 208
 				}
209 209
 
210
-				$html_name = $mode_key . '_' . $field_key;
210
+				$html_name = $mode_key.'_'.$field_key;
211 211
 				if ($field_info['type'] == 'duration') {
212
-					if (GETPOST($html_name . 'hour') == '' && GETPOST($html_name . 'min') == '') {
212
+					if (GETPOST($html_name.'hour') == '' && GETPOST($html_name.'min') == '') {
213 213
 						continue; // The field was not submited to be saved
214 214
 					}
215 215
 				} else {
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
 				if (in_array($field_info['type'], array('text', 'html'))) {
232 232
 					$value = GETPOST($html_name, 'restricthtml');
233 233
 				} elseif ($field_info['type'] == 'date') {
234
-					$value = dol_mktime(12, 0, 0, GETPOST($html_name . 'month', 'int'), GETPOST($html_name . 'day', 'int'), GETPOST($html_name . 'year', 'int')); // for date without hour, we use gmt
234
+					$value = dol_mktime(12, 0, 0, GETPOST($html_name.'month', 'int'), GETPOST($html_name.'day', 'int'), GETPOST($html_name.'year', 'int')); // for date without hour, we use gmt
235 235
 				} elseif ($field_info['type'] == 'datetime') {
236
-					$value = dol_mktime(GETPOST($html_name . 'hour', 'int'), GETPOST($html_name . 'min', 'int'), GETPOST($html_name . 'sec', 'int'), GETPOST($html_name . 'month', 'int'), GETPOST($html_name . 'day', 'int'), GETPOST($html_name . 'year', 'int'), 'tzuserrel');
236
+					$value = dol_mktime(GETPOST($html_name.'hour', 'int'), GETPOST($html_name.'min', 'int'), GETPOST($html_name.'sec', 'int'), GETPOST($html_name.'month', 'int'), GETPOST($html_name.'day', 'int'), GETPOST($html_name.'year', 'int'), 'tzuserrel');
237 237
 				} elseif ($field_info['type'] == 'duration') {
238
-					$value = 60 * 60 * GETPOST($html_name . 'hour', 'int') + 60 * GETPOST($html_name . 'min', 'int');
238
+					$value = 60 * 60 * GETPOST($html_name.'hour', 'int') + 60 * GETPOST($html_name.'min', 'int');
239 239
 				} elseif (preg_match('/^(integer|price|real|double)/', $field_info['type'])) {
240 240
 					$value = price2num(GETPOST($html_name, 'alphanohtml')); // To fix decimal separator according to lang setup
241 241
 				} elseif ($field_info['type'] == 'boolean') {
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 				} elseif ($field_info['type'] == 'reference') {
244 244
 					// todo to check
245 245
 					$tmparraykey = array(); //array_keys($object->param_list);
246
-					$value = $tmparraykey[GETPOST($html_name)] . ',' . GETPOST($html_name . '2');
246
+					$value = $tmparraykey[GETPOST($html_name)].','.GETPOST($html_name.'2');
247 247
 				} else {
248 248
 					if ($field_key == 'lang') {
249 249
 						$value = GETPOST($html_name, 'aZ09') ? GETPOST($html_name, 'aZ09') : "";
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	public function fetchDeprecationOptions($asset_id = 0, $asset_model_id = 0)
310 310
 	{
311 311
 		global $langs, $hookmanager;
312
-		dol_syslog(__METHOD__ . " asset_id=$asset_id, asset_model_id=$asset_model_id");
312
+		dol_syslog(__METHOD__." asset_id=$asset_id, asset_model_id=$asset_model_id");
313 313
 
314 314
 		$error = 0;
315 315
 		$this->errors = array();
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 			$error++;
333 333
 		}
334 334
 		if ($error) {
335
-			dol_syslog(__METHOD__ . " Error check parameters: " . $this->errorsToString(), LOG_ERR);
335
+			dol_syslog(__METHOD__." Error check parameters: ".$this->errorsToString(), LOG_ERR);
336 336
 			return -1;
337 337
 		}
338 338
 
@@ -341,9 +341,9 @@  discard block
 block discarded – undo
341 341
 		foreach ($this->deprecation_options_fields as $mode_key => $mode_info) {
342 342
 			$this->setInfosForMode($mode_key, $class_type);
343 343
 
344
-			$result = $this->fetchCommon(0, '', " AND " . ($asset_id > 0 ? " fk_asset = " . (int) $asset_id : " fk_asset_model = " . (int) $asset_model_id));
344
+			$result = $this->fetchCommon(0, '', " AND ".($asset_id > 0 ? " fk_asset = ".(int) $asset_id : " fk_asset_model = ".(int) $asset_model_id));
345 345
 			if ($result < 0) {
346
-				$this->errors = array_merge(array($langs->trans('AssetErrorFetchDepreciationOptionsForMode', $mode_key) . ':'), $this->errors);
346
+				$this->errors = array_merge(array($langs->trans('AssetErrorFetchDepreciationOptionsForMode', $mode_key).':'), $this->errors);
347 347
 				$error++;
348 348
 			} elseif ($result > 0) {
349 349
 				foreach ($this->fields as $field_key => $field_info) {
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 		}
364 364
 
365 365
 		if ($error) {
366
-			dol_syslog(__METHOD__ . " Error fetch accountancy codes: " . $this->errorsToString(), LOG_ERR);
366
+			dol_syslog(__METHOD__." Error fetch accountancy codes: ".$this->errorsToString(), LOG_ERR);
367 367
 			return -1;
368 368
 		} else {
369 369
 			$this->deprecation_options = $deprecation_options;
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 	public function getGeneralDepreciationInfoForMode($mode)
381 381
 	{
382 382
 		global $hookmanager;
383
-		dol_syslog(__METHOD__ . " mode=$mode");
383
+		dol_syslog(__METHOD__." mode=$mode");
384 384
 
385 385
 		$this->errors = array();
386 386
 
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 	public function updateDeprecationOptions($user, $asset_id = 0, $asset_model_id = 0, $notrigger = 0)
419 419
 	{
420 420
 		global $langs, $hookmanager;
421
-		dol_syslog(__METHOD__ . " user_id=".$user->id.", asset_id=".$asset_id.", asset_model_id=".$asset_model_id.", notrigger=".$notrigger);
421
+		dol_syslog(__METHOD__." user_id=".$user->id.", asset_id=".$asset_id.", asset_model_id=".$asset_model_id.", notrigger=".$notrigger);
422 422
 
423 423
 		$error = 0;
424 424
 		$this->errors = array();
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 			$error++;
441 441
 		}
442 442
 		if ($error) {
443
-			dol_syslog(__METHOD__ . " Error check parameters: " . $this->errorsToString(), LOG_ERR);
443
+			dol_syslog(__METHOD__." Error check parameters: ".$this->errorsToString(), LOG_ERR);
444 444
 			return -1;
445 445
 		}
446 446
 
@@ -458,11 +458,11 @@  discard block
 block discarded – undo
458 458
 
459 459
 		foreach ($this->deprecation_options_fields as $mode_key => $mode_info) {
460 460
 			// Delete old accountancy codes
461
-			$sql = "DELETE FROM " . MAIN_DB_PREFIX . $mode_info['table'];
462
-			$sql .= " WHERE " . ($asset_id > 0 ? " fk_asset = " . (int) $asset_id : " fk_asset_model = " . (int) $asset_model_id);
461
+			$sql = "DELETE FROM ".MAIN_DB_PREFIX.$mode_info['table'];
462
+			$sql .= " WHERE ".($asset_id > 0 ? " fk_asset = ".(int) $asset_id : " fk_asset_model = ".(int) $asset_model_id);
463 463
 			$resql = $this->db->query($sql);
464 464
 			if (!$resql) {
465
-				$this->errors[] = $langs->trans('AssetErrorDeleteDepreciationOptionsForMode', $mode_key) . ': ' . $this->db->lasterror();
465
+				$this->errors[] = $langs->trans('AssetErrorDeleteDepreciationOptionsForMode', $mode_key).': '.$this->db->lasterror();
466 466
 				$error++;
467 467
 			}
468 468
 
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 
479 479
 				$result = $this->createCommon($user, 1);
480 480
 				if ($result < 0) {
481
-					$this->errors = array_merge(array($langs->trans('AssetErrorInsertDepreciationOptionsForMode', $mode_key) . ':'), $this->errors);
481
+					$this->errors = array_merge(array($langs->trans('AssetErrorInsertDepreciationOptionsForMode', $mode_key).':'), $this->errors);
482 482
 					$error++;
483 483
 				}
484 484
 			}
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 
487 487
 		if (!$error && $this->fk_asset > 0) {
488 488
 			// Calculation of depreciation lines (reversal and future)
489
-			require_once DOL_DOCUMENT_ROOT . '/asset/class/asset.class.php';
489
+			require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php';
490 490
 			$asset = new Asset($this->db);
491 491
 			$result = $asset->fetch($this->fk_asset);
492 492
 			if ($result > 0) $result = $asset->calculationDepreciation();
Please login to merge, or discard this patch.
htdocs/asset/tpl/depreciation_options_edit.tpl.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 }
36 36
 
37 37
 if (!is_object($formadmin)) {
38
-	require_once DOL_DOCUMENT_ROOT . '/core/class/html.formadmin.class.php';
38
+	require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
39 39
 	$formadmin = new FormAdmin($db);
40 40
 }
41 41
 
@@ -69,19 +69,19 @@  discard block
 block discarded – undo
69 69
 				'mode_key' => $info[0],
70 70
 				'field_key' => $info[1],
71 71
 				'value' => $info[2],
72
-				'target' => 'block_' . $mode_key,
72
+				'target' => 'block_'.$mode_key,
73 73
 			);
74 74
 		}
75 75
 
76 76
 		$assetdepreciationoptions->setInfosForMode($mode_key, $class_type, true);
77
-		$prefix_html_name = $mode_key . '_';
77
+		$prefix_html_name = $mode_key.'_';
78 78
 
79
-		print '<div id="block_' . $mode_key . '">';
79
+		print '<div id="block_'.$mode_key.'">';
80 80
 		print load_fiche_titre($langs->trans($mode_info['label']), '', '');
81 81
 		print '<div class="fichecenter">';
82 82
 		print '<div class="fichehalfleft">';
83 83
 		print '<div class="underbanner clearboth"></div>';
84
-		print '<table class="border centpercent tableforfield">' . "\n";
84
+		print '<table class="border centpercent tableforfield">'."\n";
85 85
 		$mode_info['fields'] = dol_sort_array($mode_info['fields'], 'position');
86 86
 		foreach ($mode_info['fields'] as $field_key => $field_info) {
87 87
 			// Discard if extrafield is a hidden field on form
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
 				print '<table class="border centpercent tableforfield">';
103 103
 			}
104 104
 
105
-			$html_name = $prefix_html_name . $field_key;
105
+			$html_name = $prefix_html_name.$field_key;
106 106
 			if (!empty($field_info['enabled_field'])) {
107 107
 				$info = explode(':', $field_info['enabled_field']);
108 108
 				$enabled_field_info[] = array(
109 109
 					'mode_key' => $info[0],
110 110
 					'field_key' => $info[1],
111 111
 					'value' => $info[2],
112
-					'target' => 'field_' . $html_name,
112
+					'target' => 'field_'.$html_name,
113 113
 				);
114 114
 			}
115 115
 
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
 				$more_class .= ' tdtop';
122 122
 			}
123 123
 
124
-			print '<tr class="field_' . $html_name . '" id="field_' . $html_name . '"><td';
125
-			print ' class="titlefieldcreate' . $more_class . '">';
124
+			print '<tr class="field_'.$html_name.'" id="field_'.$html_name.'"><td';
125
+			print ' class="titlefieldcreate'.$more_class.'">';
126 126
 			if (!empty($field_info['help'])) {
127 127
 				print $form->textwithpicto($langs->trans($field_info['label']), $langs->trans($field_info['help']));
128 128
 			} else {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -221,7 +221,7 @@
 block discarded – undo
221 221
 		}
222 222
 	});
223 223
 </script>
224
-SCRIPT;
224
+script;
225 225
 }
226 226
 
227 227
 ?>
Please login to merge, or discard this patch.
htdocs/asset/tpl/depreciation_view.tpl.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		print '<div class="fichecenter">';
68 68
 		print '<div class="fichehalfleft">';
69 69
 		print '<div class="underbanner clearboth"></div>';
70
-		print '<table class="border centpercent tableforfield">' . "\n";
70
+		print '<table class="border centpercent tableforfield">'."\n";
71 71
 		$mode_info['fields'] = dol_sort_array($mode_info['fields'], 'position');
72 72
 		foreach ($mode_info['fields'] as $field_key => $field_info) {
73 73
 			if (!empty($field_info['enabled_field'])) {
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
 				print '<table class="border centpercent tableforfield">';
95 95
 			}
96 96
 
97
-			$key = $mode_key . '_' . $field_key;
97
+			$key = $mode_key.'_'.$field_key;
98 98
 			$value = $assetdepreciationoptions->deprecation_options[$mode_key][$field_key];
99 99
 
100
-			print '<tr class="field_' . $key . '"><td';
101
-			print ' class="' . (empty($field_info['tdcss']) ? 'titlefield' : $field_info['tdcss']) . ' fieldname_' . $key;
100
+			print '<tr class="field_'.$key.'"><td';
101
+			print ' class="'.(empty($field_info['tdcss']) ? 'titlefield' : $field_info['tdcss']).' fieldname_'.$key;
102 102
 			if ($field_info['type'] == 'text' || $field_info['type'] == 'html') {
103 103
 				print ' tdtop';
104 104
 			}
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
 				}
114 114
 			}
115 115
 			print '</td>';
116
-			print '<td class="valuefield fieldname_' . $key;
116
+			print '<td class="valuefield fieldname_'.$key;
117 117
 			if ($field_info['type'] == 'text') {
118 118
 				print ' wordbreak';
119 119
 			}
120 120
 			if (!empty($field_info['cssview'])) {
121
-				print ' ' . $field_info['cssview'];
121
+				print ' '.$field_info['cssview'];
122 122
 			}
123 123
 			print '">';
124 124
 			if (in_array($field_info['type'], array('text', 'html'))) {
@@ -126,15 +126,15 @@  discard block
 block discarded – undo
126 126
 			}
127 127
 			if ($field_key == 'lang') {
128 128
 				$langs->load("languages");
129
-				$labellang = ($value ? $langs->trans('Language_' . $value) : '');
129
+				$labellang = ($value ? $langs->trans('Language_'.$value) : '');
130 130
 				print picto_from_langcode($value, 'class="paddingrightonly saturatemedium opacitylow"');
131 131
 				print $labellang;
132 132
 			} else {
133 133
 				if (isset($field_info['copytoclipboard']) && $field_info['copytoclipboard'] == 2) {
134
-					$out = $assetdepreciationoptions->showOutputField($field_info, $field_key, $value, '', '', $mode_key . '_', 0);
134
+					$out = $assetdepreciationoptions->showOutputField($field_info, $field_key, $value, '', '', $mode_key.'_', 0);
135 135
 					print showValueWithClipboardCPButton($out, 0, $out);
136 136
 				} else {
137
-					print $assetdepreciationoptions->showOutputField($field_info, $field_key, $value, '', '', $mode_key . '_', 0);
137
+					print $assetdepreciationoptions->showOutputField($field_info, $field_key, $value, '', '', $mode_key.'_', 0);
138 138
 				}
139 139
 			}
140 140
 			if (in_array($field_info['type'], array('text', 'html'))) {
Please login to merge, or discard this patch.