25if (!defined(
'NOTOKENRENEWAL')) define(
'NOTOKENRENEWAL',
'1');
27if (!defined(
'NOREQUIREMENU')) define(
'NOREQUIREMENU',
'1');
28if (!defined(
'NOREQUIREHTML')) define(
'NOREQUIREHTML',
'1');
34if (! defined(
"NOREDIRECTBYMAINTOLOGIN")) define(
'NOREDIRECTBYMAINTOLOGIN', 1);
41require
'../main.inc.php';
49require_once DOL_DOCUMENT_ROOT .
'/core/class/jsonResponse.class.php';
50require_once __DIR__ .
'/class/memo.class.php';
51require_once __DIR__ .
'/lib/quickmemo.lib.php';
52if (!class_exists(
'Validate')) {
53 require_once DOL_DOCUMENT_ROOT .
'/core/class/validate.class.php';
57$hookmanager->initHooks([
'quickmemoInterface']);
60$langs->loadLangs([
"quickmemo",
"other",
'main']);
70if (!$user || !$user->hasRight(
'quickmemo',
'memo',
'read')) {
71 $jsonResponse->setError($langs->trans(
'NotEnoughRights'), JsonResponse::HTTP_FORBIDDEN);
72 $jsonResponse->output();
76if ($user->socid > 0) {
77 $jsonResponse->setError($langs->trans(
'NotEnoughRights'), JsonResponse::HTTP_FORBIDDEN);
78 $jsonResponse->output();
82$reshook = $hookmanager->executeHooks(
'quickMemoInterface', [], $jsonResponse, $action);
84 $errMsg = $hookmanager->error;
85 if (!empty($hookmanager->errors)) {
86 $errMsg.= (!empty($hookmanager->error) ?
'<br>' :
'') . implode(
'<br>', $hookmanager->errors);
88 $jsonResponse->setError($errMsg);
89 $jsonResponse->output();
95} elseif ($action ===
'update_position') {
96 quickMemoIntefaceActionUpdatePosition($jsonResponse);
97} elseif ($action ===
'update_all_positions') {
98 quickMemoIntefaceActionUpdateAllPositions($jsonResponse);
99} elseif ($action ===
'list') {
100 quickMemoIntefaceActionList($jsonResponse);
101} elseif ($action ===
'list_models') {
102 quickMemoIntefaceActionListModels($jsonResponse);
103} elseif ($action ===
'update-color') {
104 quickMemoIntefaceActionUpdateColor($jsonResponse);
105} elseif ($action ===
'update-shared-on-element') {
106 quickMemoIntefaceActionUpdateSharedOnElement($jsonResponse);
107} elseif ($action ===
'update-private') {
108 quickMemoIntefaceActionUpdatePrivate($jsonResponse);
109} elseif ($action ===
'archive') {
110 quickMemoIntefaceActionArchiveNote($jsonResponse);
111} elseif ($action ===
'delete') {
112 quickMemoIntefaceActionDeleteNote($jsonResponse);
113} elseif ($action ===
'create') {
114 quickMemoIntefaceActionCreate($jsonResponse);
115} elseif ($action ===
'create_model') {
116 quickMemoIntefaceActionCreateModel($jsonResponse);
117} elseif ($action ===
'delete_model') {
118 quickMemoIntefaceActionDeleteModel($jsonResponse);
119} elseif ($action ===
'update_model_rank') {
120 quickMemoIntefaceActionUpdateModelRank($jsonResponse);
121} elseif ($action ===
'update_note') {
122 quickMemoIntefaceActionUpdateNote($jsonResponse);
124 $jsonResponse->setError($langs->trans(
'ErrorActionNotFound'));
127$jsonResponse->output();
134function quickMemoIntefaceActionUpdatePosition($jsonResponse)
136 global $user, $langs, $db;
139 if (!$user->hasRight(
'quickmemo',
'memo',
'read')) {
140 $jsonResponse->setError($langs->trans(
'NotEnoughRights'), JsonResponse::HTTP_FORBIDDEN);
145 $memo = quickMemoInterfaceFetchMemo($jsonResponse,
'QuickMemoCantMoveThisPrivateNote');
156 if (!$memo->updatePosition($user, (
int) $x, (
int) $y, (
int) $w, (
int) $h, (
int) $z)) {
157 $jsonResponse->setError($langs->trans(
'UpdateError') .
' : ' . $memo->errorsToString(), JsonResponse::HTTP_INTERNAL_ERROR);
160 $jsonResponse->setSuccess();
161 $jsonResponse->data =
null;
171function quickMemoIntefaceActionUpdateAllPositions($jsonResponse)
173 global $user, $langs, $db;
177 if (!$user->hasRight(
'quickmemo',
'memo',
'read')) {
178 $jsonResponse->setError($langs->trans(
'NotEnoughRights'), JsonResponse::HTTP_FORBIDDEN);
182 $json = file_get_contents(
'php://input');
183 $data = json_decode($json,
true);
185 if (!is_array($data) || empty($data[
'memos'])) {
186 $jsonResponse->setError($langs->trans(
'ErrorNoDataReceived'));
192 foreach ($data[
'memos'] as $item) {
193 $memo =
new Memo($db);
194 if ($memo->fetch((
int) $item[
'id']) > 0) {
196 if ($user->id != $memo->fk_user_creat && $memo->private)
continue;
197 if (!quickMemoInterfaceCanAccessMemo($memo))
continue;
199 $memo->updatePosition(
211 $jsonResponse->setSuccess();
221function quickMemoIntefaceActionCreate($jsonResponse)
223 global $user, $langs, $db,
$conf;
225 if (!$user->hasRight(
'quickmemo',
'memo',
'write')) {
226 $jsonResponse->setError($langs->trans(
'NotEnoughRights'), JsonResponse::HTTP_FORBIDDEN);
230 $element_id =
GETPOST(
"element_id",
"int");
231 $element_type =
GETPOST(
"element_type");
234 if (empty($element_id) && !is_numeric($element_id) && !empty($element_type)) {
235 $jsonResponse->setError($langs->trans(
'ErrorNeedElementId'));
240 $jsonResponse->setError($langs->trans(
'NotEnoughRights'), JsonResponse::HTTP_FORBIDDEN);
244 $memo =
new Memo($db);
245 $context_tab =
GETPOST(
'context');
246 if (!in_array($context_tab, $memo->getAvailableMemoContext())) {
247 $jsonResponse->setError($langs->trans(
'ErrorContextUnknown'));
253 $firstColor = !empty($colorPresets) ? $colorPresets[0] :
null;
254 $memo->color =
GETPOST(
"color");
256 $memo->color = $firstColor;
259 $memo->quick_note =
GETPOST(
"note", quickMemoInterfaceGetNoteSecurityCheck());
260 $memo->fk_element = $element_id;
261 $memo->element_type = $element_type;
262 $memo->context_tab = $context_tab;
263 $memo->shared_on_element =
GETPOST(
"shared_on_element",
"int") ? 1 : 0;
264 $memo->private =
GETPOST(
"private",
"int") ? 1 : 0;
266 $memo->pos_x =
GETPOST(
"x",
"int");
267 $memo->pos_y =
GETPOST(
"y",
"int");
268 $memo->pos_w =
GETPOST(
"w",
"int");
269 $memo->pos_h =
GETPOST(
"h",
"int");
270 $memo->pos_z =
GETPOST(
"z",
"int");
271 $memo->status = Memo::STATUS_VALIDATED;
272 $memo->entity = quickMemoInterfaceGetMemoEntity((
string) $element_type, (
int) $element_id, (
bool) $memo->shared_on_element);
274 $resCre = $memo->create($user);
276 $jsonResponse->setError($langs->trans(
'UpdateError') .
' : ' . $memo->errorsToString(), JsonResponse::HTTP_INTERNAL_ERROR);
279 $jsonResponse->setSuccess();
280 $jsonResponse->data =
new stdClass();
281 $jsonResponse->data->id = (int) $resCre;
293function quickMemoIntefaceActionArchiveNote($jsonResponse)
295 global $user, $langs, $db;
297 if (!$user->hasRight(
'quickmemo',
'memo',
'write')) {
298 $jsonResponse->setError($langs->trans(
'NotEnoughRights'), JsonResponse::HTTP_FORBIDDEN);
302 $memo = quickMemoInterfaceFetchMemo($jsonResponse,
'QuickMemoCantArchiveThisPrivateNote');
307 if ($memo->setArchived($user) < 0) {
308 $jsonResponse->setError($langs->trans(
'UpdateError') .
' : ' . $memo->errorsToString(), JsonResponse::HTTP_INTERNAL_ERROR);
311 $jsonResponse->setSuccess();
312 $jsonResponse->data =
null;
322function quickMemoIntefaceActionCreateModel($jsonResponse)
324 global $user, $langs, $db,
$conf;
326 if (!$user->hasRight(
'quickmemo',
'memo',
'write')) {
327 $jsonResponse->setError($langs->trans(
'NotEnoughRights'), JsonResponse::HTTP_FORBIDDEN);
331 $memo = quickMemoInterfaceFetchMemo($jsonResponse,
'QuickMemoCantChangeThisPrivateNote');
336 $element_type =
GETPOST(
"element_type");
337 if (empty($element_type)) {
338 $memo->element_type =
'';
341 $memo->status = Memo::STATUS_TPL;
342 $memo->entity =
$conf->entity;
343 $memo->private_tpl =
GETPOST(
"tpl_private",
"int");
344 $memo->name_tpl =
GETPOST(
"tpl_name");
345 $memo->fk_user_creat = $user->id;
346 $memo->date_creation =
dol_now();
347 $memo->fk_user_modif =
null;
348 $memo->date_modification =
null;
349 $memo->fk_user_archived =
null;
350 $memo->date_archived =
null;
352 if ($memo->update($user) < 0) {
353 $jsonResponse->setError($langs->trans(
'UpdateError') .
' : ' . $memo->errorsToString(), JsonResponse::HTTP_INTERNAL_ERROR);
356 $jsonResponse->setSuccess();
357 $jsonResponse->data =
null;
368function quickMemoIntefaceActionDeleteModel($jsonResponse)
370 global $user, $langs, $db;
372 if (!$user->hasRight(
'quickmemo',
'memo',
'delete')) {
373 $jsonResponse->setError($langs->trans(
'NotEnoughRights'), JsonResponse::HTTP_FORBIDDEN);
380 $jsonResponse->setError($langs->trans(
'ErrorNeedModelId'));
384 $memo =
new Memo($db);
385 if ($memo->fetch(
$id) <= 0 || !$memo->isInCurrentEntity()) {
386 $jsonResponse->setError($langs->trans(
'ErrorMemoNotFound'));
390 if ($memo->status != Memo::STATUS_TPL) {
391 $jsonResponse->setError($langs->trans(
'ErrorThisMemoIsNotATemplate'));
395 if ($user->id != $memo->fk_user_creat && $memo->private_tpl) {
396 $jsonResponse->setError($langs->trans(
'QuickMemoCantDeleteThisPrivateModel'));
400 if ($memo->delete($user) < 0) {
401 $jsonResponse->setError($langs->trans(
'UpdateError') .
' : ' . $memo->errorsToString(), JsonResponse::HTTP_INTERNAL_ERROR);
404 $jsonResponse->setSuccess();
405 $jsonResponse->data =
null;
442function quickMemoIntefaceActionUpdateModelRank($jsonResponse)
444 global $user, $langs, $db;
446 if (!$user->hasRight(
'quickmemo',
'memo',
'write')) {
447 $jsonResponse->setError($langs->trans(
'NotEnoughRights'), JsonResponse::HTTP_FORBIDDEN);
451 $json = file_get_contents(
'php://input');
452 $data = json_decode($json,
true);
454 if (!is_array($data) || empty($data[
'moved'][
'id']) || !isset($data[
'moved'][
'newPos'])) {
455 $jsonResponse->setError($langs->trans(
'ErrorInvalidMovedData'));
461 $movedId = (int) $data[
'moved'][
'id'];
462 $newPos = max(1, (
int) $data[
'moved'][
'newPos']);
464 $tmpMemo =
new Memo($db);
467 $sql =
'SELECT rowid, element_type, context_tab
468 FROM '.MAIN_DB_PREFIX.$tmpMemo->table_element.
'
469 WHERE rowid = '. (int) $movedId.
'
470 AND entity IN ('.
getEntity($tmpMemo->element).
')
471 AND status = '. (int) Memo::STATUS_TPL;
473 $res = $db->query($sql);
474 if (!$res || !$db->num_rows($res)) {
475 $jsonResponse->setError($langs->trans(
'ErrorModelNotFound'));
479 $movedModel = $db->fetch_object($res);
482 $sqlAll =
'SELECT rowid
483 FROM '.MAIN_DB_PREFIX.$tmpMemo->table_element.
'
484 WHERE status = '. (int) Memo::STATUS_TPL.
'
485 AND entity IN ('.
getEntity($tmpMemo->element).
')
486 AND element_type IN (\''.$db->escape($movedModel->element_type).
'\', \
'\')
487 ORDER BY rank_tpl DESC
';
489 // AND context_tab = \''.$db->escape($movedModel->context_tab).
'\'
491 $resAll = $db->query($sqlAll);
493 $jsonResponse->setError($db->error(), JsonResponse::HTTP_INTERNAL_ERROR);
498 while ($obj = $db->fetch_object($resAll)) {
499 $orderedIds[] = (int) $obj->rowid;
503 $orderedIds = array_values(array_diff($orderedIds, [$movedId]));
506 $newIndex = min(count($orderedIds), $newPos - 1);
509 array_splice($orderedIds, $newIndex, 0, [$movedId]);
512 $total = count($orderedIds);
513 $currentRank = $total;
517 foreach ($orderedIds as
$id) {
518 $sqlUp =
'UPDATE '.MAIN_DB_PREFIX.$tmpMemo->table_element.
'
519 SET rank_tpl = '.(int) $currentRank.
'
520 WHERE rowid = '.(
int)
$id.
'
521 AND status = '. (int) Memo::STATUS_TPL.
'
522 AND entity IN ('.
getEntity($tmpMemo->element).
')
523 AND (private_tpl = 0 OR fk_user_creat = '.(int) $user->id.
')';
525 if (!$db->query($sqlUp)) {
527 $jsonResponse->setError($db->error(), JsonResponse::HTTP_INTERNAL_ERROR);
536 $jsonResponse->setSuccess();
537 $jsonResponse->data =
null;
545function quickMemoIntefaceActionDeleteNote($jsonResponse)
547 global $user, $langs, $db;
549 if (!$user->hasRight(
'quickmemo',
'memo',
'write')) {
550 $jsonResponse->setError($langs->trans(
'NotEnoughRights'), JsonResponse::HTTP_FORBIDDEN);
554 $memo = quickMemoInterfaceFetchMemo($jsonResponse,
'QuickMemoCantDeleteThisPrivateNote');
559 if ($memo->status == Memo::STATUS_TPL) {
560 $jsonResponse->setError($langs->trans(
'ErrorCantDeleteModel'));
564 if ($memo->delete($user) < 0) {
565 $jsonResponse->setError($langs->trans(
'UpdateError') .
' : ' . $memo->errorsToString(), JsonResponse::HTTP_INTERNAL_ERROR);
568 $jsonResponse->setSuccess();
569 $jsonResponse->data =
null;
580function quickMemoIntefaceActionUpdateNote($jsonResponse)
582 global $user, $langs, $db;
584 if (!$user->hasRight(
'quickmemo',
'memo',
'write')) {
585 $jsonResponse->setError($langs->trans(
'NotEnoughRights'), JsonResponse::HTTP_FORBIDDEN);
589 $memo = quickMemoInterfaceFetchMemo($jsonResponse,
'QuickMemoCantChangeThisPrivateNote');
594 $memo->quick_note =
GETPOST(
"note", quickMemoInterfaceGetNoteSecurityCheck());
596 $memo->fk_user_modif = $user->id;
598 if ($memo->update($user) < 0) {
599 $jsonResponse->setError($langs->trans(
'UpdateError') .
' : ' . $memo->errorsToString(), JsonResponse::HTTP_INTERNAL_ERROR);
602 $jsonResponse->setSuccess();
603 $jsonResponse->data =
new stdClass();
606 $jsonResponse->data->memo = $memo->getJsMemo($user);
616function quickMemoIntefaceActionUpdateColor($jsonResponse)
618 global $user, $langs, $db;
620 if (!$user->hasRight(
'quickmemo',
'memo',
'write')) {
621 $jsonResponse->setError($langs->trans(
'NotEnoughRights'), JsonResponse::HTTP_FORBIDDEN);
627 $jsonResponse->setError($langs->trans(
'ErrorNeedValidColor'));
631 $memo = quickMemoInterfaceFetchMemo($jsonResponse,
'QuickMemoCantChangeThisPrivateNote');
636 $memo->color = $color;
638 if ($memo->update($user) < 0) {
639 $jsonResponse->setError($langs->trans(
'UpdateError') .
' : ' . $memo->errorsToString(), JsonResponse::HTTP_INTERNAL_ERROR);
642 $jsonResponse->setSuccess();
643 $jsonResponse->data =
new stdClass();
646 $jsonResponse->data->memo = $memo->getJsMemo($user);
656function quickMemoIntefaceActionUpdateSharedOnElement($jsonResponse)
658 global $user, $langs, $db;
660 if (!$user->hasRight(
'quickmemo',
'memo',
'write')) {
661 $jsonResponse->setError($langs->trans(
'NotEnoughRights'), JsonResponse::HTTP_FORBIDDEN);
665 $shared_on_element =
GETPOST(
"shared_on_element",
"int");
667 $memo = quickMemoInterfaceFetchMemo($jsonResponse,
'QuickMemoCantChangeThisPrivateNote');
672 $memo->shared_on_element = $shared_on_element ? 1 : 0;
673 $memo->entity = quickMemoInterfaceGetMemoEntity((
string) $memo->element_type, (
int) $memo->fk_element, (
bool) $memo->shared_on_element);
675 if ($memo->update($user) < 0) {
676 $jsonResponse->setError($langs->trans(
'UpdateError') .
' : ' . $memo->errorsToString(), JsonResponse::HTTP_INTERNAL_ERROR);
679 $jsonResponse->setSuccess();
680 $jsonResponse->data =
null;
681 $jsonResponse->data =
new stdClass();
684 $jsonResponse->data->memo = $memo->getJsMemo($user);
695function quickMemoIntefaceActionUpdatePrivate($jsonResponse)
697 global $user, $langs, $db;
699 if (!$user->hasRight(
'quickmemo',
'memo',
'write')) {
700 $jsonResponse->setError($langs->trans(
'NotEnoughRights'), JsonResponse::HTTP_FORBIDDEN);
704 $private =
GETPOST(
"private",
"int");
706 $memo = quickMemoInterfaceFetchMemo($jsonResponse,
'QuickMemoCantChangeThisPrivateNote');
711 $memo->private = $private ? 1 : 0;
713 if ($memo->update($user) < 0) {
714 $jsonResponse->setError($langs->trans(
'UpdateError') .
' : ' . $memo->errorsToString(), JsonResponse::HTTP_INTERNAL_ERROR);
717 $jsonResponse->setSuccess();
718 $jsonResponse->data =
new stdClass();
721 $jsonResponse->data->memo = $memo->getJsMemo($user);
731function quickMemoIntefaceActionListModels($jsonResponse)
733 global $user, $langs, $db;
735 if (!$user->hasRight(
'quickmemo',
'memo',
'read')) {
736 $jsonResponse->setError($langs->trans(
'NotEnoughRights'), JsonResponse::HTTP_FORBIDDEN);
740 $element_type =
GETPOST(
'element_type',
'alpha');
743 $jsonResponse->data =
new stdClass();
744 $jsonResponse->data->modelTemplate = [];
745 $jsonResponse->data->presetTemplate = [];
750 foreach ($colorList as $color) {
753 $default->color = $color;
759 $default->shared_on_element = 0;
760 $default->private = 0;
761 $default->user_name = $user->getFullName($langs);
763 $default->date_change =
'';
764 $default->user_change_name =
'';
767 $jsonResponse->data->presetTemplate[] = $default;
771 $memoStatic =
new Memo($db);
772 $sql = $memoStatic->getTemplateMemosQuery($element_type,
$context);
773 $resql = $db->query($sql);
775 $jsonResponse->setError($db->lasterror(), JsonResponse::HTTP_INTERNAL_ERROR);
779 while ($obj = $db->fetch_object($resql)) {
781 $jsonResponse->data->modelTemplate[] = quickMemoInterfacePopulateMemoTplFromQueryObj($obj);
784 $jsonResponse->setSuccess();
792function quickMemoIntefaceActionList($jsonResponse)
794 global $user, $langs, $db;
796 if (!$user->hasRight(
'quickmemo',
'memo',
'read')) {
797 $jsonResponse->setError($langs->trans(
'NotEnoughPermissions'), JsonResponse::HTTP_FORBIDDEN);
802 $element_type =
GETPOST(
'element_type',
'alpha');
804 $jsonResponse->data =
new stdClass();
805 $jsonResponse->data->memos = [];
806 $jsonResponse->data->nbArchives = 0;
808 if (empty($element_id) && !empty($element_type)) {
809 $jsonResponse->setError($langs->trans(
'ErrorNeedElementId'));
814 $jsonResponse->setError($langs->trans(
'NotEnoughRights'), JsonResponse::HTTP_FORBIDDEN);
818 $staticMemo =
new Memo($db);
821 $sql = $staticMemo->getMemosQuery($element_type, $element_id,
$context);
822 $resql = $db->query($sql);
824 $jsonResponse->setError($db->lasterror(), JsonResponse::HTTP_INTERNAL_ERROR);
830 while ($obj = $db->fetch_object($resql)) {
832 $memos[] = quickMemoInterfacePopulateMemoFromQueryObj($obj);
835 $jsonResponse->data->memos = $memos;
838 $nbArchives = $staticMemo->countArchivedMemoQuery($element_type, $element_id,
$context);
839 if ($nbArchives ===
false) {
840 $jsonResponse->setError($langs->trans(
'ErrorCountArchive'), JsonResponse::HTTP_INTERNAL_ERROR);
844 $jsonResponse->data->nbArchives = $nbArchives;
846 $jsonResponse->setSuccess();
855function quickMemoInterfacePopulateMemoFromQueryObj($obj)
858 $obj->date_creation = $db->jdate($obj->date_creation);
859 $obj->tms = $db->jdate($obj->tms);
862 $memo->id = $obj->rowid;
863 $memo->color = $obj->color;
864 $memo->note = $obj->quick_note;
866 $memo->pos_x = $obj->user_pos_x !==
null ? (int) $obj->user_pos_x : (int) $obj->pos_x;
867 $memo->pos_y = $obj->user_pos_y !==
null ? (int) $obj->user_pos_y : (int) $obj->pos_y;
868 $memo->pos_w = $obj->user_pos_w !==
null ? (int) $obj->user_pos_w : (int) $obj->pos_w;
869 $memo->pos_h = $obj->user_pos_h !==
null ? (int) $obj->user_pos_h : (int) $obj->pos_h;
870 $memo->pos_z = $obj->user_pos_z !==
null ? (int) $obj->user_pos_z : (int) $obj->pos_z;
872 $memo->shared_on_element = $obj->shared_on_element;
873 $memo->private = (int) $obj->private;
874 $memo->date_creation =
dol_print_date($obj->date_creation,
'%d/%m/%Y %H:%M',
'tzuserrel');
875 $memo->date_change =
'';
876 if (!empty($obj->tms) && ((
int) $obj->date_creation !== (
int) $obj->tms || (
int) $obj->fk_user_modif > 0)) {
877 $memo->date_change =
dol_print_date($obj->tms,
'%d/%m/%Y %H:%M',
'tzuserrel');
880 $memo->fk_user_creat = $obj->fk_user_creat;
881 $memo->user_name =
'';
882 if ((
int) $obj->fk_user_creat > 0) {
883 $userCreate =
new User($db);
884 if ($userCreate->fetch((
int) $obj->fk_user_creat) > 0) {
885 $memo->user_name = $userCreate->getFullName($langs);
889 $memo->fk_user_modif = $obj->fk_user_modif;
890 $memo->user_change_name =
'';
891 if ((
int) $obj->fk_user_modif > 0) {
892 $userMod =
new User($db);
893 if ($userMod->fetch((
int) $obj->fk_user_modif) > 0) {
894 $memo->user_change_name = $userMod->getFullName($langs);
906function quickMemoInterfacePopulateMemoTplFromQueryObj($obj)
908 global $db, $langs, $user;
909 $obj->date_creation = $db->jdate($obj->date_creation);
910 $obj->tms = $db->jdate($obj->tms);
914 $memo->name = $obj->name_tpl;
915 $memo->id = $obj->rowid;
916 $memo->color = $obj->color;
917 $memo->note = $obj->quick_note;
918 $memo->pos_x = $obj->user_pos_x !==
null ? (int) $obj->user_pos_x : (int) $obj->pos_x;
919 $memo->pos_y = $obj->user_pos_y !==
null ? (int) $obj->user_pos_y : (int) $obj->pos_y;
920 $memo->pos_w = $obj->user_pos_w !==
null ? (int) $obj->user_pos_w : (int) $obj->pos_w;
921 $memo->pos_h = $obj->user_pos_h !==
null ? (int) $obj->user_pos_h : (int) $obj->pos_h;
922 $memo->pos_z = $obj->user_pos_z !==
null ? (int) $obj->user_pos_z : (int) $obj->pos_z;
923 $memo->rank_tpl = (int) $obj->rank_tpl;
925 $memo->shared_on_element = $obj->shared_on_element;
926 $memo->private = (int) $obj->private;
927 $memo->date_creation =
dol_print_date($obj->date_creation,
'%d/%m/%Y %H:%M',
'tzuserrel');
928 $memo->fk_user_creat = $user->id;
929 $memo->user_name = $user->getFullName($langs);
930 $memo->date_change =
'';
931 $memo->user_change_name =
'';
945function quickMemoInterfaceGetMemoEntity($element_type, $element_id, $shared_on_element)
949 if (empty($element_type) || $shared_on_element || $element_id <= 0) {
950 return (
int)
$conf->entity;
954 $object = fetchObjectByElement($element_id, quickMemoInterfaceResolveElementType($element_type),
'', 1);
965function quickMemoInterfaceCanAccessMemo($memo)
967 if (!$memo->isInCurrentEntity()) {
972 if ($memo->status == Memo::STATUS_TPL) {
987function quickMemoInterfaceFetchMemo($jsonResponse, $privateErrorKey =
'')
989 global $user, $langs, $db;
993 $jsonResponse->setError($langs->trans(
'ErrorNeedMemoId'));
997 $memo =
new Memo($db);
998 if ($memo->fetch(
$id) <= 0 || !$memo->isInCurrentEntity()) {
999 $jsonResponse->setError($langs->trans(
'ErrorMemoNotFound'));
1003 if (!empty($privateErrorKey) && $user->id != $memo->fk_user_creat && $memo->private) {
1004 $jsonResponse->setError($langs->trans($privateErrorKey));
1008 if (!quickMemoInterfaceCanAccessMemo($memo)) {
1009 $jsonResponse->setError($langs->trans(
'NotEnoughRights'), JsonResponse::HTTP_FORBIDDEN);
1021function quickMemoInterfaceGetNoteSecurityCheck()
1024 return 'alphanohtml';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class JsonResponse used for ajax responses in Dolibarr.
static checkColor($color)
Checks if a color is a valid hex code.
static getJsMemoDefault()
Get JS memo default.
static getColorPreset()
Get color preset.
Class to manage Dolibarr users.
$context
@method int call_trigger(string $triggerName, ?User $user)
dol_now($mode='gmt')
Return date for now.
setEntity($currentobject)
Set entity id to use when to create an object.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
quickMemoInterfaceCanAccessElement($element_type, $element_id, $moduleLevelOnly=false)
Check that current user can read the object a memo is attached to.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.