28require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
38 public $module =
'asset';
43 public $element =
'asset';
48 public $table_element =
'asset';
53 public $picto =
'asset';
55 const STATUS_DRAFT = 0;
56 const STATUS_DISPOSED = 9;
89 public $fields = array(
90 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'position' => 1,
'notnull' => 1,
'visible' => 0,
'noteditable' => 1,
'index' => 1,
'css' =>
'left',
'comment' =>
"Id"),
91 '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"),
92 '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,),
93 'fk_asset_model' => array(
'type' =>
'integer:AssetModel:asset/class/assetmodel.class.php:1:((status:=:1) and (entity:IN:__SHARED_ENTITIES__))',
'label' =>
'AssetModel',
'enabled' => 1,
'position' => 40,
'notnull' => 0,
'visible' => 1,
'index' => 1,
'validate' => 1,),
94 'qty' => array(
'type' =>
'real',
'label' =>
'Qty',
'enabled' => 1,
'position' => 50,
'notnull' => 1,
'visible' => 0,
'default' =>
'1',
'isameasure' => 1,
'css' =>
'maxwidth75imp',
'validate' => 1,),
95 'acquisition_type' => array(
'type' =>
'smallint',
'label' =>
'AssetAcquisitionType',
'enabled' => 1,
'position' => 60,
'notnull' => 1,
'visible' => 1,
'arrayofkeyval' => array(
'0' =>
'AssetAcquisitionTypeNew',
'1' =>
'AssetAcquisitionTypeOccasion'),
'validate' => 1,),
96 'asset_type' => array(
'type' =>
'smallint',
'label' =>
'AssetType',
'enabled' => 1,
'position' => 70,
'notnull' => 1,
'visible' => 1,
'arrayofkeyval' => array(
'0' =>
'AssetTypeIntangible',
'1' =>
'AssetTypeTangible',
'2' =>
'AssetTypeInProgress',
'3' =>
'AssetTypeFinancial'),
'validate' => 1,),
97 'not_depreciated' => array(
'type' =>
'boolean',
'label' =>
'AssetNotDepreciated',
'enabled' => 1,
'position' => 80,
'notnull' => 0,
'default' =>
'0',
'visible' => 1,
'validate' => 1,),
98 'date_acquisition' => array(
'type' =>
'date',
'label' =>
'AssetDateAcquisition',
'enabled' => 1,
'position' => 90,
'notnull' => 1,
'visible' => 1,),
99 'date_start' => array(
'type' =>
'date',
'label' =>
'AssetDateStart',
'enabled' => 1,
'position' => 100,
'notnull' => 0,
'visible' => -1,),
100 'acquisition_value_ht' => array(
'type' =>
'price',
'label' =>
'AssetAcquisitionValueHT',
'enabled' => 1,
'position' => 110,
'notnull' => 1,
'visible' => 1,
'isameasure' => 1,
'validate' => 1,),
101 'recovered_vat' => array(
'type' =>
'price',
'label' =>
'AssetRecoveredVAT',
'enabled' => 1,
'position' => 120,
'notnull' => 0,
'visible' => 1,
'isameasure' => 1,
'validate' => 1,),
102 'reversal_date' => array(
'type' =>
'date',
'label' =>
'AssetReversalDate',
'enabled' => 1,
'position' => 130,
'notnull' => 0,
'visible' => 1,),
103 'reversal_amount_ht' => array(
'type' =>
'price',
'label' =>
'AssetReversalAmountHT',
'enabled' => 1,
'position' => 140,
'notnull' => 0,
'visible' => 1,
'isameasure' => 1,
'validate' => 1,),
104 'disposal_date' => array(
'type' =>
'date',
'label' =>
'AssetDisposalDate',
'enabled' => 1,
'position' => 200,
'notnull' => 0,
'visible' => -2,),
105 'disposal_amount_ht' => array(
'type' =>
'price',
'label' =>
'AssetDisposalAmount',
'enabled' => 1,
'position' => 210,
'notnull' => 0,
'visible' => -2,
'default' =>
'0',
'isameasure' => 1,
'validate' => 1,),
106 'fk_disposal_type' => array(
'type' =>
'sellist:c_asset_disposal_type:label:rowid::active=1',
'label' =>
'AssetDisposalType',
'enabled' => 1,
'position' => 220,
'notnull' => 0,
'visible' => -2,
'index' => 1,
'validate' => 1,),
107 'disposal_depreciated' => array(
'type' =>
'boolean',
'label' =>
'AssetDisposalDepreciated',
'enabled' => 1,
'position' => 230,
'notnull' => 0,
'default' =>
'0',
'visible' => -2,
'validate' => 1,),
108 'disposal_subject_to_vat' => array(
'type' =>
'boolean',
'label' =>
'AssetDisposalSubjectToVat',
'enabled' => 1,
'position' => 240,
'notnull' => 0,
'default' =>
'0',
'visible' => -2,
'validate' => 1,),
109 'note_public' => array(
'type' =>
'html',
'label' =>
'NotePublic',
'enabled' => 1,
'position' => 300,
'notnull' => 0,
'visible' => 0,
'validate' => 1,),
110 'note_private' => array(
'type' =>
'html',
'label' =>
'NotePrivate',
'enabled' => 1,
'position' => 301,
'notnull' => 0,
'visible' => 0,
'validate' => 1,),
111 'date_creation' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'position' => 500,
'notnull' => 1,
'visible' => -2,),
112 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'position' => 501,
'notnull' => 0,
'visible' => -2,),
113 'fk_user_creat' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserAuthor',
'enabled' => 1,
'position' => 510,
'notnull' => 1,
'visible' => -2,
'foreignkey' =>
'user.rowid',),
114 'fk_user_modif' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserModif',
'enabled' => 1,
'position' => 511,
'notnull' => -1,
'visible' => -2,),
115 'last_main_doc' => array(
'type' =>
'varchar(255)',
'label' =>
'LastMainDoc',
'enabled' => 1,
'position' => 600,
'notnull' => 0,
'visible' => 0,),
116 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'position' => 1000,
'notnull' => -1,
'visible' => -2,),
117 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'position' => 1010,
'notnull' => -1,
'visible' => 0,),
118 'status' => array(
'type' =>
'smallint',
'label' =>
'Status',
'enabled' => 1,
'position' => 1000,
'notnull' => 1,
'default' =>
'0',
'visible' => 2,
'index' => 1,
'arrayofkeyval' => array(
'0' =>
'Draft',
'1' =>
'Validated',
'9' =>
'Canceled'),
'validate' => 1,),
136 public $fk_asset_model;
140 public $reversal_amount_ht;
144 public $acquisition_value_ht;
148 public $recovered_vat;
152 public $reversal_date;
156 public $date_acquisition;
168 public $acquisition_type;
176 public $not_depreciated;
180 public $disposal_date;
184 public $disposal_amount_ht;
188 public $fk_disposal_type;
192 public $disposal_depreciated;
196 public $disposal_subject_to_vat;
200 public $supplier_invoice_id;
208 public $note_private;
212 public $fk_user_creat;
216 public $fk_user_modif;
220 public $last_main_doc;
243 public $asset_depreciation_options;
247 public $asset_accountancy_codes;
251 public $depreciation_lines = array();
264 $this->ismultientitymanaged = 1;
265 $this->isextrafieldmanaged = 1;
268 $this->fields[
'rowid'][
'visible'] = 0;
270 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
271 $this->fields[
'entity'][
'enabled'] = 0;
275 foreach ($this->fields as $key => $val) {
276 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
277 unset($this->fields[$key]);
282 if (is_object($langs)) {
283 foreach ($this->fields as $key => $val) {
284 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
285 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
286 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
302 if (!isset($this->date_start) || $this->date_start ===
"") {
303 $this->date_start = $this->date_acquisition;
308 $result = $result_create = $this->
createCommon($user, $notrigger);
309 if ($result > 0 && $this->fk_asset_model > 0) {
313 if ($this->supplier_invoice_id > 0) {
319 $this->db->rollback();
324 return $result > 0 ? $result_create : $result;
336 global $langs, $extrafields;
429 public function fetch($id, $ref =
null)
436 } elseif ($res > 0) {
437 $this->fields[
'date_acquisition'][
'noteditable'] =
'1';
438 $this->fields[
'date_start'][
'noteditable'] =
'1';
439 $this->fields[
'acquisition_value_ht'][
'noteditable'] =
'1';
440 $this->fields[
'recovered_vat'][
'noteditable'] =
'1';
441 $this->fields[
'reversal_date'][
'noteditable'] =
'1';
442 $this->fields[
'reversal_amount_ht'][
'noteditable'] =
'1';
462 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
470 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element.
" as t";
471 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
472 $sql .=
" WHERE t.entity IN (".getEntity($this->element).
")";
474 $sql .=
" WHERE 1 = 1";
481 $this->errors[] = $errormessage;
482 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
487 if (!empty($sortfield)) {
488 $sql .= $this->db->order($sortfield, $sortorder);
490 if (!empty($limit)) {
491 $sql .= $this->db->plimit($limit, $offset);
494 $resql = $this->db->query($sql);
496 $num = $this->db->num_rows($resql);
498 while ($i < ($limit ? min($limit, $num) : $num)) {
499 $obj = $this->db->fetch_object($resql);
501 $record =
new self($this->db);
502 $record->setVarsFromFetchObj($obj);
504 $records[$record->id] = $record;
508 $this->db->free($resql);
512 $this->errors[] =
'Error '.$this->db->lasterror();
513 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
528 if (!isset($this->date_start) || $this->date_start ===
"") {
529 $this->date_start = $this->date_acquisition;
535 if ($result > 0 && $this->fk_asset_model > 0 && $this->fk_asset_model != $this->oldcopy->fk_asset_model) {
539 $this->date_start != $this->oldcopy->date_start ||
540 $this->acquisition_value_ht != $this->oldcopy->acquisition_value_ht ||
541 $this->reversal_date != $this->oldcopy->reversal_date ||
542 $this->reversal_amount_ht != $this->oldcopy->reversal_amount_ht ||
543 ($this->fk_asset_model > 0 && $this->fk_asset_model != $this->oldcopy->fk_asset_model)
550 $this->db->rollback();
565 public function delete(
User $user, $notrigger = 0)
581 $langs->load(
'assets');
584 $this->
id = $this->
id > 0 ? $this->id : 0;
585 $this->fk_asset_model = $this->fk_asset_model > 0 ? $this->fk_asset_model : 0;
589 if (empty($this->
id)) {
590 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Asset") .
' (' . $langs->transnoentitiesnoconv(
"TechnicalID") .
')');
593 if (empty($this->fk_asset_model)) {
594 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"AssetModel") .
' (' . $langs->transnoentitiesnoconv(
"TechnicalID") .
')');
605 require_once DOL_DOCUMENT_ROOT .
'/asset/class/assetdepreciationoptions.class.php';
607 $result = $options_model->fetchDeprecationOptions(0, $this->fk_asset_model);
609 $this->error = $options_model->error;
610 $this->errors = $options_model->errors;
612 } elseif ($result > 0) {
614 $result = $options->fetchDeprecationOptions($this->
id);
616 $this->error = $options->error;
617 $this->errors = $options->errors;
622 foreach ($options_model->deprecation_options as $mode_key => $fields) {
623 foreach ($fields as $field_key => $value) {
624 $options->deprecation_options[$mode_key][$field_key] = $value;
628 $result = $options->updateDeprecationOptions($user, $this->
id, 0, $notrigger);
630 $this->error = $options->error;
631 $this->errors = $options->errors;
640 require_once DOL_DOCUMENT_ROOT .
'/asset/class/assetaccountancycodes.class.php';
642 $result = $accountancy_codes_model->fetchAccountancyCodes(0, $this->fk_asset_model);
644 $this->error = $accountancy_codes_model->error;
645 $this->errors = $accountancy_codes_model->errors;
647 } elseif ($result > 0) {
649 $result = $accountancy_codes->fetchAccountancyCodes($this->
id);
651 $this->error = $accountancy_codes->error;
652 $this->errors = $accountancy_codes->errors;
657 foreach ($accountancy_codes_model->accountancy_codes as $mode_key => $fields) {
658 foreach ($fields as $field_key => $value) {
659 $accountancy_codes->accountancy_codes[$mode_key][$field_key] = $value;
663 $result = $accountancy_codes->updateAccountancyCodes($user, $this->
id, 0, $notrigger);
665 $this->error = $accountancy_codes->error;
666 $this->errors = $accountancy_codes->errors;
674 $this->db->rollback();
690 $langs->load(
'assets');
691 $this->depreciation_lines = array();
694 $this->
id = $this->
id > 0 ? $this->id : 0;
698 if (empty($this->
id)) {
699 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Asset") .
' (' . $langs->transnoentitiesnoconv(
"TechnicalID") .
')');
721 $sql =
"SELECT ad.rowid, ad.depreciation_mode, ad.ref, ad.depreciation_date, ad.depreciation_ht, ad.cumulative_depreciation_ht";
722 $sql .=
", " . $this->db->ifsql(
'iab.fk_docdet IS NOT NULL', 1, 0) .
" AS bookkeeping";
723 $sql .=
" FROM " . MAIN_DB_PREFIX .
"asset_depreciation AS ad";
724 $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";
725 $sql .=
" WHERE ad.fk_asset = " . (int) $this->
id;
726 $sql .=
" ORDER BY ad.depreciation_date ASC";
728 $resql = $this->db->query($sql);
730 $this->errors[] = $langs->trans(
'AssetErrorFetchDepreciationLines') .
': ' . $this->db->lasterror();
734 while ($obj = $this->db->fetch_object($resql)) {
735 if (!isset($this->depreciation_lines[$obj->depreciation_mode])) {
736 $this->depreciation_lines[$obj->depreciation_mode] = array();
738 $this->depreciation_lines[$obj->depreciation_mode][] = array(
741 'depreciation_date' => $this->db->jdate($obj->depreciation_date),
742 'depreciation_ht' => $obj->depreciation_ht,
743 'cumulative_depreciation_ht' => $obj->cumulative_depreciation_ht,
744 'bookkeeping' => $obj->bookkeeping,
759 $langs->load(
'assets');
762 $this->
id = $this->
id > 0 ? $this->id : 0;
766 if (empty($this->
id)) {
767 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Asset") .
' (' . $langs->transnoentitiesnoconv(
"TechnicalID") .
')');
788 $sql =
"SELECT COUNT(*) AS has_bookkeeping";
789 $sql .=
" FROM " . MAIN_DB_PREFIX .
"asset_depreciation AS ad";
790 $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";
791 $sql .=
" WHERE ad.fk_asset = " . (int) $this->
id;
792 $sql .=
" AND iab.fk_docdet IS NOT NULL";
794 $resql = $this->db->query($sql);
796 $this->errors[] = $langs->trans(
'AssetErrorFetchDepreciationLines') .
': ' . $this->db->lasterror();
800 if ($obj = $this->db->fetch_object($resql)) {
801 return $obj->has_bookkeeping > 0 ? 1 : 0;
819 public function addDepreciationLine($mode, $ref, $depreciation_date, $depreciation_ht, $cumulative_depreciation_ht, $accountancy_code_debit, $accountancy_code_credit)
822 $langs->load(
'assets');
825 $this->
id = $this->
id > 0 ? $this->id : 0;
826 $mode = strtolower(trim($mode));
828 $accountancy_code_debit = trim($accountancy_code_debit);
829 $accountancy_code_credit = trim($accountancy_code_credit);
833 if (empty($this->
id)) {
834 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Asset") .
' (' . $langs->transnoentitiesnoconv(
"TechnicalID") .
')');
841 $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)";
842 $sql .=
" VALUES ( ";
843 $sql .=
" " . (int) $this->
id;
844 $sql .=
", '" . $this->db->escape($mode) .
"'";
845 $sql .=
", '" . $this->db->escape($ref) .
"'";
846 $sql .=
", '" . $this->db->idate($depreciation_date) .
"'";
847 $sql .=
", " . (float) $depreciation_ht;
848 $sql .=
", " . (float) $cumulative_depreciation_ht;
849 $sql .=
", '" . $this->db->escape($accountancy_code_debit) .
"'";
850 $sql .=
", '" . $this->db->escape($accountancy_code_credit) .
"'";
853 $resql = $this->db->query($sql);
855 $this->errors[] = $langs->trans(
'AssetErrorAddDepreciationLine') .
': ' . $this->db->lasterror();
869 global $conf, $langs;
870 $langs->load(
'assets');
873 $this->
id = $this->
id > 0 ? $this->id : 0;
877 if (empty($this->
id)) {
878 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Asset") .
' (' . $langs->transnoentitiesnoconv(
"TechnicalID") .
')');
887 require_once DOL_DOCUMENT_ROOT .
'/asset/class/assetdepreciationoptions.class.php';
889 $result = $options->fetchDeprecationOptions($this->
id);
891 $this->error = $options->error;
892 $this->errors = $options->errors;
898 require_once DOL_DOCUMENT_ROOT .
'/asset/class/assetaccountancycodes.class.php';
900 $result = $accountancy_codes->fetchAccountancyCodes($this->
id);
902 $this->error = $accountancy_codes->error;
903 $this->errors = $accountancy_codes->errors;
911 foreach ($options->deprecation_options as $mode_key => $fields) {
912 $modes[$mode_key] = $this->db->escape($mode_key);
914 $sql =
"DELETE FROM " . MAIN_DB_PREFIX .
"asset_depreciation";
915 $sql .=
" WHERE fk_asset = " . (int) $this->
id;
916 $sql .=
" AND depreciation_mode NOT IN ('" . $this->db->sanitize(implode(
"', '", $modes)) .
"')";
918 $resql = $this->db->query($sql);
920 $this->errors[] = $langs->trans(
'AssetErrorClearDepreciationLines') .
': ' . $this->db->lasterror();
926 require_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
927 require_once DOL_DOCUMENT_ROOT .
'/core/lib/accounting.lib.php';
929 $dates =
getCurrentPeriodOfFiscalYear($this->db, $conf, $this->date_start > $this->date_acquisition ? $this->date_start : $this->date_acquisition);
930 $init_fiscal_period_start = $dates[
'date_start'];
931 $init_fiscal_period_end = $dates[
'date_end'];
932 if (empty($init_fiscal_period_start) || empty($init_fiscal_period_end)) {
933 $pastmonthyear = $dates[
'pastmonthyear'];
934 $pastmonth = $dates[
'pastmonth'];
935 $init_fiscal_period_start =
dol_get_first_day($pastmonthyear, $pastmonth,
false);
936 $init_fiscal_period_end =
dol_get_last_day($pastmonthyear, $pastmonth,
false);
939 foreach ($options->deprecation_options as $mode_key => $fields) {
960 $sql =
"SELECT ad.depreciation_date, ad.cumulative_depreciation_ht";
961 $sql .=
" FROM " . MAIN_DB_PREFIX .
"asset_depreciation AS ad";
962 $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";
963 $sql .=
" WHERE ad.fk_asset = " . (int) $this->
id;
964 $sql .=
" AND ad.depreciation_mode = '" . $this->db->escape($mode_key) .
"'";
965 $sql .=
" AND iab.fk_docdet IS NOT NULL";
966 $sql .=
" ORDER BY ad.depreciation_date DESC";
969 $resql = $this->db->query($sql);
971 $this->errors[] = $langs->trans(
'AssetErrorFetchMaxDepreciationDateForMode', $mode_key) .
': ' . $this->db->lasterror();
975 $last_depreciation_date =
'';
976 $last_cumulative_depreciation_ht = $this->reversal_amount_ht;
977 if ($obj = $this->db->fetch_object($resql)) {
978 $last_depreciation_date = $this->db->jdate($obj->depreciation_date);
979 $last_cumulative_depreciation_ht = $obj->cumulative_depreciation_ht;
983 $sql =
"UPDATE " . MAIN_DB_PREFIX . $options->deprecation_options_fields[$mode_key][
'table'];
984 $sql .=
" SET total_amount_last_depreciation_ht = " . (empty($last_cumulative_depreciation_ht) ? 0 : $last_cumulative_depreciation_ht);
985 $sql .=
" WHERE fk_asset = " . (int) $this->
id;
986 $resql = $this->db->query($sql);
988 $this->errors[] = $langs->trans(
'AssetErrorSetLastCumulativeDepreciation') .
': ' . $this->db->lasterror();
994 $sql =
"DELETE " . MAIN_DB_PREFIX .
"asset_depreciation FROM " . MAIN_DB_PREFIX .
"asset_depreciation";
995 $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";
996 $sql .=
" WHERE " . MAIN_DB_PREFIX .
"asset_depreciation.fk_asset = " . (int) $this->
id;
997 $sql .=
" AND " . MAIN_DB_PREFIX .
"asset_depreciation.depreciation_mode = '" . $this->db->escape($mode_key) .
"'";
998 $sql .=
" AND ab.fk_docdet IS NULL";
999 if ($last_depreciation_date !==
"") {
1000 $sql .=
" AND " . MAIN_DB_PREFIX .
"asset_depreciation.ref != ''";
1002 $resql = $this->db->query($sql);
1004 $this->errors[] = $langs->trans(
'AssetErrorClearDepreciationLines') .
': ' . $this->db->lasterror();
1010 $depreciation_date_start = $this->date_start > $this->date_acquisition ? $this->date_start : $this->date_acquisition;
1011 $depreciation_date_end =
dol_time_plus_duree(
dol_time_plus_duree((
int) $depreciation_date_start, $fields[
'duration'], $fields[
'duration_type'] == 1 ?
'm' : ($fields[
'duration_type'] == 2 ?
'd' :
'y')), -1,
'd');
1012 $depreciation_amount = $fields[
'amount_base_depreciation_ht'];
1013 if ($fields[
'duration_type'] == 2) {
1014 $fiscal_period_start = $depreciation_date_start;
1015 $fiscal_period_end = $depreciation_date_start;
1016 } elseif ($fields[
'duration_type'] == 1) {
1017 $date_temp =
dol_getdate((
int) $depreciation_date_start);
1018 $fiscal_period_start =
dol_get_first_day($date_temp[
'year'], $date_temp[
'mon'],
false);
1019 $fiscal_period_end =
dol_get_last_day($date_temp[
'year'], $date_temp[
'mon'],
false);
1021 $fiscal_period_start = $init_fiscal_period_start;
1022 $fiscal_period_end = $init_fiscal_period_end;
1024 $cumulative_depreciation_ht = (float) $last_cumulative_depreciation_ht;
1025 $depreciation_period_amount = $depreciation_amount - (float) $this->reversal_amount_ht;
1026 $start_date = $depreciation_date_start;
1027 $disposal_date = isset($this->disposal_date) && $this->disposal_date !==
"" ? $this->disposal_date :
"";
1028 $finish_date = $disposal_date !==
"" ? $disposal_date : $depreciation_date_end;
1029 $accountancy_code_depreciation_debit_key = $accountancy_codes->accountancy_codes_fields[$mode_key][
'depreciation_debit'];
1030 $accountancy_code_depreciation_debit = $accountancy_codes->accountancy_codes[$mode_key][$accountancy_code_depreciation_debit_key];
1031 $accountancy_code_depreciation_credit_key = $accountancy_codes->accountancy_codes_fields[$mode_key][
'depreciation_credit'];
1032 $accountancy_code_credit = $accountancy_codes->accountancy_codes[$mode_key][$accountancy_code_depreciation_credit_key];
1036 if ($last_depreciation_date ===
"" && ($depreciation_date_start < $fiscal_period_start || is_numeric($this->reversal_date))) {
1037 if (is_numeric($this->reversal_date)) {
1038 if ($this->reversal_date < $fiscal_period_start) {
1039 $this->errors[] = $langs->trans(
'AssetErrorReversalDateNotGreaterThanCurrentBeginFiscalDateForMode', $mode_key);
1044 if (empty($this->reversal_amount_ht)) {
1045 $this->errors[] = $langs->trans(
'AssetErrorReversalAmountNotProvidedForMode', $mode_key);
1050 $start_date = $this->reversal_date;
1051 $result = $this->
addDepreciationLine($mode_key,
'', $start_date, $this->reversal_amount_ht, $this->reversal_amount_ht, $accountancy_code_depreciation_debit, $accountancy_code_credit);
1057 $this->errors[] = $langs->trans(
'AssetErrorReversalDateNotProvidedForMode', $mode_key);
1065 $nb_days_in_year =
getDolGlobalInt(
'ASSET_DEPRECIATION_DURATION_PER_YEAR', 360);
1066 $nb_days_in_month =
getDolGlobalInt(
'ASSET_DEPRECIATION_DURATION_PER_MONTH', 30);
1067 $period_amount = (float)
price2num($depreciation_period_amount / $fields[
'duration'],
'MT');
1068 $first_period_found =
false;
1070 $first_period_date = isset($begin_period) && $begin_period > $fiscal_period_start ? $begin_period : $fiscal_period_start;
1072 $ref_date_format =
"%Y" . ($fields[
'duration_type'] == 1 || $fields[
'duration_type'] == 2 ?
'-%m' :
'') . ($fields[
'duration_type'] == 2 ?
'-%d' :
'');
1076 $max_loop = $fields[
'duration'] + 2;
1080 if ($idx_loop > $max_loop) {
1084 if ($last_depreciation_date < $fiscal_period_end && ($first_period_date <= $start_date || $first_period_found)) {
1086 if ($fiscal_period_start <= $disposal_date && $disposal_date <= $fiscal_period_end && empty($this->disposal_depreciated)) {
1090 $first_period_found =
true;
1092 $period_begin =
dol_print_date($fiscal_period_start, $ref_date_format);
1093 $period_end =
dol_print_date($fiscal_period_end, $ref_date_format);
1094 $ref = $period_begin . ($period_begin != $period_end ?
' - ' . $period_end :
'');
1095 if ($fiscal_period_start <= $disposal_date && $disposal_date <= $fiscal_period_end) {
1096 $ref .=
' - ' . $langs->transnoentitiesnoconv(
'AssetDisposal');
1099 $begin_date = $fiscal_period_start < $start_date && $start_date <= $fiscal_period_end ? $start_date : $fiscal_period_start;
1100 $end_date = $fiscal_period_start < $finish_date && $finish_date <= $fiscal_period_end ? $finish_date : $fiscal_period_end;
1101 if ($fields[
'duration_type'] == 2) {
1102 $depreciation_ht = $period_amount;
1103 } elseif ($fields[
'duration_type'] == 1) {
1104 $nb_days = min($nb_days_in_month,
num_between_day($begin_date, $end_date, 1));
1105 if ($nb_days >= 28) {
1107 if ($date_temp[
'mon'] == 2) {
1111 $depreciation_ht = (float)
price2num($period_amount * $nb_days / $nb_days_in_month,
'MT');
1114 if (($nb_days_real > 366) || (
num_between_day($fiscal_period_start, $fiscal_period_end, 1) < $nb_days_in_year)) {
1115 $nb_days = $nb_days_real;
1117 $nb_days = min($nb_days_in_year, $nb_days_real);
1119 $depreciation_ht = (double)
price2num($period_amount * $nb_days / $nb_days_in_year,
'MT');
1122 if ($idx_loop < $max_loop) {
1123 $depreciation_ht = ceil($depreciation_ht);
1127 if ($fiscal_period_start <= $depreciation_date_end && $depreciation_date_end <= $fiscal_period_end) {
1128 $depreciation_ht = (float)
price2num($depreciation_amount - (
float) $cumulative_depreciation_ht,
'MT');
1129 $cumulative_depreciation_ht = $depreciation_amount;
1131 $cumulative_depreciation_ht += $depreciation_ht;
1134 $result = $this->
addDepreciationLine($mode_key, $ref, $fiscal_period_end, $depreciation_ht, $cumulative_depreciation_ht, $accountancy_code_depreciation_debit, $accountancy_code_credit);
1144 if ($fields[
'duration_type'] == 2) {
1145 $fiscal_period_end = $fiscal_period_start;
1146 } elseif ($fields[
'duration_type'] == 1) {
1149 $fiscal_period_end = $dates_fiscal_period[
'date_end'];
1151 $last_period_date = $disposal_date !==
"" && $disposal_date < $depreciation_date_end ? $disposal_date : $depreciation_date_end;
1152 }
while ($fiscal_period_start < $last_period_date);
1161 $this->db->rollback();
1164 $this->db->commit();
1178 $langs->load(
'assets');
1181 $asset_depreciation_id = $asset_depreciation_id > 0 ? $asset_depreciation_id : 0;
1185 if (empty($asset_depreciation_id)) {
1186 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"AssetDepreciation") .
' (' . $langs->transnoentitiesnoconv(
"TechnicalID") .
')');
1195 require_once DOL_DOCUMENT_ROOT .
'/asset/class/assetdepreciationoptions.class.php';
1200 $sql =
"SELECT fk_asset, depreciation_mode, cumulative_depreciation_ht";
1201 $sql .=
" FROM " . MAIN_DB_PREFIX .
"asset_depreciation";
1202 $sql .=
" WHERE rowid = " . (int) $asset_depreciation_id;
1203 $resql = $this->db->query($sql);
1205 $this->errors[] = $langs->trans(
'AssetErrorFetchCumulativeDepreciation') .
': ' . $this->db->lasterror();
1208 if ($obj = $this->db->fetch_object($resql)) {
1209 $mode_key = $obj->depreciation_mode;
1210 if (!empty($options->deprecation_options_fields[$mode_key])) {
1211 $sql =
"UPDATE " . MAIN_DB_PREFIX . $options->deprecation_options_fields[$mode_key][
'table'];
1212 $sql .=
" SET total_amount_last_depreciation_ht = " . $obj->cumulative_depreciation_ht;
1213 $sql .=
" WHERE fk_asset = " . (int) $obj->fk_asset;
1214 $resql = $this->db->query($sql);
1216 $this->errors[] = $langs->trans(
'AssetErrorSetLastCumulativeDepreciation') .
': ' . $this->db->lasterror();
1224 $this->db->rollback();
1227 $this->db->commit();
1240 public function dispose($user, $disposal_invoice_id, $notrigger = 0)
1242 global $conf, $langs;
1245 if ($this->
status != self::STATUS_DRAFT || $this->
status == self::STATUS_DISPOSED) {
1251 $required_fields = array(
'disposal_date',
'disposal_date',
'fk_disposal_type');
1252 foreach ($required_fields as $field) {
1253 $this->fields[$field][
'notnull'] = 1;
1255 $result = $this->
update($user, 1);
1256 foreach ($required_fields as $field) {
1257 $this->fields[$field][
'notnull'] = 0;
1260 if ($disposal_invoice_id > 0) {
1263 $result = $this->
setStatusCommon($user, self::STATUS_DISPOSED, $notrigger,
'ASSET_DISPOSED');
1270 $this->db->rollback();
1272 $this->db->commit();
1277 if (method_exists($this,
'generateDocument')) {
1278 global $hidedetails, $hidedesc, $hideref;
1279 $outputlangs = $langs;
1282 $newlang =
GETPOST(
'lang_id',
'aZ09');
1285 $newlang = $this->thirdparty->default_lang;
1287 if (!empty($newlang)) {
1288 $outputlangs =
new Translate(
"", $conf);
1289 $outputlangs->setDefaultLang($newlang);
1291 $model = $this->model_pdf;
1292 $ret = $this->
fetch($this->
id);
1294 $this->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1308 public function reopen($user, $notrigger = 0)
1310 global $conf, $langs;
1313 if ($this->
status != self::STATUS_DISPOSED || $this->
status == self::STATUS_DRAFT) {
1320 $this->disposal_date =
null;
1321 $this->disposal_amount_ht =
null;
1322 $this->fk_disposal_type =
null;
1323 $this->disposal_depreciated = 0;
1324 $this->disposal_subject_to_vat = 0;
1325 $result = $this->
update($user, 1);
1328 $result = $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'ASSET_REOPEN');
1335 $this->db->rollback();
1337 $this->db->commit();
1342 if (method_exists($this,
'generateDocument')) {
1343 global $hidedetails, $hidedesc, $hideref;
1344 $outputlangs = $langs;
1347 $newlang =
GETPOST(
'lang_id',
'aZ09');
1350 $newlang = $this->thirdparty->default_lang;
1352 if (!empty($newlang)) {
1353 $outputlangs =
new Translate(
"", $conf);
1354 $outputlangs->setDefaultLang($newlang);
1356 $model = $this->model_pdf;
1357 $ret = $this->
fetch($this->
id);
1359 $this->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1377 public function getNomUrl($withpicto = 0, $option =
'', $maxlen = 0, $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
1379 global $db, $conf, $langs, $hookmanager;
1380 global $dolibarr_main_authentication, $dolibarr_main_demo;
1381 global $menumanager;
1383 if (!empty($conf->dol_no_mouse_hover)) {
1389 $label =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Asset").
'</u>';
1390 if (isset($this->
status)) {
1391 $label .=
' '.$this->getLibStatut(5);
1394 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1396 $url =
dol_buildpath(
'/asset/card.php', 1).
'?id='.$this->id;
1398 if ($option !=
'nolink') {
1400 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1401 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1402 $add_save_lastsearch_values = 1;
1404 if ($add_save_lastsearch_values) {
1405 $url .=
'&save_lastsearch_values=1';
1410 if (empty($notooltip)) {
1412 $label = $langs->trans(
"ShowAsset");
1413 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1415 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
1416 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
1418 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1421 if ($option ==
'nolink') {
1422 $linkstart =
'<span';
1424 $linkstart =
'<a href="'.$url.
'"';
1426 $linkstart .= $linkclose.
'>';
1427 if ($option ==
'nolink') {
1428 $linkend =
'</span>';
1433 $result .= $linkstart;
1435 if (empty($this->showphoto_on_popup)) {
1437 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
1441 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1443 list($class, $module) = explode(
'@', $this->picto);
1446 $filename = $filearray[0][
'name'];
1447 if (!empty($filename)) {
1448 $pospoint = strpos($filearray[0][
'name'],
'.');
1450 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
1451 if (!
getDolGlobalString(strtoupper($module.
'_'.$class).
'_FORMATLISTPHOTOSASUSERS')) {
1452 $result .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$module.
'" alt="No photo" border="0" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$module.
'&entity='.$conf->entity.
'&file='.urlencode($pathtophoto).
'"></div></div>';
1454 $result .=
'<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$module.
'&entity='.$conf->entity.
'&file='.urlencode($pathtophoto).
'"></div>';
1457 $result .=
'</div>';
1459 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
1464 if ($withpicto != 2) {
1466 if ($option ==
'label') {
1467 $name = $this->label;
1468 } elseif ($option ==
'with_label') {
1469 $name .=
' - ' . $this->label;
1474 $result .= $linkend;
1478 $hookmanager->initHooks(array($this->element .
'dao'));
1479 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1480 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1482 $result = $hookmanager->resPrint;
1484 $result .= $hookmanager->resPrint;
1522 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1525 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'AssetInProgress');
1526 $this->labelStatus[self::STATUS_DISPOSED] = $langs->transnoentitiesnoconv(
'AssetDisposed');
1527 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'AssetInProgress');
1528 $this->labelStatusShort[self::STATUS_DISPOSED] = $langs->transnoentitiesnoconv(
'AssetDisposed');
1531 $statusType =
'status4';
1532 if ($status == self::STATUS_DISPOSED) {
1533 $statusType =
'status6';
1536 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
1547 $sql =
"SELECT rowid, date_creation as datec, tms as datem,";
1548 $sql .=
" fk_user_creat, fk_user_modif";
1549 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element.
" as t";
1550 $sql .=
" WHERE t.rowid = ".((int) $id);
1552 $result = $this->db->query($sql);
1554 if ($this->db->num_rows($result)) {
1555 $obj = $this->db->fetch_object($result);
1556 $this->
id = $obj->rowid;
1558 $this->user_creation_id = $obj->fk_user_creat;
1559 $this->user_modification_id = $obj->fk_user_modif;
1560 $this->date_creation = $this->db->jdate($obj->datec);
1561 $this->date_modification = $this->db->jdate($obj->datem);
1564 $this->db->free($result);
1592 global $langs, $conf;
1593 $langs->load(
"assets");
1596 $conf->global->ASSET_ASSET_ADDON =
'mod_asset_standard';
1606 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
1607 foreach ($dirmodels as $reldir) {
1611 $mybool = ((bool) @include_once $dir.$file) || $mybool;
1619 if (class_exists($classname)) {
1620 $obj =
new $classname();
1622 '@phan-var-force ModeleNumRefAsset $obj';
1624 $numref = $obj->getNextValue($this);
1626 if ($numref !=
'' && $numref !=
'-1') {
1629 $this->error = $obj->error;
1634 print $langs->trans(
"Error").
" ".$langs->trans(
"ClassNotFound").
' '.$classname;
1638 print $langs->trans(
"ErrorNumberingModuleNotSetup", $this->element);
getCurrentPeriodOfFiscalYear($db, $conf, $from_time=null, $gm='tzserver', $withenddateonly=1)
Get current period of fiscal year?
Class for AssetAccountancyCodes.
Class for AssetDepreciationOptions.
getNomUrl($withpicto=0, $option='', $maxlen=0, $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
hasDepreciationLinesInBookkeeping()
If has depreciation lines in bookkeeping.
dispose($user, $disposal_invoice_id, $notrigger=0)
Set dispose status.
createFromClone(User $user, $fromid)
Clone an object into another one.
calculationDepreciation()
Calculation depreciation lines (reversal and future) for each mode.
__construct(DoliDB $db)
Constructor.
create(User $user, $notrigger=0)
Create object into database.
info($id)
Load the info information in the object.
getLabelStatus($mode=0)
Return the label of the status.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, $filter='', $filtermode='AND')
Load list of objects in memory from the database.
fetch($id, $ref=null)
Load object in memory from the database.
LibStatut($status, $mode=0)
Return the status.
reopen($user, $notrigger=0)
Set back to validated status.
getLibStatut($mode=0)
Return the label of the status.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
addDepreciationLine($mode, $ref, $depreciation_date, $depreciation_ht, $cumulative_depreciation_ht, $accountancy_code_debit, $accountancy_code_credit)
Add depreciation line for a mode.
fetchDepreciationLines()
Fetch depreciation lines for each mode in $this->depreciation_lines (sort by depreciation date)
setLastCumulativeDepreciation($asset_depreciation_id)
Set last cumulative depreciation for each mode.
update(User $user, $notrigger=0)
Update object into database.
setDataFromAssetModel(User $user, $notrigger=0)
Set asset model.
getNextNumRef()
Returns the reference to the following non used object depending on the active numbering module.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
add_object_linked($origin=null, $origin_id=null, $f_user=null, $notrigger=0)
Add an object link into llx_element_element.
deleteObjectLinked($sourceid=null, $sourcetype='', $targetid=null, $targettype='', $rowid=0, $f_user=null, $notrigger=0)
Delete all links between an object $this.
createCommon(User $user, $notrigger=0)
Create object in the database.
getFieldList($alias='', $excludefields=array())
Function to concat keys of fields.
updateCommon(User $user, $notrigger=0)
Update object into database.
setStatusCommon($user, $status, $notrigger=0, $triggercode='')
Set to a status.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
fetchCommon($id, $ref=null, $morewhere='', $noextrafields=0)
Load object in memory from the database.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in database.
Class to manage Dolibarr database access.
Class to manage translations.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
num_between_day($timestampStart, $timestampEnd, $lastday=0)
Function to return number of days between two dates (date must be UTC date !) Example: 2012-01-01 201...
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...