@@ -954,7 +954,7 @@ |
||
954 | 954 | } |
955 | 955 | $result .= $linkend; |
956 | 956 | global $action; |
957 | - $hookmanager->initHooks(array($this->element . 'dao')); |
|
957 | + $hookmanager->initHooks(array($this->element.'dao')); |
|
958 | 958 | $parameters = array('id'=>$this->id, 'getnomurl' => &$result); |
959 | 959 | $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
960 | 960 | if ($reshook > 0) { |
@@ -751,12 +751,12 @@ |
||
751 | 751 | } |
752 | 752 | |
753 | 753 | /** |
754 | - * Return clicable link of object (with eventually picto) |
|
755 | - * |
|
756 | - * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) |
|
757 | - * @param array $arraydata Array of data |
|
758 | - * @return string HTML Code for Kanban thumb. |
|
759 | - */ |
|
754 | + * Return clicable link of object (with eventually picto) |
|
755 | + * |
|
756 | + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) |
|
757 | + * @param array $arraydata Array of data |
|
758 | + * @return string HTML Code for Kanban thumb. |
|
759 | + */ |
|
760 | 760 | public function getKanbanView($option = '', $arraydata = null) |
761 | 761 | { |
762 | 762 | global $conf, $langs; |
@@ -987,7 +987,7 @@ |
||
987 | 987 | $result .= $linkend; |
988 | 988 | |
989 | 989 | global $action; |
990 | - $hookmanager->initHooks(array($this->element . 'dao')); |
|
990 | + $hookmanager->initHooks(array($this->element.'dao')); |
|
991 | 991 | $parameters = array('id'=>$this->id, 'getnomurl' => &$result); |
992 | 992 | $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
993 | 993 | if ($reshook > 0) { |
@@ -29,16 +29,28 @@ discard block |
||
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 |
||
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 | /* |
@@ -38,9 +38,9 @@ |
||
38 | 38 | // Only works if you are not in safe_mode. / Ne fonctionne que si on est pas en safe_mode. |
39 | 39 | |
40 | 40 | $err = error_reporting(); |
41 | -error_reporting(0); // Disable all errors |
|
41 | +error_reporting(0); // Disable all errors |
|
42 | 42 | //error_reporting(E_ALL); |
43 | -@set_time_limit(1800); // Need 1800 on some very slow OS like Windows 7/64 |
|
43 | +@set_time_limit(1800); // Need 1800 on some very slow OS like Windows 7/64 |
|
44 | 44 | error_reporting($err); |
45 | 45 | |
46 | 46 | $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : (empty($argv[1]) ? '' : $argv[1]); |
@@ -91,7 +91,7 @@ discard block |
||
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>'; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | |
106 | 106 | |
107 | 107 | $cssclass = "titlefield"; |
108 | - include DOL_DOCUMENT_ROOT . '/core/tpl/notes.tpl.php'; |
|
108 | + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; |
|
109 | 109 | |
110 | 110 | print '</div>'; |
111 | 111 |
@@ -55,10 +55,14 @@ |
||
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(); |
|
63 | +if (!isModEnabled('asset')) { |
|
64 | + accessforbidden(); |
|
65 | +} |
|
62 | 66 | |
63 | 67 | |
64 | 68 | /* |
@@ -91,7 +91,7 @@ |
||
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>'; |
@@ -55,11 +55,17 @@ |
||
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 | /* |
@@ -37,10 +37,10 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -140,8 +140,12 @@ discard block |
||
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 |
||
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'] = ''; |
@@ -55,12 +55,20 @@ |
||
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 | /* |
@@ -24,8 +24,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -225,14 +225,20 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -60,8 +60,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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) { |