27require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
39 public $module =
'mymodule';
44 public $element =
'myobject';
49 public $table_element =
'mymodule_myobject';
55 public $ismultientitymanaged = 0;
60 public $isextrafieldmanaged = 1;
65 public $picto =
'fa-file';
68 const STATUS_DRAFT = 0;
69 const STATUS_VALIDATED = 1;
70 const STATUS_CANCELED = 9;
115 public $fields = array(
116 'rowid' => array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>1,
'visible'=>-2,
'noteditable'=>1,
'notnull'=> 1,
'index'=>1,
'position'=>1,
'comment'=>
'Id',
'css'=>
'left'),
117 'entity' => array(
'type'=>
'integer',
'label'=>
'Entity',
'enabled'=>1,
'visible'=>0,
'notnull'=> 1,
'default'=>1,
'index'=>1,
'position'=>10),
118 'ref' => array(
'type'=>
'varchar(128)',
'label'=>
'Ref',
'enabled'=>1,
'visible'=>1,
'noteditable'=>0,
'default'=>
'',
'notnull'=> 1,
'showoncombobox'=>1,
'index'=>1,
'position'=>20,
'searchall'=>1,
'comment'=>
'Reference of object',
'validate'=>1),
119 'label' => array(
'type'=>
'varchar(255)',
'label'=>
'Label',
'enabled'=>1,
'visible'=>1,
'position'=>30,
'searchall'=>1,
'css'=>
'minwidth300',
'cssview'=>
'wordbreak',
'help'=>
'Help text',
'showoncombobox'=>2,
'validate'=>1,
'alwayseditable'=>1),
120 'amount' => array(
'type'=>
'price',
'label'=>
'Amount',
'enabled'=>1,
'visible'=>1,
'default'=>
'null',
'position'=>40,
'searchall'=>0,
'isameasure'=>1,
'help'=>
'Help text for amount',
'validate'=>1),
121 'qty' => array(
'type'=>
'real',
'label'=>
'Qty',
'enabled'=>1,
'visible'=>1,
'default'=>
'0',
'position'=>45,
'searchall'=>0,
'isameasure'=>1,
'help'=>
'Help text for quantity',
'css'=>
'maxwidth75imp',
'validate'=>1),
122 'fk_soc' => array(
'type'=>
'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))',
'picto'=>
'company',
'label'=>
'ThirdParty',
'visible'=> 1,
'enabled'=>
'isModEnabled("societe")',
'position'=>50,
'notnull'=>-1,
'index'=>1,
'help'=>
'OrganizationEventLinkToThirdParty',
'validate'=>1,
'css'=>
'maxwidth500 widthcentpercentminusxx',
'csslist'=>
'tdoverflowmax150'),
123 'fk_project' => array(
'type'=>
'integer:Project:projet/class/project.class.php:1',
'label'=>
'Project',
'picto'=>
'project',
'enabled'=>
'isModEnabled("project")',
'visible'=>-1,
'position'=>52,
'notnull'=>-1,
'index'=>1,
'validate'=>1,
'css'=>
'maxwidth500 widthcentpercentminusxx',
'csslist'=>
'tdoverflowmax150'),
124 'description' => array(
'type'=>
'text',
'label'=>
'Description',
'enabled'=>1,
'visible'=>3,
'position'=>60,
'validate'=>1),
125 'note_public' => array(
'type'=>
'html',
'label'=>
'NotePublic',
'enabled'=>1,
'visible'=>0,
'position'=>61,
'validate'=>1,
'cssview'=>
'wordbreak'),
126 'note_private' => array(
'type'=>
'html',
'label'=>
'NotePrivate',
'enabled'=>1,
'visible'=>0,
'position'=>62,
'validate'=>1,
'cssview'=>
'wordbreak'),
127 'date_creation' => array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>1,
'visible'=>-2,
'notnull'=> 1,
'position'=>500),
128 'tms' => array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>1,
'visible'=>-2,
'notnull'=> 0,
'position'=>501),
130 'fk_user_creat' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserAuthor',
'picto'=>
'user',
'enabled'=>1,
'visible'=>-2,
'notnull'=> 1,
'position'=>510,
'foreignkey'=>
'user.rowid',
'csslist'=>
'tdoverflowmax150'),
131 'fk_user_modif' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserModif',
'picto'=>
'user',
'enabled'=>1,
'visible'=>-2,
'notnull'=>-1,
'position'=>511,
'csslist'=>
'tdoverflowmax150'),
133 'last_main_doc' => array(
'type'=>
'varchar(255)',
'label'=>
'LastMainDoc',
'enabled'=>1,
'visible'=>0,
'notnull'=>0,
'position'=>600),
134 'import_key' => array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>1,
'visible'=>-2,
'notnull'=>-1,
'index'=>0,
'position'=>1000),
135 'model_pdf' => array(
'type'=>
'varchar(255)',
'label'=>
'Model pdf',
'enabled'=>1,
'visible'=>0,
'notnull'=>-1,
'position'=>1010),
136 'status' => array(
'type'=>
'integer',
'label'=>
'Status',
'enabled'=>1,
'visible'=>1,
'notnull'=> 1,
'default'=>0,
'index'=>1,
'position'=>2000,
'arrayofkeyval'=>array(0=>
'Draft', 1=>
'Validated', 9=>
'Canceled'),
'validate'=>1),
178 public $date_creation;
188 public $fk_user_creat;
193 public $fk_user_modif;
198 public $last_main_doc;
250 global $conf, $langs;
254 if (!
getDolGlobalInt(
'MAIN_SHOW_TECHNICAL_ID') && isset($this->fields[
'rowid']) && !empty($this->fields[
'ref'])) {
255 $this->fields[
'rowid'][
'visible'] = 0;
257 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
258 $this->fields[
'entity'][
'enabled'] = 0;
268 foreach ($this->fields as $key => $val) {
269 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
270 unset($this->fields[$key]);
275 if (is_object($langs)) {
276 foreach ($this->fields as $key => $val) {
277 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
278 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
279 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
299 return $resultcreate;
311 global $langs, $extrafields;
316 $object =
new self($this->db);
321 $result = $object->fetchCommon($fromid);
322 if ($result > 0 && !empty($object->table_element_line)) {
323 $object->fetchLines();
332 unset($object->fk_user_creat);
333 unset($object->import_key);
336 if (property_exists($object,
'ref')) {
337 $object->ref = empty($this->fields[
'ref'][
'default']) ?
"Copy_Of_".$object->ref : $this->fields[
'ref'][
'default'];
339 if (property_exists($object,
'label')) {
340 $object->label = empty($this->fields[
'label'][
'default']) ? $langs->trans(
"CopyOf").
" ".$object->label : $this->fields[
'label'][
'default'];
342 if (property_exists($object,
'status')) {
343 $object->status = self::STATUS_DRAFT;
345 if (property_exists($object,
'date_creation')) {
346 $object->date_creation =
dol_now();
348 if (property_exists($object,
'date_modification')) {
349 $object->date_modification =
null;
353 if (is_array($object->array_options) && count($object->array_options) > 0) {
354 $extrafields->fetch_name_optionals_label($this->table_element);
355 foreach ($object->array_options as $key => $option) {
356 $shortkey = preg_replace(
'/options_/',
'', $key);
357 if (!empty($extrafields->attributes[$this->table_element][
'unique'][$shortkey])) {
360 unset($object->array_options[$key]);
366 $object->context[
'createfromclone'] =
'createfromclone';
367 $result = $object->createCommon($user);
382 if (!empty($object->socid) && property_exists($this,
'fk_soc') && $this->fk_soc == $object->socid) {
389 unset($object->context[
'createfromclone']);
396 $this->db->rollback();
410 public function fetch($id, $ref =
null, $noextrafields = 0, $nolines = 0)
412 $result = $this->
fetchCommon($id, $ref,
'', $noextrafields);
413 if ($result > 0 && !empty($this->table_element_line) && empty($nolines)) {
427 $this->lines = array();
445 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, array $filter = array(), $filtermode =
'AND')
453 $sql .=
" FROM ".$this->db->prefix().$this->table_element.
" as t";
454 if (isset($this->isextrafieldmanaged) && $this->isextrafieldmanaged == 1) {
455 $sql .=
" LEFT JOIN ".$this->db->prefix().$this->table_element.
"_extrafields as te ON te.fk_object = t.rowid";
457 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
458 $sql .=
" WHERE t.entity IN (".getEntity($this->element).
")";
460 $sql .=
" WHERE 1 = 1";
464 if (count($filter) > 0) {
465 foreach ($filter as $key => $value) {
466 $columnName = preg_replace(
'/^t\./',
'', $key);
467 if ($key ===
'customsql') {
469 $sqlwhere[] = $value;
471 } elseif (isset($this->fields[$columnName])) {
472 $type = $this->fields[$columnName][
'type'];
473 if (preg_match(
'/^integer/', $type)) {
474 if (is_int($value)) {
476 $sqlwhere[] = $key .
" = " . intval($value);
477 } elseif (is_array($value)) {
481 $sqlwhere[] = $key .
' IN (' . $this->db->sanitize(implode(
',', array_map(
'intval', $value))) .
')';
484 } elseif (in_array($type, array(
'date',
'datetime',
'timestamp'))) {
485 $sqlwhere[] = $key .
" = '" . $this->db->idate($value) .
"'";
491 if (is_array($value) && count($value)) {
492 $value = implode(
',', array_map(
function ($v) {
493 return "'" . $this->db->sanitize($this->db->escape($v)) .
"'";
495 $sqlwhere[] = $key .
' IN (' . $this->db->sanitize($value,
true) .
')';
496 } elseif (is_scalar($value)) {
497 if (strpos($value,
'%') ===
false) {
498 $sqlwhere[] = $key .
" = '" . $this->db->sanitize($this->db->escape($value)) .
"'";
500 $sqlwhere[] = $key .
" LIKE '%" . $this->db->escape($this->db->escapeforlike($value)) .
"%'";
505 if (count($sqlwhere) > 0) {
506 $sql .=
" AND (".implode(
" ".$filtermode.
" ", $sqlwhere).
")";
509 if (!empty($sortfield)) {
510 $sql .= $this->db->order($sortfield, $sortorder);
512 if (!empty($limit)) {
513 $sql .= $this->db->plimit($limit, $offset);
516 $resql = $this->db->query($sql);
518 $num = $this->db->num_rows($resql);
520 while ($i < ($limit ? min($limit, $num) : $num)) {
521 $obj = $this->db->fetch_object($resql);
523 $record =
new self($this->db);
524 $record->setVarsFromFetchObj($obj);
526 $records[$record->id] = $record;
530 $this->db->free($resql);
534 $this->errors[] =
'Error '.$this->db->lasterror();
535 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
560 public function delete(
User $user, $notrigger =
false)
577 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
594 global $conf, $langs;
596 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
601 if ($this->
status == self::STATUS_VALIDATED) {
602 dol_syslog(get_class($this).
"::validate action abandonned: already validated", LOG_WARNING);
619 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
624 $this->newref = $num;
628 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
629 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
630 $sql .=
" status = ".self::STATUS_VALIDATED;
631 if (!empty($this->fields[
'date_validation'])) {
632 $sql .=
", date_validation = '".$this->db->idate($now).
"'";
634 if (!empty($this->fields[
'fk_user_valid'])) {
635 $sql .=
", fk_user_valid = ".((int) $user->id);
637 $sql .=
" WHERE rowid = ".((int) $this->
id);
639 dol_syslog(get_class($this).
"::validate()", LOG_DEBUG);
640 $resql = $this->db->query($sql);
643 $this->error = $this->db->lasterror();
647 if (!$error && !$notrigger) {
649 $result = $this->
call_trigger(
'MYOBJECT_VALIDATE', $user);
658 $this->oldref = $this->ref;
661 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
663 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filename = CONCAT('".$this->db->escape($this->newref).
"', SUBSTR(filename, ".(strlen($this->
ref) + 1).
")), filepath = 'myobject/".$this->db->escape($this->newref).
"'";
664 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'myobject/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
665 $resql = $this->db->query($sql);
668 $this->error = $this->db->lasterror();
670 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'myobject/".$this->db->escape($this->newref).
"'";
671 $sql .=
" WHERE filepath = 'myobject/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
672 $resql = $this->db->query($sql);
675 $this->error = $this->db->lasterror();
681 $dirsource = $conf->mymodule->dir_output.
'/myobject/'.$oldref;
682 $dirdest = $conf->mymodule->dir_output.
'/myobject/'.$newref;
683 if (!$error && file_exists($dirsource)) {
684 dol_syslog(get_class($this).
"::validate() rename dir ".$dirsource.
" into ".$dirdest);
686 if (@rename($dirsource, $dirdest)) {
689 $listoffiles =
dol_dir_list($conf->mymodule->dir_output.
'/myobject/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
690 foreach ($listoffiles as $fileentry) {
691 $dirsource = $fileentry[
'name'];
692 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
693 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
694 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
695 @rename($dirsource, $dirdest);
705 $this->
status = self::STATUS_VALIDATED;
712 $this->db->rollback();
728 if ($this->
status <= self::STATUS_DRAFT) {
739 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'MYMODULE_MYOBJECT_UNVALIDATE');
749 public function cancel($user, $notrigger = 0)
752 if ($this->
status != self::STATUS_VALIDATED) {
763 return $this->
setStatusCommon($user, self::STATUS_CANCELED, $notrigger,
'MYMODULE_MYOBJECT_CANCEL');
773 public function reopen($user, $notrigger = 0)
776 if ($this->
status == self::STATUS_VALIDATED) {
787 return $this->
setStatusCommon($user, self::STATUS_VALIDATED, $notrigger,
'MYMODULE_MYOBJECT_REOPEN');
804 return [
'optimize' => $langs->trans(
"ShowMyObject")];
806 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"MyObject").
'</u>';
807 if (isset($this->
status)) {
808 $datas[
'picto'] .=
' '.$this->getLibStatut(5);
810 if (property_exists($this,
'ref')) {
811 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
813 if (property_exists($this,
'label')) {
814 $datas[
'ref'] =
'<br>'.$langs->trans(
'Label').
':</b> '.$this->label;
830 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
832 global $conf, $langs, $hookmanager;
834 if (!empty($conf->dol_no_mouse_hover)) {
841 'objecttype' => $this->element.($this->module ?
'@'.$this->module :
''),
844 $classfortooltip =
'classfortooltip';
847 $classfortooltip =
'classforajaxtooltip';
848 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
854 $url =
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.$this->id;
856 if ($option !==
'nolink') {
858 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
859 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
860 $add_save_lastsearch_values = 1;
862 if ($url && $add_save_lastsearch_values) {
863 $url .=
'&save_lastsearch_values=1';
868 if (empty($notooltip)) {
870 $label = $langs->trans(
"ShowMyObject");
871 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
873 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
874 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
876 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
879 if ($option ==
'nolink' || empty($url)) {
880 $linkstart =
'<span';
882 $linkstart =
'<a href="'.$url.
'"';
884 $linkstart .= $linkclose.
'>';
885 if ($option ==
'nolink' || empty($url)) {
886 $linkend =
'</span>';
891 $result .= $linkstart;
893 if (empty($this->showphoto_on_popup)) {
895 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), (($withpicto != 2) ?
'class="paddingright"' :
''), 0, 0, $notooltip ? 0 : 1);
899 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
901 list($class, $module) = explode(
'@', $this->picto);
904 $filename = $filearray[0][
'name'];
905 if (!empty($filename)) {
906 $pospoint = strpos($filearray[0][
'name'],
'.');
908 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
910 $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>';
912 $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>';
917 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'"'), 0, 0, $notooltip ? 0 : 1);
922 if ($withpicto != 2) {
923 $result .= $this->ref;
929 global $action, $hookmanager;
930 $hookmanager->initHooks(array($this->element.
'dao'));
931 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
932 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
934 $result = $hookmanager->resPrint;
936 $result .= $hookmanager->resPrint;
951 global $conf, $langs;
953 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
955 $return =
'<div class="box-flex-item box-flex-grow-zero">';
956 $return .=
'<div class="info-box info-box-sm">';
957 $return .=
'<span class="info-box-icon bg-infobox-action">';
959 $return .=
'</span>';
960 $return .=
'<div class="info-box-content">';
961 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
962 if ($selected >= 0) {
963 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
965 if (property_exists($this,
'label')) {
966 $return .=
' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.
'</div>';
968 if (property_exists($this,
'thirdparty') && is_object($this->thirdparty)) {
969 $return .=
'<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).
'</div>';
971 if (property_exists($this,
'amount')) {
973 $return .=
'<span class="info-box-label amount">'.price($this->amount, 0, $langs, 1, -1, -1, $conf->currency).
'</span>';
975 if (method_exists($this,
'getLibStatut')) {
976 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
1018 if (is_null($status)) {
1022 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1025 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1026 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Enabled');
1027 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Disabled');
1028 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1029 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Enabled');
1030 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Disabled');
1033 $statusType =
'status'.$status;
1035 if ($status == self::STATUS_CANCELED) {
1036 $statusType =
'status6';
1039 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
1050 $sql =
"SELECT rowid,";
1051 $sql .=
" date_creation as datec, tms as datem";
1052 if (!empty($this->fields[
'date_validation'])) {
1053 $sql .=
", date_validation as datev";
1055 if (!empty($this->fields[
'fk_user_creat'])) {
1056 $sql .=
", fk_user_creat";
1058 if (!empty($this->fields[
'fk_user_modif'])) {
1059 $sql .=
", fk_user_modif";
1061 if (!empty($this->fields[
'fk_user_valid'])) {
1062 $sql .=
", fk_user_valid";
1064 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element.
" as t";
1065 $sql .=
" WHERE t.rowid = ".((int) $id);
1067 $result = $this->db->query($sql);
1069 if ($this->db->num_rows($result)) {
1070 $obj = $this->db->fetch_object($result);
1072 $this->
id = $obj->rowid;
1074 if (!empty($this->fields[
'fk_user_creat'])) {
1075 $this->user_creation_id = $obj->fk_user_creat;
1077 if (!empty($this->fields[
'fk_user_modif'])) {
1078 $this->user_modification_id = $obj->fk_user_modif;
1080 if (!empty($this->fields[
'fk_user_valid'])) {
1081 $this->user_validation_id = $obj->fk_user_valid;
1083 $this->date_creation = $this->db->jdate($obj->datec);
1084 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
1085 if (!empty($obj->datev)) {
1086 $this->date_validation = empty($obj->datev) ?
'' : $this->db->jdate($obj->datev);
1090 $this->db->free($result);
1118 $this->lines = array();
1121 $result = $objectline->fetchAll(
'ASC',
'position', 0, 0, array(
'customsql'=>
'fk_myobject = '.((
int) $this->
id)));
1123 if (is_numeric($result)) {
1127 $this->lines = $result;
1128 return $this->lines;
1139 global $langs, $conf;
1140 $langs->load(
"mymodule@mymodule");
1143 $conf->global->MYMODULE_MYOBJECT_ADDON =
'mod_myobject_standard';
1153 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
1154 foreach ($dirmodels as $reldir) {
1158 $mybool |= @include_once $dir.$file;
1161 if ($mybool ===
false) {
1166 if (class_exists($classname)) {
1167 $obj =
new $classname();
1168 $numref = $obj->getNextValue($this);
1170 if ($numref !=
'' && $numref !=
'-1') {
1173 $this->error = $obj->error;
1178 print $langs->trans(
"Error").
" ".$langs->trans(
"ClassNotFound").
' '.$classname;
1182 print $langs->trans(
"ErrorNumberingModuleNotSetup", $this->element);
1198 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
1200 global $conf, $langs;
1203 $includedocgeneration = 0;
1205 $langs->load(
"mymodule@mymodule");
1208 $modele =
'standard_myobject';
1210 if (!empty($this->model_pdf)) {
1211 $modele = $this->model_pdf;
1217 $modelpath =
"core/modules/mymodule/doc/";
1219 if ($includedocgeneration && !empty($modele)) {
1220 $result = $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1251 $this->db->commit();
1260require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
1273 public $isextrafieldmanaged = 0;
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Parent class of all other business classes (invoices, contracts, proposals, orders,...
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
deleteLineCommon(User $user, $idline, $notrigger=false)
Delete a line of object in database.
setErrorsFromObject($object)
setErrorsFromObject
createCommon(User $user, $notrigger=false)
Create object into database.
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.
copy_linked_contact($objFrom, $source='internal')
Copy contact from one element to current.
updateCommon(User $user, $notrigger=false)
Update object into database.
fetchLinesCommon($morewhere='', $noextrafields=0)
Load object in memory from the database.
fetchCommon($id, $ref=null, $morewhere='', $noextrafields=0)
Load object in memory from the database.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage Dolibarr database access.
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
createFromClone(User $user, $fromid)
Clone an object into another one.
getKanbanView($option='', $arraydata=null)
Return a thumb for kanban views.
getLibStatut($mode=0)
Return the label of the status.
getTooltipContentArray($params)
getTooltipContentArray
reopen($user, $notrigger=0)
Set back to validated status.
setDraft($user, $notrigger=0)
Set draft status.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionaly the picto)
LibStatut($status, $mode=0)
Return the label of a given status.
getNextNumRef()
Returns the reference to the following non used object depending on the active numbering module.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter=array(), $filtermode='AND')
Load list of objects in memory from the database.
__construct(DoliDB $db)
Constructor.
cancel($user, $notrigger=0)
Set cancel status.
update(User $user, $notrigger=false)
Update object into database.
fetchLines($noextrafields=0)
Load object lines in memory from the database.
info($id)
Load the info information in the object.
doScheduledJob()
Action executed by scheduler CAN BE A CRON TASK.
fetch($id, $ref=null, $noextrafields=0, $nolines=0)
Load object in memory from the database.
getLabelStatus($mode=0)
Return the label of the status.
create(User $user, $notrigger=false)
Create object into database.
deleteLine(User $user, $idline, $notrigger=false)
Delete a line of object in database.
validate($user, $notrigger=0)
Validate object.
getLinesArray()
Create an array of lines.
__construct(DoliDB $db)
Constructor.
Class to manage Dolibarr users.
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.
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_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a 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)
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.