@@ -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 | |
@@ -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(); |
@@ -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(); |
@@ -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) . "'"; |
@@ -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++; |
@@ -479,7 +479,9 @@ |
||
| 479 | 479 | $sql .= " titre = '" . (!empty($this->titre) ? $this->db->escape($this->titre) : "")."'," ; |
| 480 | 480 | $sql .= " ref_supplier = '". (!empty($this->ref_supplier) ? $this->db->escape($this->ref_supplier) : "")."',"; |
| 481 | 481 | $sql .= " entity = ". (!empty($this->entity) ? ((int) $this->entity) : 1) . ','; |
| 482 | - if ($this->fk_soc > 0) $sql .= " fk_soc = ". (int) $this->fk_soc. ','; |
|
| 482 | + if ($this->fk_soc > 0) { |
|
| 483 | + $sql .= " fk_soc = ". (int) $this->fk_soc. ','; |
|
| 484 | + } |
|
| 483 | 485 | $sql .= " suspended = ". (!empty($this->suspended) ? ((int) $this->suspended) : 0) . ','; |
| 484 | 486 | $sql .= " libelle = ". (!empty($this->libelle) ? "'".$this->db->escape($this->libelle)."'" : 'NULL') . ","; |
| 485 | 487 | $sql .= " vat_src_code = ". (!empty($this->vat_src_code) ? "'".$this->db->escape($this->vat_src_code)."'" : 'NULL') . ','; |
@@ -447,13 +447,17 @@ |
||
| 447 | 447 | $object->setContract($linked_contract->id); |
| 448 | 448 | // don't set '$contractid' so it is not used when creating an intervention. |
| 449 | 449 | } |
| 450 | - if (empty(NOLOGIN)) setEventMessage($langs->trans('TicketManyContractsLinked'), 'warnings'); |
|
| 450 | + if (empty(NOLOGIN)) { |
|
| 451 | + setEventMessage($langs->trans('TicketManyContractsLinked'), 'warnings'); |
|
| 452 | + } |
|
| 451 | 453 | break; |
| 452 | 454 | } |
| 453 | 455 | } |
| 454 | 456 | } |
| 455 | 457 | if ($number_contracts_found == 0) { |
| 456 | - if (empty(NOLOGIN)) setEventMessage($langs->trans('TicketNoContractFoundToLink'), 'mesgs'); |
|
| 458 | + if (empty(NOLOGIN)) { |
|
| 459 | + setEventMessage($langs->trans('TicketNoContractFoundToLink'), 'mesgs'); |
|
| 460 | + } |
|
| 457 | 461 | } |
| 458 | 462 | } |
| 459 | 463 | // Automatically create intervention |
@@ -144,7 +144,9 @@ |
||
| 144 | 144 | //$socid = $user->socid; |
| 145 | 145 | accessforbidden(); |
| 146 | 146 | } |
| 147 | -if (!$permissiontoread) accessforbidden(); |
|
| 147 | +if (!$permissiontoread) { |
|
| 148 | + accessforbidden(); |
|
| 149 | +} |
|
| 148 | 150 | |
| 149 | 151 | |
| 150 | 152 | /* |
@@ -57,7 +57,9 @@ |
||
| 57 | 57 | |
| 58 | 58 | // Category |
| 59 | 59 | $selected_cat = (int) GETPOST('search_categ', 'int'); |
| 60 | -if ($selected_cat == -1) $selected_cat = ''; |
|
| 60 | +if ($selected_cat == -1) { |
|
| 61 | + $selected_cat = ''; |
|
| 62 | +} |
|
| 61 | 63 | $subcat = false; |
| 62 | 64 | if (GETPOST('subcat', 'alpha') === 'yes') { |
| 63 | 65 | $subcat = true; |