@@ -90,7 +90,9 @@ discard block |
||
| 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 |
||
| 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(); |
@@ -89,7 +89,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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(); |
@@ -352,7 +352,9 @@ discard block |
||
| 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 |
||
| 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(); |
@@ -78,7 +78,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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(); |
@@ -35,7 +35,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 { |
@@ -221,7 +221,7 @@ |
||
| 221 | 221 | } |
| 222 | 222 | }); |
| 223 | 223 | </script> |
| 224 | -SCRIPT; |
|
| 224 | +script; |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | ?> |
@@ -67,7 +67,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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'))) { |
@@ -80,32 +80,32 @@ discard block |
||
| 80 | 80 | $h = 0; |
| 81 | 81 | $head = array(); |
| 82 | 82 | |
| 83 | - $head[$h][0] = DOL_URL_ROOT . '/asset/card.php?id=' . $object->id; |
|
| 83 | + $head[$h][0] = DOL_URL_ROOT.'/asset/card.php?id='.$object->id; |
|
| 84 | 84 | $head[$h][1] = $langs->trans("Card"); |
| 85 | 85 | $head[$h][2] = 'card'; |
| 86 | 86 | $h++; |
| 87 | 87 | |
| 88 | 88 | if (empty($object->not_depreciated)) { |
| 89 | - $head[$h][0] = DOL_URL_ROOT . '/asset/depreciation_options.php?id=' . $object->id; |
|
| 89 | + $head[$h][0] = DOL_URL_ROOT.'/asset/depreciation_options.php?id='.$object->id; |
|
| 90 | 90 | $head[$h][1] = $langs->trans("AssetDepreciationOptions"); |
| 91 | 91 | $head[$h][2] = 'depreciation_options'; |
| 92 | 92 | $h++; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - $head[$h][0] = DOL_URL_ROOT . '/asset/accountancy_codes.php?id=' . $object->id; |
|
| 95 | + $head[$h][0] = DOL_URL_ROOT.'/asset/accountancy_codes.php?id='.$object->id; |
|
| 96 | 96 | $head[$h][1] = $langs->trans("AssetAccountancyCodes"); |
| 97 | 97 | $head[$h][2] = 'accountancy_codes'; |
| 98 | 98 | $h++; |
| 99 | 99 | |
| 100 | 100 | if (empty($object->not_depreciated)) { |
| 101 | - $head[$h][0] = DOL_URL_ROOT . '/asset/depreciation.php?id=' . $object->id; |
|
| 101 | + $head[$h][0] = DOL_URL_ROOT.'/asset/depreciation.php?id='.$object->id; |
|
| 102 | 102 | $head[$h][1] = $langs->trans("AssetDepreciation"); |
| 103 | 103 | $head[$h][2] = 'depreciation'; |
| 104 | 104 | $h++; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | if (isset($object->disposal_date) && $object->disposal_date !== "") { |
| 108 | - $head[$h][0] = DOL_URL_ROOT . '/asset/disposal.php?id=' . $object->id; |
|
| 108 | + $head[$h][0] = DOL_URL_ROOT.'/asset/disposal.php?id='.$object->id; |
|
| 109 | 109 | $head[$h][1] = $langs->trans("AssetDisposal"); |
| 110 | 110 | $head[$h][2] = 'disposal'; |
| 111 | 111 | $h++; |
@@ -119,29 +119,29 @@ discard block |
||
| 119 | 119 | if (!empty($object->note_public)) { |
| 120 | 120 | $nbNote++; |
| 121 | 121 | } |
| 122 | - $head[$h][0] = DOL_URL_ROOT . '/asset/note.php?id=' . $object->id; |
|
| 122 | + $head[$h][0] = DOL_URL_ROOT.'/asset/note.php?id='.$object->id; |
|
| 123 | 123 | $head[$h][1] = $langs->trans('Notes'); |
| 124 | 124 | if ($nbNote > 0) { |
| 125 | - $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">' . $nbNote . '</span>' : ''); |
|
| 125 | + $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : ''); |
|
| 126 | 126 | } |
| 127 | 127 | $head[$h][2] = 'note'; |
| 128 | 128 | $h++; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; |
|
| 132 | - require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; |
|
| 133 | - $upload_dir = $conf->asset->dir_output . "/asset/" . dol_sanitizeFileName($object->ref); |
|
| 131 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
|
| 132 | + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; |
|
| 133 | + $upload_dir = $conf->asset->dir_output."/asset/".dol_sanitizeFileName($object->ref); |
|
| 134 | 134 | $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); |
| 135 | 135 | $nbLinks = Link::count($db, $object->element, $object->id); |
| 136 | - $head[$h][0] = DOL_URL_ROOT . '/asset/document.php?id=' . $object->id; |
|
| 136 | + $head[$h][0] = DOL_URL_ROOT.'/asset/document.php?id='.$object->id; |
|
| 137 | 137 | $head[$h][1] = $langs->trans('Documents'); |
| 138 | 138 | if (($nbFiles + $nbLinks) > 0) { |
| 139 | - $head[$h][1] .= '<span class="badge marginleftonlyshort">' . ($nbFiles + $nbLinks) . '</span>'; |
|
| 139 | + $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>'; |
|
| 140 | 140 | } |
| 141 | 141 | $head[$h][2] = 'document'; |
| 142 | 142 | $h++; |
| 143 | 143 | |
| 144 | - $head[$h][0] = DOL_URL_ROOT . '/asset/agenda.php?id=' . $object->id; |
|
| 144 | + $head[$h][0] = DOL_URL_ROOT.'/asset/agenda.php?id='.$object->id; |
|
| 145 | 145 | $head[$h][1] = $langs->trans("Events"); |
| 146 | 146 | $head[$h][2] = 'agenda'; |
| 147 | 147 | $h++; |
@@ -176,17 +176,17 @@ discard block |
||
| 176 | 176 | $h = 0; |
| 177 | 177 | $head = array(); |
| 178 | 178 | |
| 179 | - $head[$h][0] = DOL_URL_ROOT . '/asset/model/card.php?id=' . $object->id; |
|
| 179 | + $head[$h][0] = DOL_URL_ROOT.'/asset/model/card.php?id='.$object->id; |
|
| 180 | 180 | $head[$h][1] = $langs->trans("Card"); |
| 181 | 181 | $head[$h][2] = 'card'; |
| 182 | 182 | $h++; |
| 183 | 183 | |
| 184 | - $head[$h][0] = DOL_URL_ROOT . '/asset/model/depreciation_options.php?id=' . $object->id; |
|
| 184 | + $head[$h][0] = DOL_URL_ROOT.'/asset/model/depreciation_options.php?id='.$object->id; |
|
| 185 | 185 | $head[$h][1] = $langs->trans("AssetDepreciationOptions"); |
| 186 | 186 | $head[$h][2] = 'depreciation_options'; |
| 187 | 187 | $h++; |
| 188 | 188 | |
| 189 | - $head[$h][0] = DOL_URL_ROOT . '/asset/model/accountancy_codes.php?id=' . $object->id; |
|
| 189 | + $head[$h][0] = DOL_URL_ROOT.'/asset/model/accountancy_codes.php?id='.$object->id; |
|
| 190 | 190 | $head[$h][1] = $langs->trans("AssetAccountancyCodes"); |
| 191 | 191 | $head[$h][2] = 'accountancy_codes'; |
| 192 | 192 | $h++; |
@@ -199,16 +199,16 @@ discard block |
||
| 199 | 199 | if (!empty($object->note_public)) { |
| 200 | 200 | $nbNote++; |
| 201 | 201 | } |
| 202 | - $head[$h][0] = DOL_URL_ROOT . '/asset/model/note.php?id=' . $object->id; |
|
| 202 | + $head[$h][0] = DOL_URL_ROOT.'/asset/model/note.php?id='.$object->id; |
|
| 203 | 203 | $head[$h][1] = $langs->trans('Notes'); |
| 204 | 204 | if ($nbNote > 0) { |
| 205 | - $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">' . $nbNote . '</span>' : ''); |
|
| 205 | + $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : ''); |
|
| 206 | 206 | } |
| 207 | 207 | $head[$h][2] = 'note'; |
| 208 | 208 | $h++; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - $head[$h][0] = DOL_URL_ROOT . '/asset/model/agenda.php?id=' . $object->id; |
|
| 211 | + $head[$h][0] = DOL_URL_ROOT.'/asset/model/agenda.php?id='.$object->id; |
|
| 212 | 212 | $head[$h][1] = $langs->trans("Events"); |
| 213 | 213 | $head[$h][2] = 'agenda'; |
| 214 | 214 | $h++; |
@@ -397,9 +397,15 @@ |
||
| 397 | 397 | ) { |
| 398 | 398 | $accountancy_category_asset = $conf->global->ASSET_ACCOUNTANCY_CATEGORY; |
| 399 | 399 | $filters = array(); |
| 400 | - if (!empty($product_static->accountancy_code_buy)) $filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy) . "'"; |
|
| 401 | - if (!empty($product_static->accountancy_code_buy_intra)) $filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy_intra) . "'"; |
|
| 402 | - if (!empty($product_static->accountancy_code_buy_export)) $filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy_export) . "'"; |
|
| 400 | + if (!empty($product_static->accountancy_code_buy)) { |
|
| 401 | + $filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy) . "'"; |
|
| 402 | + } |
|
| 403 | + if (!empty($product_static->accountancy_code_buy_intra)) { |
|
| 404 | + $filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy_intra) . "'"; |
|
| 405 | + } |
|
| 406 | + if (!empty($product_static->accountancy_code_buy_export)) { |
|
| 407 | + $filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy_export) . "'"; |
|
| 408 | + } |
|
| 403 | 409 | $sql = "SELECT COUNT(*) AS found"; |
| 404 | 410 | $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account"; |
| 405 | 411 | $sql .= " WHERE pcg_type = '" . $this->db->escape($conf->global->ASSET_ACCOUNTANCY_CATEGORY) . "'"; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $discount = new DiscountAbsolute($this->db); |
| 111 | 111 | $discount->fetch($line->fk_remise_except); |
| 112 | 112 | print ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0)); |
| 113 | - } elseif ($line->description == '(DEPOSIT)' && $line->fk_remise_except > 0) { |
|
| 113 | + } elseif ($line->description == '(DEPOSIT)' && $line->fk_remise_except > 0) { |
|
| 114 | 114 | include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; |
| 115 | 115 | $discount = new DiscountAbsolute($this->db); |
| 116 | 116 | $discount->fetch($line->fk_remise_except); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) { |
| 120 | 120 | print ' ('.dol_print_date($discount->datec).')'; |
| 121 | 121 | } |
| 122 | - } elseif ($line->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) { |
|
| 122 | + } elseif ($line->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) { |
|
| 123 | 123 | include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; |
| 124 | 124 | $discount = new DiscountAbsolute($this->db); |
| 125 | 125 | $discount->fetch($line->fk_remise_except); |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | // we need to fetch product associated to line for some test |
| 194 | 194 | if ($object->element == 'propal' || $object->element == 'order' || $object->element == 'facture' || $object->element == 'propal_supplier' || $object->element == 'supplier_proposal' || $object->element == 'commande') { |
| 195 | 195 | $res = $line->fetch_product(); |
| 196 | - if ($res > 0 ) { |
|
| 196 | + if ($res > 0) { |
|
| 197 | 197 | if ($line->product->isService() && $line->product->isMandatoryPeriod()) { |
| 198 | 198 | print '<div><span class="clearboth nowraponall warning">'.$langs->trans("mandatoryPeriodNeedTobeSet").'</span></div>'; |
| 199 | 199 | } |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | } |
| 286 | 286 | } |
| 287 | 287 | if ($mysoc->useLocalTax(2)) { |
| 288 | - if (( isset($seller->country_code) && isset($buyer->thirdparty->country_code) && $seller->country_code == $buyer->thirdparty->country_code) || $line->total_localtax2 || $seller->useLocalTax(2)) { |
|
| 288 | + if ((isset($seller->country_code) && isset($buyer->thirdparty->country_code) && $seller->country_code == $buyer->thirdparty->country_code) || $line->total_localtax2 || $seller->useLocalTax(2)) { |
|
| 289 | 289 | $tooltiponprice .= '<br>'.$langs->transcountry("TotalLT2", $seller->country_code).'='.price($line->total_localtax2); |
| 290 | 290 | } else { |
| 291 | 291 | $tooltiponprice .= '<br>'.$langs->transcountry("TotalLT2", $seller->country_code).'=<span class="opacitymedium">'.$langs->trans($senderissupplier ? "NotUsedForThisVendor" : "NotUsedForThisCustomer").'</span>'; |
@@ -431,20 +431,20 @@ discard block |
||
| 431 | 431 | ) { |
| 432 | 432 | $accountancy_category_asset = $conf->global->ASSET_ACCOUNTANCY_CATEGORY; |
| 433 | 433 | $filters = array(); |
| 434 | - if (!empty($product_static->accountancy_code_buy)) $filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy) . "'"; |
|
| 435 | - if (!empty($product_static->accountancy_code_buy_intra)) $filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy_intra) . "'"; |
|
| 436 | - if (!empty($product_static->accountancy_code_buy_export)) $filters[] = "account_number = '" . $this->db->escape($product_static->accountancy_code_buy_export) . "'"; |
|
| 434 | + if (!empty($product_static->accountancy_code_buy)) $filters[] = "account_number = '".$this->db->escape($product_static->accountancy_code_buy)."'"; |
|
| 435 | + if (!empty($product_static->accountancy_code_buy_intra)) $filters[] = "account_number = '".$this->db->escape($product_static->accountancy_code_buy_intra)."'"; |
|
| 436 | + if (!empty($product_static->accountancy_code_buy_export)) $filters[] = "account_number = '".$this->db->escape($product_static->accountancy_code_buy_export)."'"; |
|
| 437 | 437 | $sql = "SELECT COUNT(*) AS found"; |
| 438 | - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account"; |
|
| 439 | - $sql .= " WHERE pcg_type = '" . $this->db->escape($conf->global->ASSET_ACCOUNTANCY_CATEGORY) . "'"; |
|
| 440 | - $sql .= " AND (" . implode(' OR ', $filters). ")"; |
|
| 438 | + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account"; |
|
| 439 | + $sql .= " WHERE pcg_type = '".$this->db->escape($conf->global->ASSET_ACCOUNTANCY_CATEGORY)."'"; |
|
| 440 | + $sql .= " AND (".implode(' OR ', $filters).")"; |
|
| 441 | 441 | $resql_asset = $this->db->query($sql); |
| 442 | 442 | if (!$resql_asset) { |
| 443 | - print 'Error SQL: ' . $this->db->lasterror(); |
|
| 443 | + print 'Error SQL: '.$this->db->lasterror(); |
|
| 444 | 444 | } elseif ($obj = $this->db->fetch_object($resql_asset)) { |
| 445 | 445 | if (!empty($obj->found)) { |
| 446 | - print '<a class="reposition" href="' . DOL_URL_ROOT . '/asset/card.php?action=create&token='.newToken().'&supplier_invoice_id='.$object->id.'">'; |
|
| 447 | - print img_edit_add() . '</a>'; |
|
| 446 | + print '<a class="reposition" href="'.DOL_URL_ROOT.'/asset/card.php?action=create&token='.newToken().'&supplier_invoice_id='.$object->id.'">'; |
|
| 447 | + print img_edit_add().'</a>'; |
|
| 448 | 448 | } |
| 449 | 449 | } |
| 450 | 450 | } |
@@ -349,8 +349,9 @@ discard block |
||
| 349 | 349 | |
| 350 | 350 | $rang = $i; |
| 351 | 351 | //there may already be rows from previous receptions |
| 352 | - if (!empty($createbills_onebythird)) |
|
| 353 | - $rang = $TFactThirdNbLines[$rcp->socid]; |
|
| 352 | + if (!empty($createbills_onebythird)) { |
|
| 353 | + $rang = $TFactThirdNbLines[$rcp->socid]; |
|
| 354 | + } |
|
| 354 | 355 | |
| 355 | 356 | $result = $objecttmp->addline( |
| 356 | 357 | $desc, |
@@ -380,8 +381,10 @@ discard block |
||
| 380 | 381 | |
| 381 | 382 | if ($result > 0) { |
| 382 | 383 | $lineid = $result; |
| 383 | - if (!empty($createbills_onebythird)) //increment rang to keep order |
|
| 384 | + if (!empty($createbills_onebythird)) { |
|
| 385 | + //increment rang to keep order |
|
| 384 | 386 | $TFactThirdNbLines[$rcp->socid]++; |
| 387 | + } |
|
| 385 | 388 | } else { |
| 386 | 389 | $lineid = 0; |
| 387 | 390 | $error++; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $search_date_delivery_endday = GETPOST('search_date_delivery_endday', 'int'); |
| 60 | 60 | $search_date_delivery_endmonth = GETPOST('search_date_delivery_endmonth', 'int'); |
| 61 | 61 | $search_date_delivery_endyear = GETPOST('search_date_delivery_endyear', 'int'); |
| 62 | -$search_date_delivery_start = dol_mktime(0, 0, 0, $search_date_delivery_startmonth, $search_date_delivery_startday, $search_date_delivery_startyear); // Use tzserver |
|
| 62 | +$search_date_delivery_start = dol_mktime(0, 0, 0, $search_date_delivery_startmonth, $search_date_delivery_startday, $search_date_delivery_startyear); // Use tzserver |
|
| 63 | 63 | $search_date_delivery_end = dol_mktime(23, 59, 59, $search_date_delivery_endmonth, $search_date_delivery_endday, $search_date_delivery_endyear); |
| 64 | 64 | $search_date_create_startday = GETPOST('search_date_create_startday', 'int'); |
| 65 | 65 | $search_date_create_startmonth = GETPOST('search_date_create_startmonth', 'int'); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $search_date_create_endday = GETPOST('search_date_create_endday', 'int'); |
| 68 | 68 | $search_date_create_endmonth = GETPOST('search_date_create_endmonth', 'int'); |
| 69 | 69 | $search_date_create_endyear = GETPOST('search_date_create_endyear', 'int'); |
| 70 | -$search_date_create_start = dol_mktime(0, 0, 0, $search_date_create_startmonth, $search_date_create_startday, $search_date_create_startyear); // Use tzserver |
|
| 70 | +$search_date_create_start = dol_mktime(0, 0, 0, $search_date_create_startmonth, $search_date_create_startday, $search_date_create_startyear); // Use tzserver |
|
| 71 | 71 | $search_date_create_end = dol_mktime(23, 59, 59, $search_date_create_endmonth, $search_date_create_endday, $search_date_create_endyear); |
| 72 | 72 | $search_billed = GETPOST("search_billed", 'int'); |
| 73 | 73 | $sall = GETPOST('sall', 'alphanohtml'); |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | $TFactThirdNbLines = array(); |
| 222 | 222 | |
| 223 | 223 | $nb_bills_created = 0; |
| 224 | - $lastid= 0; |
|
| 224 | + $lastid = 0; |
|
| 225 | 225 | $lastref = ''; |
| 226 | 226 | |
| 227 | 227 | $db->begin(); |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | // if the VAT reverse-charge is activated by default in supplier card to resume the information |
| 350 | 350 | $objecttmp->vat_reverse_charge = $soc->vat_reverse_charge; |
| 351 | 351 | |
| 352 | - $objecttmp->fk_project = $rcp->fk_project; |
|
| 352 | + $objecttmp->fk_project = $rcp->fk_project; |
|
| 353 | 353 | //$objecttmp->multicurrency_code = $rcp->multicurrency_code; |
| 354 | 354 | if (empty($createbills_onebythird)) { |
| 355 | 355 | $objecttmp->ref_supplier = $rcp->ref; |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | } |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - $res = $objecttmp->create($user); // This should create the supplier invoice + links into $objecttmp->linked_objects + add a link to ->origin_id |
|
| 385 | + $res = $objecttmp->create($user); // This should create the supplier invoice + links into $objecttmp->linked_objects + add a link to ->origin_id |
|
| 386 | 386 | |
| 387 | 387 | //var_dump($objecttmp->error);exit; |
| 388 | 388 | if ($res > 0) { |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | |
| 556 | 556 | $id = $objecttmp->id; // For builddoc action |
| 557 | 557 | $lastref = $objecttmp->ref; // generated ref |
| 558 | - $object =$objecttmp; |
|
| 558 | + $object = $objecttmp; |
|
| 559 | 559 | |
| 560 | 560 | // Fac builddoc |
| 561 | 561 | $donotredirect = 1; |
@@ -67,7 +67,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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'))) { |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | $amount = $credit; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - return "'" . $this->db->escape(abs($amount)) . "'"; |
|
| 109 | + return "'".$this->db->escape(abs($amount))."'"; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | return "''"; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | $sens = 'C'; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - return "'" . $this->db->escape($sens) . "'"; |
|
| 137 | + return "'".$this->db->escape($sens)."'"; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | return "''"; |