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;
116 public $fields = array(
117 'rowid' => array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>1,
'visible'=>-2,
'noteditable'=>1,
'notnull'=> 1,
'index'=>1,
'position'=>1,
'comment'=>
'Id',
'css'=>
'left'),
118 'entity' => array(
'type'=>
'integer',
'label'=>
'Entity',
'enabled'=>1,
'visible'=>0,
'notnull'=> 1,
'default'=>1,
'index'=>1,
'position'=>10),
119 '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),
120 '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),
121 '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),
122 '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),
123 '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'),
124 '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'),
125 'description' => array(
'type'=>
'text',
'label'=>
'Description',
'enabled'=>1,
'visible'=>3,
'position'=>60,
'validate'=>1),
126 'note_public' => array(
'type'=>
'html',
'label'=>
'NotePublic',
'enabled'=>1,
'visible'=>0,
'position'=>61,
'validate'=>1,
'cssview'=>
'wordbreak'),
127 'note_private' => array(
'type'=>
'html',
'label'=>
'NotePrivate',
'enabled'=>1,
'visible'=>0,
'position'=>62,
'validate'=>1,
'cssview'=>
'wordbreak'),
128 'date_creation' => array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>1,
'visible'=>-2,
'notnull'=> 1,
'position'=>500),
129 'tms' => array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>1,
'visible'=>-2,
'notnull'=> 0,
'position'=>501),
131 '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'),
132 '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'),
134 'last_main_doc' => array(
'type'=>
'varchar(255)',
'label'=>
'LastMainDoc',
'enabled'=>1,
'visible'=>0,
'notnull'=>0,
'position'=>600),
135 'import_key' => array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>1,
'visible'=>-2,
'notnull'=>-1,
'index'=>0,
'position'=>1000),
136 'model_pdf' => array(
'type'=>
'varchar(255)',
'label'=>
'Model pdf',
'enabled'=>1,
'visible'=>0,
'notnull'=>-1,
'position'=>1010),
137 '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),
179 public $date_creation;
189 public $fk_user_creat;
194 public $fk_user_modif;
199 public $last_main_doc;
251 global $conf, $langs;
255 if (!
getDolGlobalInt(
'MAIN_SHOW_TECHNICAL_ID') && isset($this->fields[
'rowid']) && !empty($this->fields[
'ref'])) {
256 $this->fields[
'rowid'][
'visible'] = 0;
258 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
259 $this->fields[
'entity'][
'enabled'] = 0;
269 foreach ($this->fields as $key => $val) {
270 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
271 unset($this->fields[$key]);
276 if (is_object($langs)) {
277 foreach ($this->fields as $key => $val) {
278 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
279 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
280 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
300 return $resultcreate;
312 global $langs, $extrafields;
317 $object =
new self($this->db);
322 $result = $object->fetchCommon($fromid);
323 if ($result > 0 && !empty($object->table_element_line)) {
324 $object->fetchLines();
333 unset($object->fk_user_creat);
334 unset($object->import_key);
337 if (property_exists($object,
'ref')) {
338 $object->ref = empty($this->fields[
'ref'][
'default']) ?
"Copy_Of_".$object->ref : $this->fields[
'ref'][
'default'];
340 if (property_exists($object,
'label')) {
341 $object->label = empty($this->fields[
'label'][
'default']) ? $langs->trans(
"CopyOf").
" ".$object->label : $this->fields[
'label'][
'default'];
343 if (property_exists($object,
'status')) {
344 $object->status = self::STATUS_DRAFT;
346 if (property_exists($object,
'date_creation')) {
347 $object->date_creation =
dol_now();
349 if (property_exists($object,
'date_modification')) {
350 $object->date_modification =
null;
354 if (is_array($object->array_options) && count($object->array_options) > 0) {
355 $extrafields->fetch_name_optionals_label($this->table_element);
356 foreach ($object->array_options as $key => $option) {
357 $shortkey = preg_replace(
'/options_/',
'', $key);
358 if (!empty($extrafields->attributes[$this->table_element][
'unique'][$shortkey])) {
361 unset($object->array_options[$key]);
367 $object->context[
'createfromclone'] =
'createfromclone';
368 $result = $object->createCommon($user);
383 if (!empty($object->socid) && property_exists($this,
'fk_soc') && $this->fk_soc == $object->socid) {
390 unset($object->context[
'createfromclone']);
397 $this->db->rollback();
409 public function fetch($id, $ref =
null)
412 if ($result > 0 && !empty($this->table_element_line)) {
425 $this->lines = array();
443 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, array $filter = array(), $filtermode =
'AND')
451 $sql .=
" FROM ".$this->db->prefix().$this->table_element.
" as t";
452 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
453 $sql .=
" WHERE t.entity IN (".getEntity($this->element).
")";
455 $sql .=
" WHERE 1 = 1";
459 if (count($filter) > 0) {
460 foreach ($filter as $key => $value) {
461 if ($key ==
't.rowid') {
462 $sqlwhere[] = $key.
" = ".((int) $value);
463 } elseif (in_array($this->fields[$key][
'type'], array(
'date',
'datetime',
'timestamp'))) {
464 $sqlwhere[] = $key.
" = '".$this->db->idate($value).
"'";
465 } elseif ($key ==
'customsql') {
466 $sqlwhere[] = $value;
467 } elseif (strpos($value,
'%') ===
false) {
468 $sqlwhere[] = $key.
" IN (".$this->db->sanitize($this->db->escape($value)).
")";
470 $sqlwhere[] = $key.
" LIKE '%".$this->db->escapeforlike($this->db->escape($value)).
"%'";
474 if (count($sqlwhere) > 0) {
475 $sql .=
" AND (".implode(
" ".$filtermode.
" ", $sqlwhere).
")";
478 if (!empty($sortfield)) {
479 $sql .= $this->db->order($sortfield, $sortorder);
481 if (!empty($limit)) {
482 $sql .= $this->db->plimit($limit, $offset);
485 $resql = $this->db->query($sql);
487 $num = $this->db->num_rows($resql);
489 while ($i < ($limit ? min($limit, $num) : $num)) {
490 $obj = $this->db->fetch_object($resql);
492 $record =
new self($this->db);
493 $record->setVarsFromFetchObj($obj);
495 $records[$record->id] = $record;
499 $this->db->free($resql);
503 $this->errors[] =
'Error '.$this->db->lasterror();
504 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
529 public function delete(
User $user, $notrigger =
false)
545 if ($this->status < 0) {
546 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
563 global $conf, $langs;
565 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
570 if ($this->status == self::STATUS_VALIDATED) {
571 dol_syslog(get_class($this).
"::validate action abandonned: already validated", LOG_WARNING);
588 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
593 $this->newref = $num;
597 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
598 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
599 $sql .=
" status = ".self::STATUS_VALIDATED;
600 if (!empty($this->fields[
'date_validation'])) {
601 $sql .=
", date_validation = '".$this->db->idate($now).
"'";
603 if (!empty($this->fields[
'fk_user_valid'])) {
604 $sql .=
", fk_user_valid = ".((int) $user->id);
606 $sql .=
" WHERE rowid = ".((int) $this->
id);
608 dol_syslog(get_class($this).
"::validate()", LOG_DEBUG);
609 $resql = $this->db->query($sql);
612 $this->error = $this->db->lasterror();
616 if (!$error && !$notrigger) {
618 $result = $this->
call_trigger(
'MYOBJECT_VALIDATE', $user);
627 $this->oldref = $this->ref;
630 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
632 $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).
"'";
633 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'myobject/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
634 $resql = $this->db->query($sql);
636 $error++; $this->error = $this->db->lasterror();
638 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'myobject/".$this->db->escape($this->newref).
"'";
639 $sql .=
" WHERE filepath = 'myobject/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
640 $resql = $this->db->query($sql);
642 $error++; $this->error = $this->db->lasterror();
648 $dirsource = $conf->mymodule->dir_output.
'/myobject/'.$oldref;
649 $dirdest = $conf->mymodule->dir_output.
'/myobject/'.$newref;
650 if (!$error && file_exists($dirsource)) {
651 dol_syslog(get_class($this).
"::validate() rename dir ".$dirsource.
" into ".$dirdest);
653 if (@rename($dirsource, $dirdest)) {
656 $listoffiles =
dol_dir_list($conf->mymodule->dir_output.
'/myobject/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
657 foreach ($listoffiles as $fileentry) {
658 $dirsource = $fileentry[
'name'];
659 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
660 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
661 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
662 @rename($dirsource, $dirdest);
672 $this->status = self::STATUS_VALIDATED;
679 $this->db->rollback();
695 if ($this->status <= self::STATUS_DRAFT) {
706 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'MYMODULE_MYOBJECT_UNVALIDATE');
716 public function cancel($user, $notrigger = 0)
719 if ($this->status != self::STATUS_VALIDATED) {
730 return $this->
setStatusCommon($user, self::STATUS_CANCELED, $notrigger,
'MYMODULE_MYOBJECT_CANCEL');
740 public function reopen($user, $notrigger = 0)
743 if ($this->status == self::STATUS_VALIDATED) {
754 return $this->
setStatusCommon($user, self::STATUS_VALIDATED, $notrigger,
'MYMODULE_MYOBJECT_REOPEN');
766 global $conf, $langs;
771 return [
'optimize' => $langs->trans(
"ShowMyObject")];
773 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"MyObject").
'</u>';
774 if (isset($this->status)) {
775 $datas[
'picto'] .=
' '.$this->getLibStatut(5);
777 $datas[
'ref'] .=
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
792 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
794 global $conf, $langs, $hookmanager;
796 if (!empty($conf->dol_no_mouse_hover)) {
803 'objecttype' => $this->element.($this->module ?
'@'.$this->module :
''),
806 $classfortooltip =
'classfortooltip';
809 $classfortooltip =
'classforajaxtooltip';
810 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
816 $url =
dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.$this->id;
818 if ($option !==
'nolink') {
820 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
821 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
822 $add_save_lastsearch_values = 1;
824 if ($url && $add_save_lastsearch_values) {
825 $url .=
'&save_lastsearch_values=1';
830 if (empty($notooltip)) {
832 $label = $langs->trans(
"ShowMyObject");
833 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
835 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
836 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
838 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
841 if ($option ==
'nolink' || empty($url)) {
842 $linkstart =
'<span';
844 $linkstart =
'<a href="'.$url.
'"';
846 $linkstart .= $linkclose.
'>';
847 if ($option ==
'nolink' || empty($url)) {
848 $linkend =
'</span>';
853 $result .= $linkstart;
855 if (empty($this->showphoto_on_popup)) {
857 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), (($withpicto != 2) ?
'class="paddingright"' :
''), 0, 0, $notooltip ? 0 : 1);
861 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
863 list($class, $module) = explode(
'@', $this->picto);
866 $filename = $filearray[0][
'name'];
867 if (!empty($filename)) {
868 $pospoint = strpos($filearray[0][
'name'],
'.');
870 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
872 $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>';
874 $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>';
879 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'"'), 0, 0, $notooltip ? 0 : 1);
884 if ($withpicto != 2) {
885 $result .= $this->ref;
891 global $action, $hookmanager;
892 $hookmanager->initHooks(array($this->element.
'dao'));
893 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
894 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
896 $result = $hookmanager->resPrint;
898 $result .= $hookmanager->resPrint;
913 global $conf, $langs;
915 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
917 $return =
'<div class="box-flex-item box-flex-grow-zero">';
918 $return .=
'<div class="info-box info-box-sm">';
919 $return .=
'<span class="info-box-icon bg-infobox-action">';
921 $return .=
'</span>';
922 $return .=
'<div class="info-box-content">';
923 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
924 if ($selected >= 0) {
925 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
927 if (property_exists($this,
'label')) {
928 $return .=
' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.
'</div>';
930 if (property_exists($this,
'thirdparty') && is_object($this->thirdparty)) {
931 $return .=
'<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).
'</div>';
933 if (property_exists($this,
'amount')) {
935 $return .=
'<span class="info-box-label amount">'.price($this->amount, 0, $langs, 1, -1, -1, $conf->currency).
'</span>';
937 if (method_exists($this,
'getLibStatut')) {
938 $return .=
'<br><div class="info-box-status margintoponly">'.$this->getLibStatut(3).
'</div>';
955 return $this->
LibStatut($this->status, $mode);
966 return $this->
LibStatut($this->status, $mode);
980 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
983 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
984 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Enabled');
985 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Disabled');
986 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
987 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Enabled');
988 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Disabled');
991 $statusType =
'status'.$status;
993 if ($status == self::STATUS_CANCELED) {
994 $statusType =
'status6';
997 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
1008 $sql =
"SELECT rowid,";
1009 $sql .=
" date_creation as datec, tms as datem,";
1010 $sql .=
" fk_user_creat, fk_user_modif";
1011 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element.
" as t";
1012 $sql .=
" WHERE t.rowid = ".((int) $id);
1014 $result = $this->db->query($sql);
1016 if ($this->db->num_rows($result)) {
1017 $obj = $this->db->fetch_object($result);
1019 $this->
id = $obj->rowid;
1021 $this->user_creation_id = $obj->fk_user_creat;
1022 $this->user_modification_id = $obj->fk_user_modif;
1023 if (!empty($obj->fk_user_valid)) {
1024 $this->user_validation_id = $obj->fk_user_valid;
1026 $this->date_creation = $this->db->jdate($obj->datec);
1027 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
1028 if (!empty($obj->datev)) {
1029 $this->date_validation = empty($obj->datev) ?
'' : $this->db->jdate($obj->datev);
1033 $this->db->free($result);
1061 $this->lines = array();
1064 $result = $objectline->fetchAll(
'ASC',
'position', 0, 0, array(
'customsql'=>
'fk_myobject = '.((
int) $this->
id)));
1066 if (is_numeric($result)) {
1070 $this->lines = $result;
1071 return $this->lines;
1082 global $langs, $conf;
1083 $langs->load(
"mymodule@mymodule");
1086 $conf->global->MYMODULE_MYOBJECT_ADDON =
'mod_myobject_standard';
1096 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
1097 foreach ($dirmodels as $reldir) {
1101 $mybool |= @include_once $dir.$file;
1104 if ($mybool ===
false) {
1109 if (class_exists($classname)) {
1110 $obj =
new $classname();
1111 $numref = $obj->getNextValue($this);
1113 if ($numref !=
'' && $numref !=
'-1') {
1116 $this->error = $obj->error;
1121 print $langs->trans(
"Error").
" ".$langs->trans(
"ClassNotFound").
' '.$classname;
1125 print $langs->trans(
"ErrorNumberingModuleNotSetup", $this->element);
1141 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
1143 global $conf, $langs;
1146 $includedocgeneration = 0;
1148 $langs->load(
"mymodule@mymodule");
1151 $modele =
'standard_myobject';
1153 if (!empty($this->model_pdf)) {
1154 $modele = $this->model_pdf;
1160 $modelpath =
"core/modules/mymodule/doc/";
1162 if ($includedocgeneration && !empty($modele)) {
1163 $result = $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1194 $this->db->commit();
1201require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
1214 public $isextrafieldmanaged = 0;
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
fetchCommon($id, $ref=null, $morewhere='')
Load object in memory from the database.
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='')
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.
fetch($id, $ref=null)
Load object in memory from the 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 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.
fetchLines()
Load object lines in memory from the database.
update(User $user, $notrigger=false)
Update object into database.
info($id)
Load the info information in the object.
doScheduledJob()
Action executed by scheduler CAN BE A CRON TASK.
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 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.