25require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
35 public $module =
'asset';
40 public $element =
'asset';
45 public $table_element =
'asset';
51 public $ismultientitymanaged = 1;
56 public $isextrafieldmanaged = 1;
61 public $picto =
'asset';
63 const STATUS_DRAFT = 0;
64 const STATUS_DISPOSED = 9;
98 'rowid' => array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>
'1',
'position'=>1,
'notnull'=>1,
'visible'=>0,
'noteditable'=>
'1',
'index'=>1,
'css'=>
'left',
'comment'=>
"Id"),
99 'ref' => array(
'type'=>
'varchar(128)',
'label'=>
'Ref',
'enabled'=>
'1',
'position'=>20,
'notnull'=>1,
'visible'=>1,
'noteditable'=>
'0',
'index'=>1,
'searchall'=>1,
'showoncombobox'=>
'1',
'validate'=>
'1',
'comment'=>
"Reference of object"),
100 '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',),
101 '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',),
102 'qty' => array(
'type'=>
'real',
'label'=>
'Qty',
'enabled'=>
'1',
'position'=>50,
'notnull'=>1,
'visible'=>0,
'default'=>
'1',
'isameasure'=>
'1',
'css'=>
'maxwidth75imp',
'validate'=>
'1',),
103 'acquisition_type' => array(
'type'=>
'smallint',
'label'=>
'AssetAcquisitionType',
'enabled'=>
'1',
'position'=>60,
'notnull'=>1,
'visible'=>1,
'arrayofkeyval'=>array(
'0'=>
'AssetAcquisitionTypeNew',
'1'=>
'AssetAcquisitionTypeOccasion'),
'validate'=>
'1',),
104 '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',),
105 'not_depreciated' => array(
'type'=>
'boolean',
'label'=>
'AssetNotDepreciated',
'enabled'=>
'1',
'position'=>80,
'notnull'=>0,
'default'=>
'0',
'visible'=>1,
'validate'=>
'1',),
106 'date_acquisition' => array(
'type'=>
'date',
'label'=>
'AssetDateAcquisition',
'enabled'=>
'1',
'position'=>90,
'notnull'=>1,
'visible'=>1,),
107 'date_start' => array(
'type'=>
'date',
'label'=>
'AssetDateStart',
'enabled'=>
'1',
'position'=>100,
'notnull'=>0,
'visible'=>-1,),
108 'acquisition_value_ht' => array(
'type'=>
'price',
'label'=>
'AssetAcquisitionValueHT',
'enabled'=>
'1',
'position'=>110,
'notnull'=>1,
'visible'=>1,
'isameasure'=>
'1',
'validate'=>
'1',),
109 'recovered_vat' => array(
'type'=>
'price',
'label'=>
'AssetRecoveredVAT',
'enabled'=>
'1',
'position'=>120,
'notnull'=>0,
'visible'=>1,
'isameasure'=>
'1',
'validate'=>
'1',),
110 'reversal_date' => array(
'type'=>
'date',
'label'=>
'AssetReversalDate',
'enabled'=>
'1',
'position'=>130,
'notnull'=>0,
'visible'=>1,),
111 'reversal_amount_ht' => array(
'type'=>
'price',
'label'=>
'AssetReversalAmountHT',
'enabled'=>
'1',
'position'=>140,
'notnull'=>0,
'visible'=>1,
'isameasure'=>
'1',
'validate'=>
'1',),
112 'disposal_date' => array(
'type'=>
'date',
'label'=>
'AssetDisposalDate',
'enabled'=>
'1',
'position'=>200,
'notnull'=>0,
'visible'=>-2,),
113 'disposal_amount_ht' => array(
'type'=>
'price',
'label'=>
'AssetDisposalAmount',
'enabled'=>
'1',
'position'=>210,
'notnull'=>0,
'visible'=>-2,
'default'=>
'0',
'isameasure'=>
'1',
'validate'=>
'1',),
114 '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',),
115 'disposal_depreciated' => array(
'type'=>
'boolean',
'label'=>
'AssetDisposalDepreciated',
'enabled'=>
'1',
'position'=>230,
'notnull'=>0,
'default'=>
'0',
'visible'=>-2,
'validate'=>
'1',),
116 'disposal_subject_to_vat' => array(
'type'=>
'boolean',
'label'=>
'AssetDisposalSubjectToVat',
'enabled'=>
'1',
'position'=>240,
'notnull'=>0,
'default'=>
'0',
'visible'=>-2,
'validate'=>
'1',),
117 'note_public' => array(
'type'=>
'html',
'label'=>
'NotePublic',
'enabled'=>
'1',
'position'=>300,
'notnull'=>0,
'visible'=>0,
'validate'=>
'1',),
118 'note_private' => array(
'type'=>
'html',
'label'=>
'NotePrivate',
'enabled'=>
'1',
'position'=>301,
'notnull'=>0,
'visible'=>0,
'validate'=>
'1',),
119 'date_creation' => array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>
'1',
'position'=>500,
'notnull'=>1,
'visible'=>-2,),
120 'tms' => array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>
'1',
'position'=>501,
'notnull'=>0,
'visible'=>-2,),
121 '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',),
122 'fk_user_modif' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserModif',
'enabled'=>
'1',
'position'=>511,
'notnull'=>-1,
'visible'=>-2,),
123 'last_main_doc' => array(
'type'=>
'varchar(255)',
'label'=>
'LastMainDoc',
'enabled'=>
'1',
'position'=>600,
'notnull'=>0,
'visible'=>0,),
124 'import_key' => array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>
'1',
'position'=>1000,
'notnull'=>-1,
'visible'=>-2,),
125 'model_pdf' => array(
'type'=>
'varchar(255)',
'label'=>
'Model pdf',
'enabled'=>
'1',
'position'=>1010,
'notnull'=>-1,
'visible'=>0,),
126 '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',),
131 public $fk_asset_model;
132 public $reversal_amount_ht;
133 public $acquisition_value_ht;
134 public $recovered_vat;
135 public $reversal_date;
136 public $date_acquisition;
139 public $acquisition_type;
141 public $not_depreciated;
142 public $disposal_date;
143 public $disposal_amount_ht;
144 public $fk_disposal_type;
145 public $disposal_depreciated;
146 public $disposal_subject_to_vat;
147 public $supplier_invoice_id;
149 public $note_private;
150 public $date_creation;
152 public $fk_user_creat;
153 public $fk_user_modif;
154 public $last_main_doc;
158 public $user_cloture_id;
169 public $asset_depreciation_options;
173 public $depreciation_lines = array();
182 global $conf, $langs;
186 if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields[
'rowid'])) {
187 $this->fields[
'rowid'][
'visible'] = 0;
189 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
190 $this->fields[
'entity'][
'enabled'] = 0;
194 foreach ($this->fields as $key => $val) {
195 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
196 unset($this->fields[$key]);
201 if (is_object($langs)) {
202 foreach ($this->fields as $key => $val) {
203 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
204 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
205 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
221 if (!isset($this->date_start) || $this->date_start ===
"") $this->date_start = $this->date_acquisition;
225 $result = $result_create = $this->
createCommon($user, $notrigger);
226 if ($result > 0 && $this->fk_asset_model > 0) $result = $this->
setDataFromAssetModel($user, $notrigger);
228 if ($this->supplier_invoice_id > 0) $this->
add_object_linked(
'invoice_supplier', $this->supplier_invoice_id);
232 $this->db->rollback();
237 return $result > 0 ? $result_create : $result;
249 global $langs, $extrafields;
347 public function fetch($id, $ref =
null)
351 if (!empty($this->table_element_line)) $this->
fetchLines();
356 } elseif ($res > 0) {
357 $this->fields[
'date_acquisition'][
'noteditable'] =
'1';
358 $this->fields[
'date_start'][
'noteditable'] =
'1';
359 $this->fields[
'acquisition_value_ht'][
'noteditable'] =
'1';
360 $this->fields[
'recovered_vat'][
'noteditable'] =
'1';
361 $this->fields[
'reversal_date'][
'noteditable'] =
'1';
362 $this->fields[
'reversal_amount_ht'][
'noteditable'] =
'1';
375 $this->lines = array();
392 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, array $filter = array(), $filtermode =
'AND')
402 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element.
" as t";
403 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
404 $sql .=
" WHERE t.entity IN (".getEntity($this->element).
")";
406 $sql .=
" WHERE 1 = 1";
410 if (count($filter) > 0) {
411 foreach ($filter as $key => $value) {
412 if ($key ==
't.rowid') {
413 $sqlwhere[] = $key.
" = ".((int) $value);
414 } elseif (in_array($this->fields[$key][
'type'], array(
'date',
'datetime',
'timestamp'))) {
415 $sqlwhere[] = $key.
" = '".$this->db->idate($value).
"'";
416 } elseif ($key ==
'customsql') {
417 $sqlwhere[] = $value;
418 } elseif (strpos($value,
'%') ===
false) {
419 $sqlwhere[] = $key.
" IN (".$this->db->sanitize($this->db->escape($value)).
")";
421 $sqlwhere[] = $key.
" LIKE '%".$this->db->escape($value).
"%'";
425 if (count($sqlwhere) > 0) {
426 $sql .=
" AND (".implode(
" ".$filtermode.
" ", $sqlwhere).
")";
429 if (!empty($sortfield)) {
430 $sql .= $this->db->order($sortfield, $sortorder);
432 if (!empty($limit)) {
433 $sql .= $this->db->plimit($limit, $offset);
436 $resql = $this->db->query($sql);
438 $num = $this->db->num_rows($resql);
440 while ($i < ($limit ? min($limit, $num) : $num)) {
441 $obj = $this->db->fetch_object($resql);
443 $record =
new self($this->db);
444 $record->setVarsFromFetchObj($obj);
446 $records[$record->id] = $record;
450 $this->db->free($resql);
454 $this->errors[] =
'Error '.$this->db->lasterror();
455 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
470 if (!isset($this->date_start) || $this->date_start ===
"") $this->date_start = $this->date_acquisition;
475 if ($result > 0 && $this->fk_asset_model > 0 && $this->fk_asset_model != $this->oldcopy->fk_asset_model) {
479 $this->date_start != $this->oldcopy->date_start ||
480 $this->acquisition_value_ht != $this->oldcopy->acquisition_value_ht ||
481 $this->reversal_date != $this->oldcopy->reversal_date ||
482 $this->reversal_amount_ht != $this->oldcopy->reversal_amount_ht ||
483 ($this->fk_asset_model > 0 && $this->fk_asset_model != $this->oldcopy->fk_asset_model)
490 $this->db->rollback();
505 public function delete(
User $user, $notrigger =
false)
521 $langs->load(
'assets');
524 $this->
id = $this->
id > 0 ? $this->id : 0;
525 $this->fk_asset_model = $this->fk_asset_model > 0 ? $this->fk_asset_model : 0;
529 if (empty($this->
id)) {
530 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Asset") .
' (' . $langs->transnoentitiesnoconv(
"TechnicalID") .
')');
533 if (empty($this->fk_asset_model)) {
534 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"AssetModel") .
' (' . $langs->transnoentitiesnoconv(
"TechnicalID") .
')');
545 require_once DOL_DOCUMENT_ROOT .
'/asset/class/assetdepreciationoptions.class.php';
547 $result = $options_model->fetchDeprecationOptions(0, $this->fk_asset_model);
549 $this->error = $options_model->error;
550 $this->errors = $options_model->errors;
552 } elseif ($result > 0) {
554 $result = $options->fetchDeprecationOptions($this->
id);
556 $this->error = $options->error;
557 $this->errors = $options->errors;
562 foreach ($options_model->deprecation_options as $mode_key => $fields) {
563 foreach ($fields as $field_key => $value) {
564 $options->deprecation_options[$mode_key][$field_key] = $value;
568 $result = $options->updateDeprecationOptions($user, $this->
id, 0, $notrigger);
570 $this->error = $options->error;
571 $this->errors = $options->errors;
580 require_once DOL_DOCUMENT_ROOT .
'/asset/class/assetaccountancycodes.class.php';
582 $result = $accountancy_codes_model->fetchAccountancyCodes(0, $this->fk_asset_model);
584 $this->error = $accountancy_codes_model->error;
585 $this->errors = $accountancy_codes_model->errors;
587 } elseif ($result > 0) {
589 $result = $accountancy_codes->fetchAccountancyCodes($this->
id);
591 $this->error = $accountancy_codes->error;
592 $this->errors = $accountancy_codes->errors;
597 foreach ($accountancy_codes_model->accountancy_codes as $mode_key => $fields) {
598 foreach ($fields as $field_key => $value) {
599 $accountancy_codes->accountancy_codes[$mode_key][$field_key] = $value;
603 $result = $accountancy_codes->updateAccountancyCodes($user, $this->
id, 0, $notrigger);
605 $this->error = $accountancy_codes->error;
606 $this->errors = $accountancy_codes->errors;
614 $this->db->rollback();
630 $langs->load(
'assets');
631 $this->depreciation_lines = array();
634 $this->
id = $this->
id > 0 ? $this->id : 0;
638 if (empty($this->
id)) {
639 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Asset") .
' (' . $langs->transnoentitiesnoconv(
"TechnicalID") .
')');
661 $sql =
"SELECT ad.rowid, ad.depreciation_mode, ad.ref, ad.depreciation_date, ad.depreciation_ht, ad.cumulative_depreciation_ht";
662 $sql .=
", " . $this->db->ifsql(
'iab.fk_docdet IS NOT NULL', 1, 0) .
" AS bookkeeping";
663 $sql .=
" FROM " . MAIN_DB_PREFIX .
"asset_depreciation AS ad";
664 $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";
665 $sql .=
" WHERE ad.fk_asset = " . (int) $this->
id;
666 $sql .=
" ORDER BY ad.depreciation_date ASC";
668 $resql = $this->db->query($sql);
670 $this->errors[] = $langs->trans(
'AssetErrorFetchDepreciationLines') .
': ' . $this->db->lasterror();
674 while ($obj = $this->db->fetch_object($resql)) {
675 if (!isset($this->depreciation_lines[$obj->depreciation_mode])) $this->depreciation_lines[$obj->depreciation_mode] = array();
676 $this->depreciation_lines[$obj->depreciation_mode][] = array(
679 'depreciation_date' => $this->db->jdate($obj->depreciation_date),
680 'depreciation_ht' => $obj->depreciation_ht,
681 'cumulative_depreciation_ht' => $obj->cumulative_depreciation_ht,
682 'bookkeeping' => $obj->bookkeeping,
697 $langs->load(
'assets');
700 $this->
id = $this->
id > 0 ? $this->id : 0;
704 if (empty($this->
id)) {
705 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Asset") .
' (' . $langs->transnoentitiesnoconv(
"TechnicalID") .
')');
726 $sql =
"SELECT COUNT(*) AS has_bookkeeping";
727 $sql .=
" FROM " . MAIN_DB_PREFIX .
"asset_depreciation AS ad";
728 $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";
729 $sql .=
" WHERE ad.fk_asset = " . (int) $this->
id;
730 $sql .=
" AND iab.fk_docdet IS NOT NULL";
732 $resql = $this->db->query($sql);
734 $this->errors[] = $langs->trans(
'AssetErrorFetchDepreciationLines') .
': ' . $this->db->lasterror();
738 if ($obj = $this->db->fetch_object($resql)) {
739 return $obj->has_bookkeeping > 0 ? 1 : 0;
757 public function addDepreciationLine($mode, $ref, $depreciation_date, $depreciation_ht, $cumulative_depreciation_ht, $accountancy_code_debit, $accountancy_code_credit)
760 $langs->load(
'assets');
763 $this->
id = $this->
id > 0 ? $this->id : 0;
764 $mode = strtolower(trim($mode));
766 $accountancy_code_debit = trim($accountancy_code_debit);
767 $accountancy_code_credit = trim($accountancy_code_credit);
771 if (empty($this->
id)) {
772 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Asset") .
' (' . $langs->transnoentitiesnoconv(
"TechnicalID") .
')');
779 $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)";
780 $sql .=
" VALUES ( ";
781 $sql .=
" " . (int) $this->
id;
782 $sql .=
", '" . $this->db->escape($mode) .
"'";
783 $sql .=
", '" . $this->db->escape($ref) .
"'";
784 $sql .=
", '" . $this->db->idate($depreciation_date) .
"'";
785 $sql .=
", " . (double) $depreciation_ht;
786 $sql .=
", " . (double) $cumulative_depreciation_ht;
787 $sql .=
", '" . $this->db->escape($accountancy_code_debit) .
"'";
788 $sql .=
", '" . $this->db->escape($accountancy_code_credit) .
"'";
791 $resql = $this->db->query($sql);
793 $this->errors[] = $langs->trans(
'AssetErrorAddDepreciationLine') .
': ' . $this->db->lasterror();
807 global $conf, $langs;
808 $langs->load(
'assets');
811 $this->
id = $this->
id > 0 ? $this->id : 0;
815 if (empty($this->
id)) {
816 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Asset") .
' (' . $langs->transnoentitiesnoconv(
"TechnicalID") .
')');
825 require_once DOL_DOCUMENT_ROOT .
'/asset/class/assetdepreciationoptions.class.php';
827 $result = $options->fetchDeprecationOptions($this->
id);
829 $this->error = $options->error;
830 $this->errors = $options->errors;
836 require_once DOL_DOCUMENT_ROOT .
'/asset/class/assetaccountancycodes.class.php';
838 $result = $accountancy_codes->fetchAccountancyCodes($this->
id);
840 $this->error = $accountancy_codes->error;
841 $this->errors = $accountancy_codes->errors;
849 foreach ($options->deprecation_options as $mode_key => $fields) {
850 $modes[$mode_key] = $this->db->escape($mode_key);
852 $sql =
"DELETE FROM " . MAIN_DB_PREFIX .
"asset_depreciation";
853 $sql .=
" WHERE fk_asset = " . (int) $this->
id;
854 $sql .=
" AND depreciation_mode NOT IN ('" . $this->db->sanitize(implode(
"', '", $modes)) .
"')";
856 $resql = $this->db->query($sql);
858 $this->errors[] = $langs->trans(
'AssetErrorClearDepreciationLines') .
': ' . $this->db->lasterror();
864 require_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
865 require_once DOL_DOCUMENT_ROOT .
'/core/lib/accounting.lib.php';
866 $dates =
getCurrentPeriodOfFiscalYear($this->db, $conf, $this->date_start > $this->date_acquisition ? $this->date_start : $this->date_acquisition);
867 $init_fiscal_period_start = $dates[
'date_start'];
868 $init_fiscal_period_end = $dates[
'date_end'];
869 if (empty($init_fiscal_period_start) || empty($init_fiscal_period_end)) {
870 $pastmonthyear = $dates[
'pastmonthyear'];
871 $pastmonth = $dates[
'pastmonth'];
872 $init_fiscal_period_start =
dol_get_first_day($pastmonthyear, $pastmonth,
false);
873 $init_fiscal_period_end =
dol_get_last_day($pastmonthyear, $pastmonth,
false);
876 foreach ($options->deprecation_options as $mode_key => $fields) {
897 $sql =
"SELECT ad.depreciation_date, ad.cumulative_depreciation_ht";
898 $sql .=
" FROM " . MAIN_DB_PREFIX .
"asset_depreciation AS ad";
899 $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";
900 $sql .=
" WHERE ad.fk_asset = " . (int) $this->
id;
901 $sql .=
" AND ad.depreciation_mode = '" . $this->db->escape($mode_key) .
"'";
902 $sql .=
" AND iab.fk_docdet IS NOT NULL";
903 $sql .=
" ORDER BY ad.depreciation_date DESC";
906 $resql = $this->db->query($sql);
908 $this->errors[] = $langs->trans(
'AssetErrorFetchMaxDepreciationDateForMode', $mode_key) .
': ' . $this->db->lasterror();
912 $last_depreciation_date =
'';
913 $last_cumulative_depreciation_ht = $this->reversal_amount_ht;
914 if ($obj = $this->db->fetch_object($resql)) {
915 $last_depreciation_date = $this->db->jdate($obj->depreciation_date);
916 $last_cumulative_depreciation_ht = $obj->cumulative_depreciation_ht;
920 $sql =
"UPDATE " . MAIN_DB_PREFIX . $options->deprecation_options_fields[$mode_key][
'table'];
921 $sql .=
" SET total_amount_last_depreciation_ht = " . (empty($last_cumulative_depreciation_ht) ? 0 : $last_cumulative_depreciation_ht);
922 $sql .=
" WHERE fk_asset = " . (int) $this->
id;
923 $resql = $this->db->query($sql);
925 $this->errors[] = $langs->trans(
'AssetErrorSetLastCumulativeDepreciation') .
': ' . $this->db->lasterror();
931 $sql =
"DELETE FROM " . MAIN_DB_PREFIX .
"asset_depreciation";
932 $sql .=
" WHERE fk_asset = " . (int) $this->
id;
933 $sql .=
" AND depreciation_mode = '" . $this->db->escape($mode_key) .
"'";
934 $sql .=
" AND NOT EXISTS (SELECT fk_docdet FROM " . MAIN_DB_PREFIX .
"accounting_bookkeeping WHERE doc_type = 'asset' AND fk_docdet = " . MAIN_DB_PREFIX .
"asset_depreciation.rowid)";
935 if ($last_depreciation_date !==
"") {
936 $sql .=
" AND ref != ''";
938 $resql = $this->db->query($sql);
940 $this->errors[] = $langs->trans(
'AssetErrorClearDepreciationLines') .
': ' . $this->db->lasterror();
946 $depreciation_date_start = $this->date_start > $this->date_acquisition ? $this->date_start : $this->date_acquisition;
947 $depreciation_date_end =
dol_time_plus_duree($depreciation_date_start, $fields[
'duration'], $fields[
'duration_type'] == 1 ?
'm' : ($fields[
'duration_type'] == 2 ?
'd' :
'y'));
948 $depreciation_amount = $fields[
'amount_base_depreciation_ht'];
949 if ($fields[
'duration_type'] == 2) {
950 $fiscal_period_start = $depreciation_date_start;
951 $fiscal_period_end = $depreciation_date_start;
952 } elseif ($fields[
'duration_type'] == 1) {
953 $date_temp =
dol_getdate($depreciation_date_start);
954 $fiscal_period_start =
dol_get_first_day($date_temp[
'year'], $date_temp[
'mon'],
false);
955 $fiscal_period_end =
dol_get_last_day($date_temp[
'year'], $date_temp[
'mon'],
false);
957 $fiscal_period_start = $init_fiscal_period_start;
958 $fiscal_period_end = $init_fiscal_period_end;
960 $cumulative_depreciation_ht = $last_cumulative_depreciation_ht;
961 $depreciation_period_amount = $depreciation_amount - $this->reversal_amount_ht;
962 $start_date = $depreciation_date_start;
963 $disposal_date = isset($this->disposal_date) && $this->disposal_date !==
"" ? $this->disposal_date :
"";
964 $finish_date = $disposal_date !==
"" ? $disposal_date : $depreciation_date_end;
965 $accountancy_code_depreciation_debit_key = $accountancy_codes->accountancy_codes_fields[$mode_key][
'depreciation_debit'];
966 $accountancy_code_depreciation_debit = $accountancy_codes->accountancy_codes[$mode_key][$accountancy_code_depreciation_debit_key];
967 $accountancy_code_depreciation_credit_key = $accountancy_codes->accountancy_codes_fields[$mode_key][
'depreciation_credit'];
968 $accountancy_code_credit = $accountancy_codes->accountancy_codes[$mode_key][$accountancy_code_depreciation_credit_key];
972 if ($last_depreciation_date ===
"" && ($depreciation_date_start < $fiscal_period_start || is_numeric($this->reversal_date))) {
973 if (is_numeric($this->reversal_date)) {
974 if ($this->reversal_date < $fiscal_period_start) {
975 $this->errors[] = $langs->trans(
'AssetErrorReversalDateNotGreaterThanCurrentBeginFiscalDateForMode', $mode_key);
980 if (empty($this->reversal_amount_ht)) {
981 $this->errors[] = $langs->trans(
'AssetErrorReversalAmountNotProvidedForMode', $mode_key);
986 $start_date = $this->reversal_date;
987 $result = $this->
addDepreciationLine($mode_key,
'', $start_date, $this->reversal_amount_ht, $this->reversal_amount_ht, $accountancy_code_depreciation_debit, $accountancy_code_credit);
993 $this->errors[] = $langs->trans(
'AssetErrorReversalDateNotProvidedForMode', $mode_key);
1001 $nb_days_in_year = !empty($conf->global->ASSET_DEPRECIATION_DURATION_PER_YEAR) ? $conf->global->ASSET_DEPRECIATION_DURATION_PER_YEAR : 365;
1002 $nb_days_in_month = !empty($conf->global->ASSET_DEPRECIATION_DURATION_PER_MONTH) ? $conf->global->ASSET_DEPRECIATION_DURATION_PER_MONTH : 30;
1003 $period_amount = (float) ($fields[
'duration'] > 0 ?
price2num($depreciation_period_amount / $fields[
'duration'],
'MT') : 0);
1004 $first_period_found =
false;
1005 $first_period_date = isset($begin_period) && $begin_period > $fiscal_period_start ? $begin_period : $fiscal_period_start;
1007 $ref_date_format =
"%Y" . ($fields[
'duration_type'] == 1 || $fields[
'duration_type'] == 2 ?
'-%m' :
'') . ($fields[
'duration_type'] == 2 ?
'-%d' :
'');
1011 $max_loop = $fields[
'duration'] + 2;
1015 if ($idx_loop > $max_loop)
break;
1017 if ($last_depreciation_date < $fiscal_period_end && ($first_period_date <= $start_date || $first_period_found)) {
1019 if ($fiscal_period_start <= $disposal_date && $disposal_date <= $fiscal_period_end && empty($this->disposal_depreciated)) {
1023 $first_period_found =
true;
1025 $period_begin =
dol_print_date($fiscal_period_start, $ref_date_format);
1026 $period_end =
dol_print_date($fiscal_period_end, $ref_date_format);
1027 $ref = $period_begin . ($period_begin != $period_end ?
' - ' . $period_end :
'');
1028 if ($fiscal_period_start <= $disposal_date && $disposal_date <= $fiscal_period_end) {
1029 $ref .=
' - ' . $langs->transnoentitiesnoconv(
'AssetDisposal');
1032 $begin_date = $fiscal_period_start < $start_date && $start_date <= $fiscal_period_end ? $start_date : $fiscal_period_start;
1033 $end_date = $fiscal_period_start < $finish_date && $finish_date <= $fiscal_period_end ? $finish_date : $fiscal_period_end;
1034 if ($fields[
'duration_type'] == 2) {
1035 $depreciation_ht = $period_amount;
1036 } elseif ($fields[
'duration_type'] == 1) {
1037 $nb_days = min($nb_days_in_month,
num_between_day($begin_date, $end_date, 1));
1038 if ($nb_days >= 28) {
1040 if ($date_temp[
'mon'] == 2) {
1044 $depreciation_ht = (double)
price2num($period_amount * $nb_days / $nb_days_in_month,
'MT');
1046 $nb_days = min($nb_days_in_year,
num_between_day($begin_date, $end_date, 1));
1047 $depreciation_ht = (double)
price2num($period_amount * $nb_days / $nb_days_in_year,
'MT');
1050 if ($fiscal_period_start <= $depreciation_date_end && $depreciation_date_end <= $fiscal_period_end) {
1051 $depreciation_ht = (double)
price2num($depreciation_amount - $cumulative_depreciation_ht,
'MT');
1052 $cumulative_depreciation_ht = $depreciation_amount;
1054 $cumulative_depreciation_ht += $depreciation_ht;
1057 $result = $this->
addDepreciationLine($mode_key, $ref, $fiscal_period_end, $depreciation_ht, $cumulative_depreciation_ht, $accountancy_code_depreciation_debit, $accountancy_code_credit);
1066 if ($fields[
'duration_type'] == 2) {
1067 $fiscal_period_end = $fiscal_period_start;
1068 } elseif ($fields[
'duration_type'] == 1) {
1073 $last_period_date = $disposal_date !==
"" && $disposal_date < $depreciation_date_end ? $disposal_date : $depreciation_date_end;
1074 }
while ($fiscal_period_start < $last_period_date);
1083 $this->db->rollback();
1086 $this->db->commit();
1100 $langs->load(
'assets');
1103 $asset_depreciation_id = $asset_depreciation_id > 0 ? $asset_depreciation_id : 0;
1107 if (empty($asset_depreciation_id)) {
1108 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"AssetDepreciation") .
' (' . $langs->transnoentitiesnoconv(
"TechnicalID") .
')');
1117 require_once DOL_DOCUMENT_ROOT .
'/asset/class/assetdepreciationoptions.class.php';
1122 $sql =
"SELECT fk_asset, depreciation_mode, cumulative_depreciation_ht";
1123 $sql .=
" FROM " . MAIN_DB_PREFIX .
"asset_depreciation";
1124 $sql .=
" WHERE rowid = " . (int) $asset_depreciation_id;
1125 $resql = $this->db->query($sql);
1127 $this->errors[] = $langs->trans(
'AssetErrorFetchCumulativeDepreciation') .
': ' . $this->db->lasterror();
1130 if ($obj = $this->db->fetch_object($resql)) {
1131 $mode_key = $obj->depreciation_mode;
1132 if (!empty($options->deprecation_options_fields[$mode_key])) {
1133 $sql =
"UPDATE " . MAIN_DB_PREFIX . $options->deprecation_options_fields[$mode_key][
'table'];
1134 $sql .=
" SET total_amount_last_depreciation_ht = " . $obj->cumulative_depreciation_ht;
1135 $sql .=
" WHERE fk_asset = " . (int) $obj->fk_asset;
1136 $resql = $this->db->query($sql);
1138 $this->errors[] = $langs->trans(
'AssetErrorSetLastCumulativeDepreciation') .
': ' . $this->db->lasterror();
1146 $this->db->rollback();
1149 $this->db->commit();
1162 public function dispose($user, $disposal_invoice_id, $notrigger = 0)
1164 global $conf, $langs;
1167 if ($this->status != self::STATUS_DRAFT || $this->status == self::STATUS_DISPOSED) {
1173 $required_fields = array(
'disposal_date',
'disposal_date',
'fk_disposal_type');
1174 foreach ($required_fields as $field) {
1175 $this->fields[$field][
'notnull'] = 1;
1177 $result = $this->
update($user, 1);
1178 foreach ($required_fields as $field) {
1179 $this->fields[$field][
'notnull'] = 0;
1182 if ($disposal_invoice_id > 0) $this->
add_object_linked(
'facture', $disposal_invoice_id);
1183 $result = $this->
setStatusCommon($user, self::STATUS_DISPOSED, $notrigger,
'ASSET_DISPOSED');
1188 $this->db->rollback();
1190 $this->db->commit();
1194 if ($result > 0 && empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1195 if (method_exists($this,
'generateDocument')) {
1196 global $hidedetails, $hidedesc, $hideref;
1197 $outputlangs = $langs;
1200 $newlang =
GETPOST(
'lang_id',
'aZ09');
1203 $newlang = $this->thirdparty->default_lang;
1205 if (!empty($newlang)) {
1206 $outputlangs =
new Translate(
"", $conf);
1207 $outputlangs->setDefaultLang($newlang);
1209 $model = $this->model_pdf;
1210 $ret = $this->
fetch($this->
id);
1212 $this->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1226 public function reopen($user, $notrigger = 0)
1228 global $conf, $langs;
1231 if ($this->status != self::STATUS_DISPOSED || $this->status == self::STATUS_DRAFT) {
1238 $this->disposal_date =
null;
1239 $this->disposal_amount_ht =
null;
1240 $this->fk_disposal_type =
null;
1241 $this->disposal_depreciated =
null;
1242 $this->disposal_subject_to_vat =
null;
1243 $result = $this->
update($user, 1);
1246 $result = $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'ASSET_REOPEN');
1251 $this->db->rollback();
1253 $this->db->commit();
1257 if ($result > 0 && empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1258 if (method_exists($this,
'generateDocument')) {
1259 global $hidedetails, $hidedesc, $hideref;
1260 $outputlangs = $langs;
1263 $newlang =
GETPOST(
'lang_id',
'aZ09');
1266 $newlang = $this->thirdparty->default_lang;
1268 if (!empty($newlang)) {
1269 $outputlangs =
new Translate(
"", $conf);
1270 $outputlangs->setDefaultLang($newlang);
1272 $model = $this->model_pdf;
1273 $ret = $this->
fetch($this->
id);
1275 $this->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1293 public function getNomUrl($withpicto = 0, $option =
'', $maxlen = 0, $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
1295 global $db, $conf, $langs, $hookmanager;
1296 global $dolibarr_main_authentication, $dolibarr_main_demo;
1297 global $menumanager;
1299 if (!empty($conf->dol_no_mouse_hover)) {
1305 $label =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Asset").
'</u>';
1306 if (isset($this->status)) {
1307 $label .=
' '.$this->getLibStatut(5);
1310 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1312 $url =
dol_buildpath(
'/asset/card.php', 1).
'?id='.$this->id;
1314 if ($option !=
'nolink') {
1316 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1317 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1318 $add_save_lastsearch_values = 1;
1320 if ($add_save_lastsearch_values) {
1321 $url .=
'&save_lastsearch_values=1';
1326 if (empty($notooltip)) {
1327 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1328 $label = $langs->trans(
"ShowAsset");
1329 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1331 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
1332 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
1334 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1337 if ($option ==
'nolink') {
1338 $linkstart =
'<span';
1340 $linkstart =
'<a href="'.$url.
'"';
1342 $linkstart .= $linkclose.
'>';
1343 if ($option ==
'nolink') {
1344 $linkend =
'</span>';
1349 $result .= $linkstart;
1351 if (empty($this->showphoto_on_popup)) {
1353 $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);
1357 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1359 list($class, $module) = explode(
'@', $this->picto);
1362 $filename = $filearray[0][
'name'];
1363 if (!empty($filename)) {
1364 $pospoint = strpos($filearray[0][
'name'],
'.');
1366 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
1367 if (empty($conf->global->{strtoupper($module.
'_'.$class).
'_FORMATLISTPHOTOSASUSERS'})) {
1368 $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>';
1370 $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>';
1373 $result .=
'</div>';
1375 $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);
1380 if ($withpicto != 2) {
1382 if ($option ==
'label') $name = $this->label;
1383 elseif ($option ==
'with_label') $name .= ' - ' . $this->label;
1387 $result .= $linkend;
1391 $hookmanager->initHooks(array($this->element . 'dao'));
1392 $parameters = array('
id'=>$this->
id, 'getnomurl' => &$result);
1393 $reshook = $hookmanager->executeHooks('
getNomUrl', $parameters, $this, $action);
1395 $result = $hookmanager->resPrint;
1397 $result .= $hookmanager->resPrint;
1410 return $this->
LibStatut($this->status, $mode);
1421 return $this->
LibStatut($this->status, $mode);
1435 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1438 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'AssetInProgress');
1439 $this->labelStatus[self::STATUS_DISPOSED] = $langs->transnoentitiesnoconv(
'AssetDisposed');
1440 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'AssetInProgress');
1441 $this->labelStatusShort[self::STATUS_DISPOSED] = $langs->transnoentitiesnoconv(
'AssetDisposed');
1444 $statusType =
'status4';
1445 if ($status == self::STATUS_DISPOSED) {
1446 $statusType =
'status6';
1449 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
1460 $sql =
"SELECT rowid, date_creation as datec, tms as datem,";
1461 $sql .=
" fk_user_creat, fk_user_modif";
1462 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element.
" as t";
1463 $sql .=
" WHERE t.rowid = ".((int) $id);
1465 $result = $this->db->query($sql);
1467 if ($this->db->num_rows($result)) {
1468 $obj = $this->db->fetch_object($result);
1469 $this->
id = $obj->rowid;
1471 $this->user_creation_id = $obj->fk_user_author;
1472 $this->user_validation_id = $obj->fk_user_valid;
1473 $this->user_cloture_id = $obj->fk_user_cloture;
1474 $this->date_creation = $this->db->jdate($obj->datec);
1475 $this->date_modification = $this->db->jdate($obj->datem);
1476 $this->date_validation = $this->db->jdate($obj->datev);
1479 $this->db->free($result);
1507 $this->lines = array();
1509 return $this->lines;
1519 global $langs, $conf;
1520 $langs->load(
"asset@asset");
1522 if (empty($conf->global->ASSET_ASSET_ADDON)) {
1523 $conf->global->ASSET_ASSET_ADDON =
'mod_asset_standard';
1526 if (!empty($conf->global->ASSET_ASSET_ADDON)) {
1529 $file = $conf->global->ASSET_ASSET_ADDON.
".php";
1530 $classname = $conf->global->ASSET_ASSET_ADDON;
1533 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
1534 foreach ($dirmodels as $reldir) {
1538 $mybool |= @include_once $dir.$file;
1541 if ($mybool ===
false) {
1546 if (class_exists($classname)) {
1547 $obj =
new $classname();
1548 $numref = $obj->getNextValue($this);
1550 if ($numref !=
'' && $numref !=
'-1') {
1553 $this->error = $obj->error;
1558 print $langs->trans(
"Error").
" ".$langs->trans(
"ClassNotFound").
' '.$classname;
1562 print $langs->trans(
"ErrorNumberingModuleNotSetup", $this->element);
getCurrentPeriodOfFiscalYear($db, $conf, $from_time=null)
Get current period of fiscal year.
Class for AssetAccountancyCodes.
Class for AssetDepreciationOptions.
create(User $user, $notrigger=false)
Create object into database.
getNomUrl($withpicto=0, $option='', $maxlen=0, $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionaly the picto)
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter=array(), $filtermode='AND')
Load list of objects in memory from the database.
hasDepreciationLinesInBookkeeping()
If has depreciation lines in bookkeeping.
getLinesArray()
Create an array of lines.
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.
fetchLines()
Load object lines in memory from the database.
__construct(DoliDB $db)
Constructor.
info($id)
Load the info information in the object.
getLabelStatus($mode=0)
Return the label of the status.
update(User $user, $notrigger=false)
Update object into 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.
setDataFromAssetModel(User $user, $notrigger=false)
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.
fetchCommon($id, $ref=null, $morewhere='')
Load object in memory from the database.
createCommon(User $user, $notrigger=false)
Create object into database.
deleteObjectLinked($sourceid=null, $sourcetype='', $targetid=null, $targettype='', $rowid='', $f_user=null, $notrigger=0)
Delete all links between an object $this.
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
getFieldList($alias='', $excludefields=array())
Function to concat keys of fields.
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.
updateCommon(User $user, $notrigger=false)
Update object into database.
Class to manage Dolibarr database access.
Class to manage translations.
Class to manage Dolibarr users.
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($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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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_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.
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...
if(!defined( 'CSRFCHECK_WITH_TOKEN'))