28require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
40 public $module =
'mymodule';
45 public $element =
'myobject';
50 public $table_element =
'mymodule_myobject';
60 public $picto =
'fa-file';
63 const STATUS_DRAFT = 0;
64 const STATUS_VALIDATED = 1;
65 const STATUS_CANCELED = 9;
111 public $fields = array(
112 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -2,
'noteditable' => 1,
'notnull' => 1,
'index' => 1,
'position' => 1,
'comment' =>
'Id',
'css' =>
'left'),
113 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'enabled' => 1,
'visible' => 0,
'notnull' => 1,
'default' => 1,
'index' => 1,
'position' => 10),
114 '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),
115 '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),
116 '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),
117 '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),
118 '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'),
119 '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'),
120 'description' => array(
'type' =>
'text',
'label' =>
'Description',
'enabled' => 1,
'visible' => 3,
'position' => 60,
'validate' => 1),
121 'note_public' => array(
'type' =>
'html',
'label' =>
'NotePublic',
'enabled' => 1,
'visible' => 0,
'position' => 61,
'validate' => 1,
'cssview' =>
'wordbreak'),
122 'note_private' => array(
'type' =>
'html',
'label' =>
'NotePrivate',
'enabled' => 1,
'visible' => 0,
'position' => 62,
'validate' => 1,
'cssview' =>
'wordbreak'),
123 'date_creation' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -2,
'notnull' => 1,
'position' => 500),
124 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -2,
'notnull' => 0,
'position' => 501),
126 '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'),
127 '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'),
129 'last_main_doc' => array(
'type' =>
'varchar(255)',
'label' =>
'LastMainDoc',
'enabled' => 1,
'visible' => 0,
'notnull' => 0,
'position' => 600),
130 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'notnull' => -1,
'index' => 0,
'position' => 1000),
131 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'visible' => 0,
'notnull' => -1,
'position' => 1010),
132 '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),
174 public $date_creation;
179 public $fk_user_creat;
184 public $fk_user_modif;
189 public $last_main_doc;
244 $this->ismultientitymanaged = 0;
245 $this->isextrafieldmanaged = 1;
247 if (!
getDolGlobalInt(
'MAIN_SHOW_TECHNICAL_ID') && isset($this->fields[
'rowid']) && !empty($this->fields[
'ref'])) {
248 $this->fields[
'rowid'][
'visible'] = 0;
250 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
251 $this->fields[
'entity'][
'enabled'] = 0;
261 foreach ($this->fields as $key => $val) {
262 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
263 unset($this->fields[$key]);
268 if (is_object($langs)) {
269 foreach ($this->fields as $key => $val) {
270 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
271 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
272 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
292 return $resultcreate;
304 global $langs, $extrafields;
314 $result =
$object->fetchCommon($fromid);
315 if ($result > 0 && !empty(
$object->table_element_line)) {
329 if (property_exists(
$object,
'ref')) {
330 $object->ref = empty($this->fields[
'ref'][
'default']) ?
"Copy_Of_".$object->ref : $this->fields[
'ref'][
'default'];
332 if (property_exists(
$object,
'label')) {
333 $object->label = empty($this->fields[
'label'][
'default']) ? $langs->trans(
"CopyOf").
" ".
$object->label : $this->fields[
'label'][
'default'];
335 if (property_exists(
$object,
'status')) {
336 $object->status = self::STATUS_DRAFT;
338 if (property_exists(
$object,
'date_creation')) {
341 if (property_exists(
$object,
'date_modification')) {
342 $object->date_modification =
null;
346 if (is_array(
$object->array_options) && count(
$object->array_options) > 0) {
347 $extrafields->fetch_name_optionals_label($this->table_element);
348 foreach (
$object->array_options as $key => $option) {
349 $shortkey = preg_replace(
'/options_/',
'', $key);
350 if (!empty($extrafields->attributes[$this->table_element][
'unique'][$shortkey])) {
353 unset(
$object->array_options[$key]);
359 $object->context[
'createfromclone'] =
'createfromclone';
360 $result =
$object->createCommon($user);
375 if (!empty(
$object->socid) && property_exists($this,
'fk_soc') && $this->fk_soc ==
$object->socid) {
382 unset(
$object->context[
'createfromclone']);
389 $this->db->rollback();
403 public function fetch($id, $ref =
null, $noextrafields = 0, $nolines = 0)
405 $result = $this->
fetchCommon($id, $ref,
'', $noextrafields);
406 if ($result > 0 && !empty($this->table_element_line) && empty($nolines)) {
420 $this->lines = array();
441 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 1000, $offset = 0,
string $filter =
'', $filtermode =
'AND')
449 $sql .=
" FROM ".$this->db->prefix().$this->table_element.
" as t";
450 if (isset($this->isextrafieldmanaged) && $this->isextrafieldmanaged == 1) {
451 $sql .=
" LEFT JOIN ".$this->db->prefix().$this->table_element.
"_extrafields as te ON te.fk_object = t.rowid";
453 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
454 $sql .=
" WHERE t.entity IN (".getEntity($this->element).
")";
456 $sql .=
" WHERE 1 = 1";
463 $this->errors[] = $errormessage;
464 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
468 if (!empty($sortfield)) {
469 $sql .= $this->db->order($sortfield, $sortorder);
471 if (!empty($limit)) {
472 $sql .= $this->db->plimit($limit, $offset);
475 $resql = $this->db->query($sql);
477 $num = $this->db->num_rows($resql);
479 while ($i < ($limit ? min($limit, $num) : $num)) {
480 $obj = $this->db->fetch_object($resql);
482 $record =
new self($this->db);
483 $record->setVarsFromFetchObj($obj);
485 if (!empty($record->isextrafieldmanaged)) {
486 $record->fetch_optionals();
489 $records[$record->id] = $record;
493 $this->db->free($resql);
497 $this->errors[] =
'Error '.$this->db->lasterror();
498 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
523 public function delete(
User $user, $notrigger = 0)
540 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
559 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
564 if ($this->
status == self::STATUS_VALIDATED) {
565 dol_syslog(get_class($this).
"::validate action abandoned: already validated", LOG_WARNING);
582 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
587 $this->newref = $num;
591 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
593 if (!empty($this->fields[
'ref'])) {
594 $sql .=
" ref = '".$this->db->escape($num).
"',";
596 $sql .=
" status = ".self::STATUS_VALIDATED;
597 if (!empty($this->fields[
'date_validation'])) {
598 $sql .=
", date_validation = '".$this->db->idate($now).
"'";
600 if (!empty($this->fields[
'fk_user_valid'])) {
601 $sql .=
", fk_user_valid = ".((int) $user->id);
603 $sql .=
" WHERE rowid = ".((int) $this->
id);
605 dol_syslog(get_class($this).
"::validate()", LOG_DEBUG);
606 $resql = $this->db->query($sql);
609 $this->error = $this->db->lasterror();
613 if (!$error && !$notrigger) {
615 $result = $this->
call_trigger(
'MYOBJECT_VALIDATE', $user);
624 $this->oldref = $this->ref;
627 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
629 $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).
"'";
630 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'myobject/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
631 $resql = $this->db->query($sql);
634 $this->error = $this->db->lasterror();
636 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'myobject/".$this->db->escape($this->newref).
"'";
637 $sql .=
" WHERE filepath = 'myobject/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
638 $resql = $this->db->query($sql);
641 $this->error = $this->db->lasterror();
647 $dirsource = $conf->mymodule->dir_output.
'/myobject/'.$oldref;
648 $dirdest = $conf->mymodule->dir_output.
'/myobject/'.$newref;
649 if (!$error && file_exists($dirsource)) {
650 dol_syslog(get_class($this).
"::validate() rename dir ".$dirsource.
" into ".$dirdest);
652 if (@rename($dirsource, $dirdest)) {
655 $listoffiles =
dol_dir_list($conf->mymodule->dir_output.
'/myobject/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
656 foreach ($listoffiles as $fileentry) {
657 $dirsource = $fileentry[
'name'];
658 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
659 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
660 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
661 @rename($dirsource, $dirdest);
671 $this->
status = self::STATUS_VALIDATED;
678 $this->db->rollback();
694 if ($this->
status <= self::STATUS_DRAFT) {
705 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'MYMODULE_MYOBJECT_UNVALIDATE');
715 public function cancel($user, $notrigger = 0)
718 if ($this->
status != self::STATUS_VALIDATED) {
729 return $this->
setStatusCommon($user, self::STATUS_CANCELED, $notrigger,
'MYMODULE_MYOBJECT_CANCEL');
739 public function reopen($user, $notrigger = 0)
742 if ($this->
status == self::STATUS_VALIDATED) {
753 return $this->
setStatusCommon($user, self::STATUS_VALIDATED, $notrigger,
'MYMODULE_MYOBJECT_REOPEN');
770 return [
'optimize' => $langs->trans(
"ShowMyObject")];
772 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"MyObject").
'</u>';
773 if (isset($this->
status)) {
774 $datas[
'picto'] .=
' '.$this->getLibStatut(5);
776 if (property_exists($this,
'ref')) {
777 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
779 if (property_exists($this,
'label')) {
780 $datas[
'ref'] =
'<br>'.$langs->trans(
'Label').
':</b> '.$this->label;
796 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
798 global $conf, $langs, $hookmanager;
800 if (!empty($conf->dol_no_mouse_hover)) {
807 'objecttype' => $this->element.($this->module ?
'@'.$this->module :
''),
810 $classfortooltip =
'classfortooltip';
813 $classfortooltip =
'classforajaxtooltip';
814 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
820 $url =
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.$this->id;
822 if ($option !==
'nolink') {
824 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
825 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
826 $add_save_lastsearch_values = 1;
828 if ($url && $add_save_lastsearch_values) {
829 $url .=
'&save_lastsearch_values=1';
834 if (empty($notooltip)) {
836 $label = $langs->trans(
"ShowMyObject");
837 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
839 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
840 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
842 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
845 if ($option ==
'nolink' || empty($url)) {
846 $linkstart =
'<span';
848 $linkstart =
'<a href="'.$url.
'"';
850 $linkstart .= $linkclose.
'>';
851 if ($option ==
'nolink' || empty($url)) {
852 $linkend =
'</span>';
857 $result .= $linkstart;
859 if (empty($this->showphoto_on_popup)) {
861 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), (($withpicto != 2) ?
'class="paddingright"' :
''), 0, 0, $notooltip ? 0 : 1);
865 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
867 list($class, $module) = explode(
'@', $this->picto);
870 $filename = $filearray[0][
'name'];
871 if (!empty($filename)) {
872 $pospoint = strpos($filearray[0][
'name'],
'.');
874 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
876 $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>';
878 $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>';
883 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'"'), 0, 0, $notooltip ? 0 : 1);
888 if ($withpicto != 2) {
889 $result .= $this->ref;
895 global $action, $hookmanager;
896 $hookmanager->initHooks(array($this->element.
'dao'));
897 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
898 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
900 $result = $hookmanager->resPrint;
902 $result .= $hookmanager->resPrint;
917 global $conf, $langs;
919 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
921 $return =
'<div class="box-flex-item box-flex-grow-zero">';
922 $return .=
'<div class="info-box info-box-sm">';
923 $return .=
'<span class="info-box-icon bg-infobox-action">';
925 $return .=
'</span>';
926 $return .=
'<div class="info-box-content">';
927 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
928 if ($selected >= 0) {
929 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
931 if (property_exists($this,
'label')) {
932 $return .=
' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.
'</div>';
934 if (property_exists($this,
'thirdparty') && is_object($this->thirdparty)) {
935 $return .=
'<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).
'</div>';
937 if (property_exists($this,
'amount')) {
939 $return .=
'<span class="info-box-label amount">'.price($this->amount, 0, $langs, 1, -1, -1, $conf->currency).
'</span>';
941 if (method_exists($this,
'getLibStatut')) {
942 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
984 if (is_null($status)) {
988 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
991 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
992 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Enabled');
993 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Disabled');
994 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
995 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Enabled');
996 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Disabled');
999 $statusType =
'status'.$status;
1001 if ($status == self::STATUS_CANCELED) {
1002 $statusType =
'status6';
1005 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
1016 $sql =
"SELECT rowid,";
1017 $sql .=
" date_creation as datec, tms as datem";
1018 if (!empty($this->fields[
'date_validation'])) {
1019 $sql .=
", date_validation as datev";
1021 if (!empty($this->fields[
'fk_user_creat'])) {
1022 $sql .=
", fk_user_creat";
1024 if (!empty($this->fields[
'fk_user_modif'])) {
1025 $sql .=
", fk_user_modif";
1027 if (!empty($this->fields[
'fk_user_valid'])) {
1028 $sql .=
", fk_user_valid";
1030 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element.
" as t";
1031 $sql .=
" WHERE t.rowid = ".((int) $id);
1033 $result = $this->db->query($sql);
1035 if ($this->db->num_rows($result)) {
1036 $obj = $this->db->fetch_object($result);
1038 $this->
id = $obj->rowid;
1040 if (!empty($this->fields[
'fk_user_creat'])) {
1041 $this->user_creation_id = $obj->fk_user_creat;
1043 if (!empty($this->fields[
'fk_user_modif'])) {
1044 $this->user_modification_id = $obj->fk_user_modif;
1046 if (!empty($this->fields[
'fk_user_valid'])) {
1047 $this->user_validation_id = $obj->fk_user_valid;
1049 $this->date_creation = $this->db->jdate($obj->datec);
1050 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
1051 if (!empty($obj->datev)) {
1052 $this->date_validation = empty($obj->datev) ?
'' : $this->db->jdate($obj->datev);
1056 $this->db->free($result);
1084 $this->lines = array();
1087 $result = $objectline->fetchAll(
'ASC',
'position', 0, 0,
'(fk_myobject:=:'.((
int) $this->
id).
')');
1089 if (is_numeric($result)) {
1093 $this->lines = $result;
1094 return $this->lines;
1105 global $langs, $conf;
1106 $langs->load(
"mymodule@mymodule");
1109 $conf->global->MYMODULE_MYOBJECT_ADDON =
'mod_myobject_standard';
1119 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
1120 foreach ($dirmodels as $reldir) {
1124 $mybool |= @include_once $dir.$file;
1127 if ($mybool ===
false) {
1132 if (class_exists($classname)) {
1133 $obj =
new $classname();
1134 $numref = $obj->getNextValue($this);
1136 if ($numref !=
'' && $numref !=
'-1') {
1139 $this->error = $obj->error;
1144 print $langs->trans(
"Error").
" ".$langs->trans(
"ClassNotFound").
' '.$classname;
1148 print $langs->trans(
"ErrorNumberingModuleNotSetup", $this->element);
1164 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
1169 $includedocgeneration = 0;
1171 $langs->load(
"mymodule@mymodule");
1174 $modele =
'standard_myobject';
1176 if (!empty($this->model_pdf)) {
1177 $modele = $this->model_pdf;
1183 $modelpath =
"core/modules/mymodule/doc/";
1185 if ($includedocgeneration && !empty($modele)) {
1186 $result = $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1206 return parent::validateField($fields, $fieldKey, $fieldValue);
1234 $this->db->commit();
1243require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
1274 $this->isextrafieldmanaged = 0;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Parent class of all other business classes (invoices, contracts, proposals, orders,...
deleteLineCommon(User $user, $idline, $notrigger=0)
Delete a line of object in database.
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
setErrorsFromObject($object)
setErrorsFromObject
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.
copy_linked_contact($objFrom, $source='internal')
Copy contact from one element to current.
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.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in 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.
create(User $user, $notrigger=0)
Create object into database.
update(User $user, $notrigger=0)
Update object into database.
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 optionally the picto)
LibStatut($status, $mode=0)
Return the label of a given status.
validateField($fields, $fieldKey, $fieldValue)
Return validation test result for a field.
getNextNumRef()
Returns the reference to the following non used object depending on the active numbering module.
fetchAll($sortorder='', $sortfield='', $limit=1000, $offset=0, string $filter='', $filtermode='AND')
Load list of objects in memory from the database.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
__construct(DoliDB $db)
Constructor.
deleteLine(User $user, $idline, $notrigger=0)
Delete a line of object in database.
cancel($user, $notrigger=0)
Set cancel status.
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.
validate($user, $notrigger=0)
Validate object.
getLinesArray()
Create an array of lines.
$parent_element
To overload.
$fk_parent_attribute
To overload.
__construct(DoliDB $db)
Constructor.
Class to manage Dolibarr users.
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)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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...
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.