28require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
40 public $module =
'quickmemo';
45 public $element =
'memo';
51 public $TRIGGER_PREFIX =
'QUICKMEMO_MEMO';
56 public $table_element =
'quickmemo_memo';
66 public $picto =
'fa-file';
71 public $isextrafieldmanaged = 0;
77 public $ismultientitymanaged = 1;
82 const STATUS_VALIDATED = 1;
83 const STATUS_CANCELED = 9;
84 const STATUS_ARCHIVED = 9;
134 "rowid" => array(
"type" =>
"integer",
"label" =>
"TechnicalID",
'enabled' => 1,
'position' => 1,
'notnull' => 1,
"visible" => 0,
'noteditable' => 1,
'index' => 1,
"css" =>
"left",
"comment" =>
"Id"),
135 "entity" => array(
"type" =>
"integer",
"label" =>
"Entity",
'enabled' => 1,
'position' => 2,
'notnull' => 1,
"visible" => 0,
'default' =>
'1',
'index' => 1),
136 "quick_note" => array(
"type" =>
"text",
"label" =>
"Note",
'enabled' => 1,
'position' => 61,
'notnull' => 0,
"visible" => -1,
"cssview" =>
"wordbreak",
"validate" => 1,),
137 "date_creation" => array(
"type" =>
"datetime",
"label" =>
"DateCreation",
'enabled' => 1,
'position' => 500,
'notnull' => 1,
"visible" => -2,),
138 "tms" => array(
"type" =>
"timestamp",
"label" =>
"DateModification",
'enabled' => 1,
'position' => 501,
'notnull' => 0,
"visible" => -2,),
139 "date_archived" => array(
"type" =>
"timestamp",
"label" =>
"DateArchived",
'enabled' => 1,
'position' => 502,
'notnull' => 0,
"visible" => -2,),
140 "fk_user_creat" => array(
"type" =>
"integer:User:user/class/user.class.php",
"label" =>
"UserAuthor",
"picto" =>
"user",
'enabled' => 1,
'position' => 510,
'notnull' => 1,
"visible" => -2,
"csslist" =>
"tdoverflowmax150",),
141 "fk_user_modif" => array(
"type" =>
"integer:User:user/class/user.class.php",
"label" =>
"UserModif",
"picto" =>
"user",
'enabled' => 1,
'position' => 511,
'notnull' => -1,
"visible" => -2,
"csslist" =>
"tdoverflowmax150",),
142 "fk_user_archived" => array(
"type" =>
"integer:User:user/class/user.class.php",
"label" =>
"ArchivedBy",
"picto" =>
"user",
'enabled' => 1,
'position' => 511,
'notnull' => -1,
"visible" => -2,
"csslist" =>
"tdoverflowmax150",),
143 "fk_element" => array(
'type' =>
'integer',
'label' =>
'MemoLinkedTo',
'help' =>
'MemoLinkedToHelp',
'enabled' => 1,
'visible' => 5,
'notnull' => 0,
'default' => 0,
'index' => 1,
'position' => 0),
144 "element_type" => array(
'type' =>
'varchar(64)',
'label' =>
'QuickMemoElementType',
'enabled' => 1,
'visible' => 5,
'position' => 10,
'required' => 0),
145 "pos_z" => array(
"type" =>
"integer",
"label" =>
"PosZ",
'enabled' => 1,
'position' => 1000,
'notnull' => 1,
"visible" => 0,
"default" => 0,
"validate" => 1),
146 "pos_y" => array(
"type" =>
"integer",
"label" =>
"PosY",
'enabled' => 1,
'position' => 1000,
'notnull' => 1,
"visible" => 0,
"default" => 0,
"validate" => 1),
147 "pos_x" => array(
"type" =>
"integer",
"label" =>
"PosX",
'enabled' => 1,
'position' => 1000,
'notnull' => 1,
"visible" => 0,
"default" => 0,
"validate" => 1),
148 "pos_w" => array(
"type" =>
"integer",
"label" =>
"PosW",
'enabled' => 1,
'position' => 1000,
'notnull' => 1,
"visible" => 0,
"default" => 0,
"validate" => 1),
149 "pos_h" => array(
"type" =>
"integer",
"label" =>
"PosH",
'enabled' => 1,
'position' => 1000,
'notnull' => 1,
"visible" => 0,
"default" => 0,
"validate" => 1),
150 "color" => array(
'type' =>
'varchar(10)',
'label' =>
'Color',
'enabled' => 1,
'visible' => 1,
'position' => 10,
'required' => 0),
151 "context_tab" => array(
'type' =>
'varchar(64)',
'label' =>
'ContextTab',
'enabled' => 1,
'visible' => 1,
'position' => 10,
'required' => 0),
152 "private" => array(
"type" =>
"integer",
"label" =>
"Private",
'enabled' => 1,
'position' => 1990,
'notnull' => 1,
"visible" => 1,
'index' => 1,
"arrayofkeyval" => array(0 =>
"No", 1 =>
"Yes"),
'default' => 1,
"validate" => 1,),
153 "private_tpl" => array(
"type" =>
"integer",
"label" =>
"PrivateTemplate",
'enabled' => 1,
'position' => 1990,
'notnull' => 0,
"visible" => 1,
'index' => 1,
"arrayofkeyval" => array(0 =>
"No", 1 =>
"Yes"),
'default' => 0,
"validate" => 1,),
154 "rank_tpl" => array(
"type" =>
"integer",
"label" =>
"TemplateRank",
'enabled' => 1,
'position' => 1990,
'notnull' => 0,
"visible" => 0,
'index' => 1,
'default' => 0,
"validate" => 1,),
155 "name_tpl" => array(
'type' =>
'varchar(256)',
'label' =>
'QuickMemoTemplateName',
'enabled' => 1,
'visible' => -1,
'position' => 1,
'required' => 0),
156 "shared_on_element" => array(
"type" =>
"integer",
"label" =>
"SharedBetweenElement",
'enabled' => 1,
'position' => 1991,
'notnull' => 1,
"visible" => 1,
'index' => 1,
"arrayofkeyval" => array(0 =>
"No", 1 =>
"Yes"),
"validate" => 1,),
157 "import_key" => array(
"type" =>
"varchar(14)",
"label" =>
"ImportId",
'enabled' => 1,
'position' => 1000,
'notnull' => -1,
"visible" => -2,),
158 "status" => array(
"type" =>
"integer",
"label" =>
"Status",
'enabled' => 1,
'position' => 2000,
'notnull' => 1,
"visible" => 1,
'index' => 1,
"arrayofkeyval" => array(1 =>
"Active",2 =>
"Template", 9 =>
"Archived"),
"validate" => 1,),
165 public $date_archived;
168 public $fk_user_archived;
183 public $element_type;
229 public $shared_on_element;
242 if (!
getDolGlobalInt(
'MAIN_SHOW_TECHNICAL_ID') && isset($this->fields[
'rowid']) && !empty($this->fields[
'ref'])) {
243 $this->fields[
'rowid'][
'visible'] = 0;
245 if (!
isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
246 $this->fields[
'entity'][
'enabled'] = 0;
250 foreach ($this->fields as $key => $val) {
251 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
252 unset($this->fields[$key]);
257 if (is_object($langs)) {
258 foreach ($this->fields as $key => $val) {
259 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
260 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
261 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
291 global $langs, $extrafields;
301 $result =
$object->fetchCommon($fromid);
302 if ($result > 0 && !empty(
$object->table_element_line)) {
312 $object->status = self::STATUS_VALIDATED;
316 $object->date_modification =
null;
320 if (is_array(
$object->array_options) && count(
$object->array_options) > 0) {
321 $extrafields->fetch_name_optionals_label($this->table_element);
322 foreach (
$object->array_options as $key => $option) {
323 $shortkey = preg_replace(
'/options_/',
'', $key);
324 if (!empty($extrafields->attributes[$this->table_element][
'unique'][$shortkey])) {
327 unset(
$object->array_options[$key]);
333 $object->context[
'createfromclone'] =
'createfromclone';
334 $result =
$object->createCommon($user);
340 unset(
$object->context[
'createfromclone']);
347 $this->db->rollback();
361 public function fetch($id, $ref =
null, $noextrafields = 0, $nolines = 0)
363 $result = $this->
fetchCommon($id, $ref,
'', $noextrafields);
364 if ($result > 0 && !empty($this->table_element_line) && empty($nolines)) {
378 $this->lines = array();
399 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 1000, $offset = 0,
string $filter =
'', $filtermode =
'AND')
407 $sql .=
" FROM ".$this->db->prefix().$this->table_element.
" as t";
408 if (!empty($this->isextrafieldmanaged) && $this->isextrafieldmanaged == 1) {
409 $sql .=
" LEFT JOIN ".$this->db->prefix().$this->table_element.
"_extrafields as te ON te.fk_object = t.rowid";
411 if (!empty($this->ismultientitymanaged) && (
int) $this->ismultientitymanaged == 1) {
412 $sql .=
" WHERE t.entity IN (".getEntity($this->element).
")";
413 } elseif (preg_match(
'/^\w+@\w+$/', (
string) $this->ismultientitymanaged)) {
414 $tmparray = explode(
'@', (
string) $this->ismultientitymanaged);
415 $sql .=
" LEFT JOIN ".$this->db->prefix().$this->db->sanitize($tmparray[1]).
" as pt ON t.".$this->db->sanitize($tmparray[0]).
" = pt.rowid";
416 $sql .=
" WHERE pt.entity IN (".getEntity($this->element).
")";
418 $sql .=
" WHERE 1 = 1";
425 $this->errors[] = $errormessage;
426 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
430 if (!empty($sortfield)) {
431 $sql .= $this->db->order($sortfield, $sortorder);
433 if (!empty($limit)) {
434 $sql .= $this->db->plimit($limit, $offset);
437 $resql = $this->db->query($sql);
439 $num = $this->db->num_rows($resql);
441 while ($i < ($limit ? min($limit, $num) : $num)) {
442 $obj = $this->db->fetch_object($resql);
444 $record =
new self($this->db);
445 $record->setVarsFromFetchObj($obj);
447 if (!empty($record->isextrafieldmanaged)) {
448 $record->fetch_optionals();
451 $records[$record->id] = $record;
455 $this->db->free($resql);
459 $this->errors[] =
'Error '.$this->db->lasterror();
460 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
492 if (empty($this->
id)) {
503 if ((
int) $this->fk_user_creat === (int) $user->id) {
510 if ($this->
update($user) <= 0) {
519 $sql =
'SELECT rowid';
520 $sql .=
' FROM '.$this->db->prefix().
'quickmemo_memo_user';
521 $sql .=
' WHERE fk_memo = '.((int) $this->
id);
522 $sql .=
' AND fk_user = '.((int) $user->id);
524 $resql = $this->db->query($sql);
529 if ($this->db->num_rows($resql) > 0) {
531 $sql =
'UPDATE '.$this->db->prefix().
'quickmemo_memo_user SET';
532 $sql .=
' pos_x = '. (int) $x.
',';
533 $sql .=
' pos_y = '. (int) $y.
',';
534 $sql .=
' pos_w = '. (int) $w.
',';
535 $sql .=
' pos_h = '. (int) $h.
',';
536 $sql .=
' pos_z = '. (int) $z;
537 $sql .=
' WHERE fk_memo = '.((int) $this->
id);
538 $sql .=
' AND fk_user = '.((int) $user->id);
540 if (!$this->db->query($sql)) {
545 $sql =
'INSERT INTO '.$this->db->prefix().
'quickmemo_memo_user (';
548 $sql .=
'date_creation,';
554 $sql .=
') VALUES (';
555 $sql .= ((int) $this->
id).
',';
556 $sql .= ((int) $user->id).
',';
557 $sql .=
'\''. $this->db->idate(
dol_now()) .
'\',
';
558 $sql .= (int) $x.',
';
559 $sql .= (int) $y.',
';
560 $sql .= (int) $w.',
';
561 $sql .= (int) $h.',
';
565 if (!$this->db->query($sql)) {
581 public function delete(User $user, $notrigger = 0)
583 // fetch() does not filter on entity, so an id of a memo of another entity may be provided (mass delete...)
584 if (!$this->isInCurrentEntity()) {
585 $this->error = 'ErrorRecordNotFound
';
589 return $this->deleteCommon($user, $notrigger);
590 //return $this->deleteCommon($user, $notrigger, 1);
601 public function deleteLine(User $user, $idline, $notrigger = 0)
603 if ($this->status < 0) {
604 $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus
';
608 return $this->deleteLineCommon($user, $idline, $notrigger);
619 public function validate($user, $notrigger = 0)
623 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php
';
628 if ($this->status == self::STATUS_VALIDATED) {
629 dol_syslog(get_class($this)."::validate action abandoned: already validated", LOG_WARNING);
633 /* if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS
') && $user->hasRight('quickmemo
', 'memo
', 'write'))
634 || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS
') && $user->hasRight('quickmemo
', 'memo_advance
', 'validate')))
636 $this->error='NotEnoughPermissions
';
637 dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
646 if (preg_match('/^[\(]?PROV/i
', $this->ref) || empty($this->ref)) { // empty should not happened, but when it occurs, the test save life
647 $num = $this->getNextNumRef();
649 $num = (string) $this->ref;
651 $this->newref = $num;
655 $sql = "UPDATE ".$this->db->prefix().$this->table_element;
657 if (!empty($this->fields['ref'])) {
658 $sql .= " ref = '".$this->db->escape($num)."',";
660 $sql .= " status = ".self::STATUS_VALIDATED;
661 if (!empty($this->fields['date_validation
'])) {
662 $sql .= ", date_validation = '".$this->db->idate($now)."'";
664 if (!empty($this->fields['fk_user_valid
'])) {
665 $sql .= ", fk_user_valid = ".((int) $user->id);
667 $sql .= " WHERE rowid = ".((int) $this->id);
669 dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
670 $resql = $this->db->query($sql);
672 dol_print_error($this->db);
673 $this->error = $this->db->lasterror();
677 if (!$error && !$notrigger) {
679 $result = $this->call_trigger('MEMO_VALIDATE
', $user);
688 $this->oldref = $this->ref;
690 // Rename directory if dir was a temporary ref
691 if (preg_match('/^[\(]?PROV/i
', $this->ref)) {
692 // Now we rename also files into index
693 $sql = 'UPDATE
'.$this->db->prefix()."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'memo/
".$this->db->escape($this->newref)."'";
694 $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%
' AND filepath = 'memo/
".$this->db->escape($this->ref)."' and entity = ".((int) $conf->entity);
695 $resql = $this->db->query($sql);
698 $this->error = $this->db->lasterror();
700 $sql = 'UPDATE
'.$this->db->prefix()."ecm_files set filepath = 'memo/
".$this->db->escape($this->newref)."'";
701 $sql .= " WHERE filepath = 'memo/
".$this->db->escape($this->ref)."' and entity = ".((int) $conf->entity);
702 $resql = $this->db->query($sql);
705 $this->error = $this->db->lasterror();
708 // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
709 $oldref = dol_sanitizeFileName($this->ref);
710 $newref = dol_sanitizeFileName($num);
711 $dirsource = $conf->quickmemo->dir_output.'/memo/
'.$oldref;
712 $dirdest = $conf->quickmemo->dir_output.'/memo/
'.$newref;
713 if (!$error && file_exists($dirsource)) {
714 dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
716 if (@rename($dirsource, $dirdest)) {
717 dol_syslog("Rename ok");
718 // Rename docs starting with $oldref with $newref
719 $listoffiles = dol_dir_list($conf->quickmemo->dir_output.'/memo/
'.$newref, 'files
', 1, '^
'.preg_quote($oldref, '/
'));
720 foreach ($listoffiles as $fileentry) {
721 $dirsource = $fileentry['name'];
722 $dirdest = preg_replace('/^
'.preg_quote($oldref, '/
').'/
', $newref, $dirsource);
723 $dirsource = $fileentry['path
'].'/
'.$dirsource;
724 $dirdest = $fileentry['path
'].'/
'.$dirdest;
725 @rename($dirsource, $dirdest);
732 // Set new ref and current status
735 $this->status = self::STATUS_VALIDATED;
742 $this->db->rollback();
755 public function setDraft($user, $notrigger = 0)
758 if ($this->status <= self::STATUS_VALIDATED) {
762 /* if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS
') && $user->hasRight('quickmemo
','write'))
763 || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS
') && $user->hasRight('quickmemo
','quickmemo_advance
','validate'))))
765 $this->error='Permission denied
';
769 return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'QUICKMEMO_MEMO_UNVALIDATE
');
780 public function setArchived($user, $notrigger = 0)
782 $this->date_archived = dol_now();
783 $this->fk_user_archived = $user->id;
784 $this->status = self::STATUS_ARCHIVED;
785 return $this->update($user, $notrigger);
796 public function setUnArchived($user, $notrigger = 0)
798 $this->date_archived = null;
799 $this->fk_user_archived = null;
800 $this->status = self::STATUS_VALIDATED;
801 return $this->update($user, $notrigger);
811 public function cancel($user, $notrigger = 0)
814 if ($this->status != self::STATUS_VALIDATED) {
818 /* if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS
') && $user->hasRight('quickmemo
','write'))
819 || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS
') && $user->hasRight('quickmemo
','quickmemo_advance
','validate'))))
821 $this->error='Permission denied
';
825 return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'QUICKMEMO_MEMO_CANCEL
');
835 public function reopen($user, $notrigger = 0)
838 if ($this->status == self::STATUS_VALIDATED) {
842 /*if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS
') && $user->hasRight('quickmemo
','write'))
843 || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS
') && $user->hasRight('quickmemo
','quickmemo_advance
','validate'))))
845 $this->error='Permission denied
';
849 return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'QUICKMEMO_MEMO_REOPEN
');
859 public function getTooltipContentArray($params)
865 if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
')) {
866 return ['optimize
' => $langs->trans("ShowMemo")];
868 $datas['picto
'] = img_picto('', $this->picto).' <u>
'.$langs->trans("Memo").'</u>
';
869 if (isset($this->status)) {
870 $datas['picto
'] .= ' '.$this->getLibStatut(5);
886 public function getNomUrl($withpicto = 0, $option = '
', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
888 global $conf, $langs, $hookmanager;
890 if (!empty($conf->dol_no_mouse_hover)) {
891 $notooltip = 1; // Force disable tooltips
896 'id' => (string) $this->id,
897 'objecttype
' => $this->element.($this->module ? '@
'.$this->module : ''),
900 $classfortooltip = 'classfortooltip
';
902 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP
')) {
903 $classfortooltip = 'classforajaxtooltip
';
904 $dataparams = ' data-params=
"'.dol_escape_htmltag(json_encode($params)).'"';
907 $label = implode($this->getTooltipContentArray($params));
910 $baseurl = dol_buildpath('/quickmemo/memo_card.php
', 1);
911 $query = ['id' => $this->id];
912 if ($option !== 'nolink
') {
913 // Add param to save lastsearch_values or not
914 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
915 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/
', $_SERVER["PHP_SELF"])) {
916 $add_save_lastsearch_values = 1;
918 if ($add_save_lastsearch_values) {
919 $query = array_merge($query, ['save_lastsearch_values
' => 1]);
922 $url = dolBuildUrl($baseurl, $query);
925 if (empty($notooltip)) {
926 if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER
')) {
927 $label = $langs->trans("ShowMemo");
928 $linkclose .= ' alt=
"'.dolPrintHTMLForAttribute($label).'"';
930 $linkclose .= ($label ? ' title=
"'.dolPrintHTMLForAttribute($label).'"' : ' title=
"tocomplete"');
931 $linkclose .= $dataparams.' class=
"'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
933 $linkclose = ($morecss ? ' class=
"'.$morecss.'"' : '');
936 if ($option == 'nolink
') {
937 $linkstart = '<span
';
939 $linkstart = '<a href=
"'.$url.'"';
941 $linkstart .= $linkclose.'>
';
942 if ($option == 'nolink
') {
943 $linkend = '</span>
';
948 $result .= $linkstart;
950 if (empty($this->showphoto_on_popup)) {
952 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class=
"paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
956 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php
';
958 [$class, $module] = explode('@
', $this->picto);
959 $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
960 $filearray = dol_dir_list($upload_dir, "files");
961 $filename = $filearray[0]['name'];
962 if (!empty($filename)) {
963 $pospoint = strpos($filearray[0]['name'], '.
');
965 $pathtophoto = $class.'/
'.$this->ref.'/thumbs/
'.dol_substr($filename, 0, $pospoint).'_mini
'.dol_substr($filename, $pospoint);
966 if (!getDolGlobalString(strtoupper($module.'_
'.$class).'_FORMATLISTPHOTOSASUSERS
')) {
967 $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>
';
969 $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>
';
974 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class=
"paddingright"' : '') : 'class=
"'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1);
979 if ($withpicto != 2) {
980 $result .= $this->ref;
984 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
986 global $action, $hookmanager;
987 $hookmanager->initHooks(array($this->element.'dao
'));
988 $parameters = array('id' => $this->id, 'getnomurl
' => &$result);
989 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
991 $result = $hookmanager->resPrint;
993 $result .= $hookmanager->resPrint;
1006 public function getKanbanView($option = '
', $arraydata = null)
1008 global $conf, $langs;
1010 $selected = (empty($arraydata['selected
']) ? 0 : $arraydata['selected
']);
1012 $return = '<div
class=
"box-flex-item box-flex-grow-zero">
';
1013 $isDarkMode = !empty($this->color) && !colorIsLight($this->color) ? '--memo-is-dark
' : '';
1014 $style = !empty($this->color) && Memo::checkColor($this->color) ? ' style=
"--memo-color : '.$this->color.'" ' : '';
1015 $return .= '<div
class=
"info-box-quickmemo '.$isDarkMode.'" '.$style.' >
';
1016 $return .= '<div
class=
"info-box-content-quickmemo">
';
1018 $return .= '<span
class=
"info-box-status">
'.$this->getLibStatut(4).'</span>
';
1020 // $return .= '<span
class=
"info-box-ref inline-block tdoverflowmax150 valignmiddle">
'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>
';
1021 if ($selected >= 0) {
1022 $return .= '<input
id=
"cb'.$this->id.'" class=
"flat checkforselect fright" type=
"checkbox" name=
"toselect[]" value=
"'.$this->id.'"'.($selected ? ' checked=
"checked"' : '').'>
';
1027 $return .= ' <div
class=
"info-box-content-quicknote">
';
1028 $return .= nl2br(htmlentities($this->quick_note));
1029 $return .= '</div>
';
1031 $return .= '<div
class=
"quickmemo-info" >
';
1032 $return .= ' <div
class=
"quickmemo-info__create" >
';
1033 $return .= ' <span
class=
"quickmemo-info__user-create-name">
'.$this->showOutputField($this->fields['fk_user_creat
'], 'fk_user_creat
', $this->user_creation_id).'</span>
';
1034 $return .= ' <span
class=
"quickmemo-info__date_create">
'.dol_print_date($this->date_creation, '%d/%m/%Y %H:%M
', 'tzuserrel
').'</span>
';
1035 $return .= ' </div>
';
1038 if (!empty($this->tms) && $this->tms != $this->date_creation) {
1039 $return .= ' <div class=
"quickmemo-info__update" >
';
1041 $return .= ' <span class=
"quickmemo-info__date_update">
'.$langs->trans('QuickMemoModified
') . ' ' .dol_print_date($this->date_modification, '%d/%m/%Y %H:%M
', 'tzuserrel
').'</span>
';
1042 if ($this->user_modification_id != $this->user_creation_id) {
1043 $return .= ' <span class=
"quickmemo-info__user-update-name">
'.$langs->trans('QuickMemoBy
') . ' ' .$this->showOutputField($this->fields['fk_user_modif
'], 'fk_user_modif
', $this->user_modification_id).'</span>
';
1046 $return .= ' </div>
';
1049 if (!empty($this->date_archived) && $this->status == self::STATUS_ARCHIVED) {
1050 $return .= ' <div class=
"quickmemo-info__update" >
';
1052 $return .= ' <span class=
"quickmemo-info__date_update">
'.$langs->trans('QuickMemoArchived
') . ' ' .dol_print_date($this->date_archived, '%d/%m/%Y %H:%M
', 'tzuserrel
').'</span>
';
1053 if ($this->fk_user_modif != $this->fk_user_archived) {
1054 $return .= ' <span class=
"quickmemo-info__user-update-name">
'.$langs->trans('QuickMemoBy
') . ' ' .$this->showOutputField($this->fields['fk_user_archived
'], 'fk_user_archived
', $this->fk_user_archived).'</span>
';
1057 $return .= ' </div>
';
1060 $return .= '</div>
';
1065 $return .= '</div>
';
1066 $return .= '</div>
';
1067 $return .= '</div>
';
1078 public function getLabelStatus($mode = 0)
1080 return $this->LibStatut($this->status, $mode);
1089 public function getLibStatut($mode = 0)
1091 return $this->LibStatut($this->status, $mode);
1094 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1102 public function LibStatut($status, $mode = 0)
1105 if (is_null($status)) {
1109 $paramsBadge = array('badgeParams
' => array('attr
' => array(
1110 'data-
status-element
' => $this->element,
1111 'data-
status' => (int) $status
1115 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1117 //$langs->load("quickmemo");
1118 $this->labelStatus[self::STATUS_TPL] = $langs->transnoentitiesnoconv('Template
');
1119 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled
');
1120 $this->labelStatus[self::STATUS_ARCHIVED] = $langs->transnoentitiesnoconv('Archived
');
1121 $this->labelStatusShort[self::STATUS_TPL] = $langs->transnoentitiesnoconv('Template
');
1122 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled
');
1123 $this->labelStatusShort[self::STATUS_ARCHIVED] = $langs->transnoentitiesnoconv('Archived
');
1126 $statusType = 'status'.$status;
1127 //if ($status == self::STATUS_VALIDATED) $statusType = 'status1
';
1128 if ($status == self::STATUS_ARCHIVED) {
1129 $statusType = 'status6
';
1132 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode, '', $paramsBadge);
1141 public function info($id)
1143 $sql = "SELECT t.rowid, t.date_creation as datec";
1144 if (!empty($this->isextrafieldmanaged) && $this->isextrafieldmanaged == 1) {
1145 $sql .= ", GREATEST(t.tms, te.tms) as datem";
1147 $sql .= ", t.tms as datem";
1149 if (!empty($this->fields['date_validation
'])) {
1150 $sql .= ", t.date_validation as datev";
1152 if (!empty($this->fields['fk_user_creat
'])) {
1153 $sql .= ", t.fk_user_creat";
1155 if (!empty($this->fields['fk_user_modif
'])) {
1156 $sql .= ", t.fk_user_modif";
1158 if (!empty($this->fields['fk_user_valid
'])) {
1159 $sql .= ", t.fk_user_valid";
1161 $sql .= " FROM ".$this->db->prefix().$this->table_element." as t";
1162 if (!empty($this->isextrafieldmanaged) && $this->isextrafieldmanaged == 1) {
1163 $sql .= " LEFT JOIN ".$this->db->prefix().$this->table_element."_extrafields as te ON te.fk_object = t.rowid";
1165 $sql .= " WHERE t.rowid = ".((int) $id);
1167 $result = $this->db->query($sql);
1169 if ($this->db->num_rows($result)) {
1170 $obj = $this->db->fetch_object($result);
1172 $this->id = $obj->rowid;
1174 if (!empty($this->fields['fk_user_creat
'])) {
1175 $this->user_creation_id = $obj->fk_user_creat;
1177 if (!empty($this->fields['fk_user_modif
'])) {
1178 $this->user_modification_id = $obj->fk_user_modif;
1180 if (!empty($this->fields['fk_user_valid
'])) {
1181 $this->user_validation_id = $obj->fk_user_valid;
1183 $this->date_creation = $this->db->jdate($obj->datec);
1184 $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
1185 if (!empty($obj->datev)) {
1186 $this->date_validation = empty($obj->datev) ? '' : $this->db->jdate($obj->datev);
1190 $this->db->free($result);
1192 dol_print_error($this->db);
1202 public function initAsSpecimen()
1204 // Set here init that are not commonf fields
1205 // $this->property1 = ...
1206 // $this->property2 = ...
1208 return $this->initAsSpecimenCommon();
1217 public function getNextNumRef()
1233 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
1244 public static function checkColor($color)
1246 if (!is_string($color)) {
1250 // Remove spaces at the beginning/end
1251 $color = trim($color);
1253 // Checks for #fff or #ffffff
1254 return preg_match('/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/
', $color) === 1;
1262 public static function getColorPreset()
1265 $colorsConf = getDolGlobalString('QUICKMEMO_COLORS_PRESET
');
1266 $colors = explode(',
', $colorsConf);
1267 if (!empty($colors)) {
1268 foreach ($colors as $iColor => $color) {
1269 if (!preg_match('/^#[a-f0-9]{6}$/i
', $color)) {
1270 unset($colors[$iColor]);
1275 if (empty($colors)) {
1276 $colors = ['#fff8a6
', '#ffd6d6
', '#d6ffd9
', '#d6e6ff
', '#f3d6ff
', '#ffffff
', '#f5f5f5
'];
1279 return array_values($colors);
1290 public static function getMemoContext($context, $object = null)
1292 global $db,$action, $hookmanager;
1294 if (!isModEnabled('quickmemo
')) {
1298 if (!is_array($context)) {
1299 $context = explode(':
', $context);
1302 $contextMapping = self::getAvailableMemoContextMapping();
1305 foreach ($contextMapping as $key => $values) {
1306 $values = (array) $values;
1308 if (array_intersect($context, $values)) {
1309 $memoContext = $key;
1314 $staticMemo = new self($db);
1316 $hookmanager->initHooks(array($staticMemo->element.'dao
'));
1317 $parameters = array(
1318 'memoContext
' => & $memoContext
1321 $reshook = $hookmanager->executeHooks('getMemoContext', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
1323 return $hookmanager->resPrint;
1326 return $memoContext;
1336 public static function completeMemoContextMapping(array &$contextTabMapping, string $tabContext, string $dolibarrContext = '
')
1338 $dolibarrContext = trim($dolibarrContext) ?: $tabContext;
1340 if (!isset($contextTabMapping[$tabContext])) {
1341 $contextTabMapping[$tabContext] = [$dolibarrContext];
1345 if (!in_array($dolibarrContext, $contextTabMapping[$tabContext], true)) {
1346 $contextTabMapping[$tabContext][] = $dolibarrContext;
1358 public static function getAvailableMemoContextMapping($object = null, $onlyActiveModules = true)
1360 global $db,$action, $hookmanager;
1362 $contextTabMapping = [];
1364 // Start Correction of no standard Dolibarr context and special context
1365 if (isModEnabled('propal
') || !$onlyActiveModules) {
1366 self::completeMemoContextMapping($contextTabMapping, 'contactcard
', 'proposalcontactcard
');
1369 if (isModEnabled('supplier_order
') || !$onlyActiveModules) {
1370 self::completeMemoContextMapping($contextTabMapping, 'contactcard
', 'ordersuppliercontactcard
');
1371 self::completeMemoContextMapping($contextTabMapping, 'document
', 'ordersuppliercarddocument
');
1372 self::completeMemoContextMapping($contextTabMapping, 'agenda
', 'ordersuppliercardinfo
');
1373 self::completeMemoContextMapping($contextTabMapping, 'ordersupplierdispatch
');
1376 if (isModEnabled('contract
') || !$onlyActiveModules) {
1377 self::completeMemoContextMapping($contextTabMapping, 'agenda
', 'agendacontract
');
1380 if (isModEnabled('order
') || !$onlyActiveModules) {
1381 self::completeMemoContextMapping($contextTabMapping, 'ordershipmentcard
');
1384 if (isModEnabled('shipping
')) {
1385 self::completeMemoContextMapping($contextTabMapping, 'contactcard
', 'shipmentcontactcard
');
1388 if (isModEnabled('product
')) {
1389 self::completeMemoContextMapping($contextTabMapping, 'productpricecard
');
1390 self::completeMemoContextMapping($contextTabMapping, 'pricesuppliercard
');
1391 self::completeMemoContextMapping($contextTabMapping, 'producttranslationcard
');
1392 self::completeMemoContextMapping($contextTabMapping, 'productcompositioncard
');
1393 self::completeMemoContextMapping($contextTabMapping, 'stockproductcard
');
1394 self::completeMemoContextMapping($contextTabMapping, 'productstatsinvoice
');
1395 self::completeMemoContextMapping($contextTabMapping, 'productstatscard
');
1396 self::completeMemoContextMapping($contextTabMapping, 'tabproductmarginlist
');
1399 // End of corrections
1401 // Generate standard context
1402 // TODO : Common contexts such as document, agenda, contact card, and stat, which are used across most Dolibarr objects, are not defined as standard global contexts.
1403 // Instead of having dedicated contexts like global_document, global_agenda, global_contactcard, or global_stat (similar to global_card), pages currently mix global_card with object-specific contexts (e.g. product_document, propal_agenda, etc.).
1404 // This creates inconsistent context handling. These contexts should include both their object-specific context and a proper global context (e.g. global_document or global_agenda) depending on the active tab.
1405 $commonCardContext = ['document
', 'agenda
', 'contactcard
', 'stats
']; // for common object
1406 $modules = ['order
', 'propal
', 'invoice
', 'supplier_proposal
', 'supplier_order
', 'supplier_invoice
', 'contract
', 'product
', 'shipping
'];
1407 foreach ($modules as $module) {
1408 if (!isModEnabled($module) && $onlyActiveModules) {
1412 $moduleClean = str_replace('_
', '', $module);
1414 foreach ($commonCardContext as $context) {
1415 self::completeMemoContextMapping($contextTabMapping, $context, $moduleClean.$context);
1419 if (!empty($object) && !empty($object->element)) {
1420 foreach ($commonCardContext as $context) {
1421 self::completeMemoContextMapping($contextTabMapping, $context, $object->element.$context);
1425 // Need to be at end of tests
1426 self::completeMemoContextMapping($contextTabMapping, 'index
');
1427 self::completeMemoContextMapping($contextTabMapping, 'card
', 'globalcard
');
1429 $staticMemo = new self($db);
1430 $hookmanager->initHooks(array($staticMemo->element.'dao
'));
1431 $parameters = array(
1432 'contextTabMapping
' => & $contextTabMapping,
1433 'onlyActiveModules
' => $onlyActiveModules
1436 $reshook = $hookmanager->executeHooks('getAvailableMemoContextMapping', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
1438 return $hookmanager->resArray;
1441 return $contextTabMapping;
1450 public static function getAvailableMemoContext()
1452 global $db,$action, $hookmanager;
1454 $contextMapping = self::getAvailableMemoContextMapping();
1455 $list = array_keys($contextMapping);
1457 $staticMemo = new self($db);
1458 $hookmanager->initHooks(array($staticMemo->element.'dao
'));
1459 $parameters = array(
1462 $object = null; // @phan-suppress-next-line PhanPluginConstantVariableNull
1463 $reshook = $hookmanager->executeHooks('getAvailableMemoContext', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
1465 $list = $hookmanager->resArray;
1470 foreach ($list as $k => $v) {
1471 if (!is_string($v)) {
1474 if (strlen($v) > 64) {
1477 if (preg_match('/^[a-zA-Z0-9_]+$/
', $k) !== 1) {
1497 public function countArchivedMemoQuery($element_type, $element_id, $context, $id = 0)
1501 $sql = 'SELECT COUNT(m.rowid) nb
1502 FROM '.MAIN_DB_PREFIX.$this->table_element.' m
1504 AND m.element_type = \''.$this->db->escape($element_type).'\'
1505 AND ( m.fk_element = '.(
int) $element_id.' OR m.shared_on_element = 1 )
1506 AND m.context_tab = \''.$this->db->escape($context).'\'
1508 AND (m.private = 0 OR m.fk_user_creat = '.(
int) $user->
id.')
1511 if ((
int) $id > 0) {
1512 $sql .=
' AND m.rowid = ' . (int)
$id;
1515 $obj = $this->db->getRow($sql);
1520 return (
int) $obj->nb;
1537 $sql =
'SELECT m.rowid, m.quick_note, m.pos_x, m.pos_y, m.pos_w, m.pos_h, m.pos_z, m.color, m.fk_user_creat, m.fk_user_modif, m.shared_on_element, m.date_creation, m.tms, m.private,
1538 mu.pos_x as user_pos_x, mu.pos_y as user_pos_y, mu.pos_w as user_pos_w, mu.pos_h as user_pos_h, mu.pos_z as user_pos_z
1539 FROM '.MAIN_DB_PREFIX.$this->table_element.
' m
1540 LEFT JOIN '.MAIN_DB_PREFIX.$this->table_element.
'_user mu
1541 ON mu.fk_memo = m.rowid
1542 AND mu.fk_user = '.(int) $user->id.
'
1543 WHERE m.entity IN ('.
getEntity(self::getEntityElementKey($element_type)).
')
1544 AND m.element_type = \''.$this->db->escape($element_type).
'\'
1545 AND ( m.fk_element =
'.(int) $element_id.' OR m.shared_on_element = 1 )
1546 AND m.context_tab = \
''.$this->db->escape($context).
'\'
1547 AND m.status =
'.self::STATUS_VALIDATED.'
1548 AND (COALESCE(m.private, 0) = 0 OR m.fk_user_creat =
'.(int) $user->id.')
1551 if ((int) $id > 0) {
1552 $sql .= ' AND m.rowid =
' . (int) $id;
1555 $sql .= ' ORDER BY COALESCE(mu.pos_z, m.pos_z) ASC
';
1569 public function getTemplateMemosQuery($element_type, $context_tab = '
', $id = 0)
1573 $sql = 'SELECT m.rowid, m.quick_note, m.pos_x, m.pos_y, m.pos_w, m.pos_h, m.color, m.pos_z,
1574 m.fk_user_creat, m.fk_user_modif, m.shared_on_element, m.date_creation, m.tms, m.private, m.name_tpl,m.rank_tpl,
1575 mu.pos_x as user_pos_x, mu.pos_y as user_pos_y, mu.pos_w as user_pos_w, mu.pos_h as user_pos_h, mu.pos_z as user_pos_z
1576 FROM
'.MAIN_DB_PREFIX.$this->table_element.' m
1577 LEFT JOIN
'.MAIN_DB_PREFIX.$this->table_element.'_user mu
1578 ON mu.fk_memo = m.rowid
1579 AND mu.fk_user =
'.(int) $user->id.'
1580 WHERE m.entity IN (
'.getEntity($this->element).')
1581 AND m.element_type IN (\''.$this->db->escape($element_type).'\', \'\')
1582 AND m.
status = '.self::STATUS_TPL.'
1583 AND (COALESCE(m.private_tpl, 0) = 0 OR m.fk_user_creat = '.(
int) $user->
id.')
1586 if (!empty($context_tab)) {
1590 if ((
int) $id > 0) {
1591 $sql .=
' AND m.rowid = ' . (int) $id;
1594 $sql .=
" ORDER BY m.rank_tpl DESC, m.rowid ASC ";
1612 public function showOutputField($val, $key, $value, $moreparam =
'', $keysuffix =
'', $keyprefix =
'', $morecss =
'')
1614 global
$conf, $langs, $form;
1616 if ($key ==
'color' && self::checkColor($value)) {
1617 $badgeBase =
colorIsLight($value) ?
'badge-light' :
'badge-dark';
1618 return '<span class="badge badge-pill '.$badgeBase.
'" style="background-color: '.$value.
'" >'.$value.
'</span>';
1621 if ($key ==
'quick_note') {
1622 return nl2br(htmlentities($value));
1625 return parent::showOutputField($val, $key, $value, $moreparam, $keysuffix, $keyprefix, $morecss);
1643 if (defined(
'QUICKMEMOJS')) {
1647 if (defined(
'NOREQUIRETRAN') || empty($user) || empty($user->id) || (
int) $user->socid > 0) {
1651 if (!$user->hasRight(
'quickmemo',
'memo',
'read')) {
1656 if (!empty($jsConfVars[
'elementType'])) {
1657 require_once __DIR__.
'/../lib/quickmemo.lib.php';
1663 $autoResizeFontMin =
getDolGlobalFloat(
'QUICKMEMO_AUTO_RESIZE_MIN_FONT_SIZE', 1);
1664 $autoResizeFontMax =
getDolGlobalFloat(
'QUICKMEMO_AUTO_RESIZE_MAX_FONT_SIZE', 1.4);
1667 $autoResizeFontMin = max($autoResizeFontMin, 0.3);
1668 $autoResizeFontMax = min($autoResizeFontMax, 5);
1671 if ($autoResizeFontMin >= $autoResizeFontMax) {
1672 $autoResizeFontMin = max(0.3, $autoResizeFontMax - 0.1);
1675 $defaultJsConfVars = [
1676 'interfaceUrl' =>
dol_buildpath(
'quickmemo/interface.php', 1),
1677 'archivesUrl' =>
dol_buildpath(
'quickmemo/memo_list.php', 1) .
'?mode=kanban&search_status='.Memo::STATUS_ARCHIVED . ($jsConfVars[
'archivesUrlParams'] ??
''),
1679 'elementType' =>
'',
1683 'userReadRight' => $user->hasRight(
'quickmemo',
'memo',
'read'),
1684 'userWriteRight' => $user->hasRight(
'quickmemo',
'memo',
'write'),
1685 'userDeleteRight' => $user->hasRight(
'quickmemo',
'memo',
'delete'),
1686 'autoResizeFontSize' => !
getDolGlobalInt(
'QUICKMEMO_DISABLE_AUTO_RESIZE_FONT_SIZE'),
1687 'autoResizeFontMin' => $autoResizeFontMin,
1688 'autoResizeFontMax' => $autoResizeFontMax,
1690 $jsConfVars = array_merge($defaultJsConfVars, $jsConfVars);
1692 if (!empty($jsConfVars[
'elementType'])) {
1693 $jsConfVars[
'shareBtnStatus'] = 1;
1697 print
'<link rel="stylesheet" type="text/css" href="'.dol_buildpath(
'quickmemo/css/memo.css', 1) .
'">'.
"\n";
1698 print
'<link rel="stylesheet" type="text/css" href="'.dol_buildpath(
'quickmemo/css/memo-dialog.css', 1) .
'">'.
"\n";
1699 print
'<script nonce="'.getNonce().
'" src="'.
dol_buildpath(
'quickmemo/js/QuickMemo.js', 1).
'" ></script>'.
"\n";
1701 print
'<script nonce="'.getNonce().
'">
1702 document.addEventListener(\'Dolibarr:Ready\', function() {
1703 if(!Dolibarr.checkToolExist(\'quickMemo\')) {
1704 Dolibarr.defineTool(\'quickMemo\', new QuickMemo('.json_encode($jsConfVars).
') );
1709 define(
'QUICKMEMOJS',
true);
1725 $memo->id = $this->id;
1726 $memo->color = $this->color;
1727 $memo->note = $this->quick_note;
1729 $memo->pos_x = (int) $this->pos_x;
1730 $memo->pos_y = (int) $this->pos_y;
1731 $memo->pos_w = (int) $this->pos_w;
1732 $memo->pos_h = (int) $this->pos_h;
1734 if ($currentUser->id != $memo->fk_user_creat) {
1738 $memo->shared_on_element = $this->shared_on_element;
1739 $memo->private = (int) $this->
private;
1740 $memo->date_creation =
dol_print_date($this->date_creation,
'%d/%m/%Y %H:%M',
'tzuserrel');
1741 $memo->date_change =
'';
1742 if (!empty($this->tms) && ((
int) $this->date_creation !== (
int) $this->tms || (
int) $this->fk_user_modif > 0)) {
1743 $memo->date_change =
dol_print_date($this->tms,
'%d/%m/%Y %H:%M',
'tzuserrel');
1746 $memo->fk_user_creat = $this->fk_user_creat;
1747 $memo->user_name =
'';
1748 if ((
int) $this->fk_user_creat > 0) {
1749 $userCreate =
new User($this->db);
1750 if ($userCreate->fetch((
int) $this->fk_user_creat) > 0) {
1751 $memo->user_name = $userCreate->getFullName($langs);
1755 $memo->fk_user_modif = $this->fk_user_modif;
1756 $memo->user_change_name =
'';
1757 if ((
int) $this->fk_user_modif > 0) {
1758 $userMod =
new User($this->db);
1759 if ($userMod->fetch((
int) $this->fk_user_modif) > 0) {
1760 $memo->user_change_name = $userMod->getFullName($langs);
1781 return in_array((
int) $this->entity, array_map(
'intval', explode(
',',
getEntity($entityKey))),
true);
1794 return empty($element_type) ?
'memo' : $element_type;
1806 $memo->color =
null;
1812 $memo->shared_on_element = 0;
1814 $memo->date_creation =
'';
1815 $memo->date_change =
'';
1816 $memo->fk_user_creat =
null;
1817 $memo->user_name =
'';
1818 $memo->fk_user_modif =
null;
1819 $memo->user_change_name =
'';
write(string $newInnerBlock)
Replace the whole permissions block, markers included, in a single write.
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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.
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.
Class to manage Dolibarr database access.
static loadQuickMemoJsInterface($jsConfVars)
Load the Javascript interface for QuickMemo.
$fields
'type' field format: 'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortf...
static getAvailableMemoContext()
Get available memo context.
createFromClone(User $user, $fromid)
Clone an object into another one.
create(User $user, $notrigger=0)
Create object into database.
static getAvailableMemoContextMapping($object=null, $onlyActiveModules=true)
Get available memo context.
fetchAll($sortorder='', $sortfield='', $limit=1000, $offset=0, string $filter='', $filtermode='AND')
Load list of objects in memory from the database.
getJsMemo(User $currentUser)
Get JS memo.
update(User $user, $notrigger=0)
Update object into database.
static getJsMemoDefault()
Get JS memo default.
showOutputField($val, $key, $value, $moreparam='', $keysuffix='', $keyprefix='', $morecss='')
Return HTML string to show a field into a page Code very similar with showOutputField of extra fields...
getMemosQuery($element_type, $element_id, $context, $id=0)
Get memos query.
fetch($id, $ref=null, $noextrafields=0, $nolines=0)
Load object in memory from the database.
__construct(DoliDB $db)
Constructor.
fetchLines($noextrafields=0)
Load object lines in memory from the database.
static getMemoContext($context, $object=null)
Get memo context.
isInCurrentEntity()
Check that the memo (loaded with fetch(), which does not filter on entity) belongs to an entity visib...
static getColorPreset()
Get color preset.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
static getEntityElementKey($element_type)
Element key to use with getEntity() for memos of an element type.
validate($user, $notrigger=0)
Validate object.
updatePosition(User $user, int $x, int $y, int $w, int $h, int $z)
Update position of a memo for a specific user.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
dol_now($mode='gmt')
Return date for now.
getDolGlobalFloat($key, $default=0)
Return a Dolibarr global constant float value.
currentToken()
Return the value of token currently saved into session with name 'token'.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0, $forbiddenfields=array())
forgeSQLFromUniversalSearchCriteria
colorIsLight($stringcolor)
Return true if the color is light.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
Build the customer statement lines (invoices and payments) with running balance.
quickMemoInterfaceCanAccessElement($element_type, $element_id, $moduleLevelOnly=false)
Check that current user can read the object a memo is attached to.
$conf db name
Only used if Module[ID]Name translation string is not found.