dolibarr 25.0.0-alpha
knowledgerecord_card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017-2021 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
37require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
40require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/class/knowledgerecord.class.php';
41require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/lib/knowledgemanagement_knowledgerecord.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
43
44// Load translation files required by the page
45$langs->loadLangs(array("knowledgemanagement", "ticket", "other"));
46
47// Get parameters
48$id = GETPOSTINT('id');
49$ref = GETPOST('ref', 'alpha');
50$action = GETPOST('action', 'aZ09');
51$confirm = GETPOST('confirm', 'alpha');
52$cancel = GETPOST('cancel');
53$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'knowledgerecordcard'; // To manage different context of search
54$backtopage = GETPOST('backtopage', 'alpha');
55$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
56$lineid = GETPOSTINT('lineid');
57
58// Initialize a technical objects
59$object = new KnowledgeRecord($db);
60$extrafields = new ExtraFields($db);
61$diroutputmassaction = $conf->knowledgemanagement->dir_output.'/temp/massgeneration/'.$user->id;
62$hookmanager->initHooks(array('knowledgerecordcard', 'globalcard')); // Note that conf->hooks_modules contains array
63
64// Fetch optionals attributes and labels
65$extrafields->fetch_name_optionals_label($object->table_element);
66
67$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
68
69// Initialize array of search criteria
70$search_all = GETPOST("search_all", 'alpha');
71$search = array();
72foreach ($object->fields as $key => $val) {
73 if (GETPOST('search_'.$key, 'alpha')) {
74 $search[$key] = GETPOST('search_'.$key, 'alpha');
75 }
76}
77
78if (empty($action) && empty($id) && empty($ref)) {
79 $action = 'view';
80}
81
82// Load object
83include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
84
85
86$permissiontoread = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'read');
87$permissiontoadd = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
88$permissiontodelete = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
89$permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $permissiontoadd) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('knowledgemanagement', 'knowledgerecord_advance', 'validate')));
90$permissionnote = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_setnotes.inc.php
91$permissiondellink = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_dellink.inc.php
92$upload_dir = $conf->knowledgemanagement->multidir_output[isset($object->entity) ? $object->entity : 1];
93
94// Security check - Protection if external user
95//if ($user->socid > 0) accessforbidden();
96//if ($user->socid > 0) $socid = $user->socid;
97$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
98restrictedArea($user, $object->module, $object->id, $object->table_element.'&'.$object->element, $object->element, '', 'rowid', $isdraft);
99//if (empty($conf->knowledgemanagement->enabled)) accessforbidden();
100//if (empty($permissiontoread)) accessforbidden();
101
102
103/*
104 * Actions
105 */
106
107$parameters = array();
108$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
109if ($reshook < 0) {
110 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
111}
112
113if (empty($reshook)) {
114 $error = 0;
115
116 $backurlforlist = DOL_URL_ROOT.'/knowledgemanagement/knowledgerecord_list.php';
117
118 if (empty($backtopage) || ($cancel && empty($id))) {
119 if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
120 if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
121 $backtopage = $backurlforlist;
122 } else {
123 $backtopage = DOL_URL_ROOT.'/knowledgemanagement/knowledgerecord_card.php?id='.($id > 0 ? $id : '__ID__');
124 }
125 }
126 }
127
128 $triggermodname = 'KNOWLEDGERECORD_MODIFY'; // Name of trigger action code to execute when we modify record
129
130 // Update / add for lang
131 if (($action == 'update' || $action == 'add') && !empty($permissiontoadd)) {
132 $object->lang = (GETPOSTISSET('langkm') ? GETPOST('langkm', 'aZ09') : $object->lang);
133 }
134
135 // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
136 include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
137
138 // Actions when linking object each other
139 include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
140
141 // Actions when printing a doc from card
142 include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
143
144 // Action to move up and down lines of object
145 //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
146
147 // Action to build doc
148 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
149
150 if ($action == 'set_thirdparty' && $permissiontoadd) {
151 $object->setValueFrom('fk_soc', GETPOSTINT('fk_soc'), '', null, 'date', '', $user, $triggermodname);
152 }
153 if ($action == 'classin' && $permissiontoadd) {
154 $object->setProject(GETPOSTINT('projectid'));
155 }
156
157 // Actions to send emails
158 $triggersendname = 'KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_SENTBYMAIL';
159 $autocopy = 'MAIN_MAIL_AUTOCOPY_KNOWLEDGERECORD_TO';
160 $trackid = 'knowledgerecord'.$object->id;
161 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
162}
163if ($action == 'confirm_validate') { // Test on permission already done into actions_addupdatedelete.inc.php
164 $action = 'edit';
165}
166
167
168/*
169 * View
170 */
171
172$form = new Form($db);
173$formfile = new FormFile($db);
174$formproject = new FormProjets($db);
175$formadmin = new FormAdmin($db);
176
177$title = $langs->trans("KnowledgeRecord");
178$help_url = '';
179llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-knowledgemanagement page-card');
180
181// Part to create
182if ($action == 'create') {
183 print load_fiche_titre($langs->trans("NewKnowledgeRecord"), '', 'object_'.$object->picto);
184
185 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
186 print '<input type="hidden" name="token" value="'.newToken().'">';
187 print '<input type="hidden" name="action" value="add">';
188 if (!empty($backtopage)) {
189 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
190 }
191 if (!empty($backtopageforcancel)) {
192 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
193 }
194
195 print dol_get_fiche_head(array(), '', '', -3);
196
197 print '<table class="border centpercent tableforfieldcreate">'."\n";
198
199 // Common attributes
200 $object->fields['answer']['enabled'] = 0;
201 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
202 $object->fields['answer']['enabled'] = 1;
203
204 if (isModEnabled('category')) {
205 $cate_arbo = $form->select_all_categories(Categorie::TYPE_KNOWLEDGEMANAGEMENT, '', 'parent', 64, 0, 3);
206 // $output_mode is 3, so fix return type:
207 '@phan-var-force array<int,array{rowid:int,id:int,fk_parent:int,label:string,description:string,color:string,position:string,visible:int,ref_ext:string,picto:string,fullpath:string,fulllabel:string}> $cate_arbo';
208
209 if (count($cate_arbo)) {
210 // Categories
211 print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
212 print $form->selectCategories(Categorie::TYPE_KNOWLEDGEMANAGEMENT, 'categories', $object);
213 print "</td></tr>";
214 }
215 }
216
217 // Other attributes
218 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
219
220
221 // Add field answer
222 print '<tr><td>';
223 print $langs->trans($object->fields['answer']['label']);
224 print '</td><td>';
225
226 // Add layout and AI tools for answer
227 $out = '';
228 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
229 $formmail = new FormMail($db);
230 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formai.class.php';
231 $formai = new FormAI($db);
232
233 $formmail->withfckeditor = 1;
234 //$formmail->withlayout = 'email';
235 $formmail->withaiprompt = (isModEnabled('ai') ? 'html' : '');
236
237 $showlinktolayout = (getDolGlobalInt('MAIN_EMAIL_USE_LAYOUT') ? $formmail->withlayout : '');
238 $showlinktolayoutlabel = $langs->trans("FillMessageWithALayout");
239 $showlinktoai = ($formmail->withaiprompt ? 'textgenerationemail' : '');
240 $showlinktoailabel = $langs->trans("FillMessageWithAIContent");
241 $htmlname = 'answer';
242
243 include DOL_DOCUMENT_ROOT.'/core/tpl/formlayoutai.tpl.php';
244 print $out;
245 print '</td></tr>';
246
247 print '</table>'."\n";
248
249 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
250 $doleditor = new DolEditor('answer', $object->answer, '', 200, 'dolibarr_notes', 'In', true, true, true, ROWS_9, '100%');
251 $out = $doleditor->Create(1);
252 print $out;
253
254 // Prefill AI instructions with question text on create form
255 if (isModEnabled('ai')) {
256 $aipromptprefix = $langs->transnoentities('SuggestAnswerToQuestion');
257
258 print '<script nonce="'.getNonce().'" type="text/javascript">
259 $(document).ready(function() {
260 $("#linkforaiprompttextgenerationemail").on("click", function() {
261 setTimeout(function() {
262 var instructionField = $("#ai_instructionsanswer");
263 if (!instructionField.is(":visible")) {
264 return;
265 }
266 var prefix = \''.dol_escape_js($aipromptprefix).'\';
267 var currentVal = instructionField.val();
268 var question = "";
269 if (typeof CKEDITOR !== "undefined" && CKEDITOR.instances && CKEDITOR.instances["question"]) {
270 question = $("<div>").html(CKEDITOR.instances["question"].getData()).text().trim();
271 } else {
272 question = $("#question").val() ? $.trim($("#question").val()) : "";
273 }
274 if (currentVal === "" || currentVal === prefix || currentVal.indexOf(prefix) === 0) {
275 if (question) {
276 instructionField.val(prefix + " " + question);
277 } else {
278 instructionField.val(prefix);
279 }
280 $("#generate_buttonanswer").prop("disabled", (instructionField.val() === ""));
281 }
282 }, 50);
283 });
284 });
285 </script>';
286 }
287
288 print dol_get_fiche_end();
289
290 print $form->buttonsSaveCancel('Create');
291
292 print '</form>';
293
294 //dol_set_focus('input[name="ref"]');
295}
296
297// Part to edit record
298if (($id || $ref) && $action == 'edit') {
299 print load_fiche_titre($langs->trans("KnowledgeRecord"), '', 'object_'.$object->picto);
300
301 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
302 print '<input type="hidden" name="token" value="'.newToken().'">';
303 print '<input type="hidden" name="action" value="update">';
304 print '<input type="hidden" name="id" value="'.$object->id.'">';
305 if (!empty($backtopage)) {
306 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
307 }
308 if (!empty($backtopageforcancel)) {
309 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
310 }
311
312 print dol_get_fiche_head(array(), '', '', -3);
313
314 print '<table class="border centpercent tableforfieldedit">'."\n";
315
316 // Common attributes
317 $object->fields['answer']['enabled'] = 0;
318 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
319 $object->fields['answer']['enabled'] = 1;
320
321 if (isModEnabled('category')) {
322 $cate_arbo = $form->select_all_categories(Categorie::TYPE_KNOWLEDGEMANAGEMENT, '', 'parent', 64, 0, 3);
323 // $output_mode is 3, so fix return type:
324 '@phan-var-force array<int,array{rowid:int,id:int,fk_parent:int,label:string,description:string,color:string,position:string,visible:int,ref_ext:string,picto:string,fullpath:string,fulllabel:string}> $cate_arbo';
325
326 if (count($cate_arbo)) {
327 // Categories
328 print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
329 print $form->selectCategories(Categorie::TYPE_KNOWLEDGEMANAGEMENT, 'categories', $object);
330 print "</td></tr>";
331 }
332 }
333
334 // Other attributes
335 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
336
337 // Add field answer
338 print '<tr><td>';
339 print $langs->trans($object->fields['answer']['label']);
340 print '</td><td>';
341
342 // Add layout and AI tools for answer
343 $out = '';
344 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
345 $formmail = new FormMail($db);
346 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formai.class.php';
347 $formai = new FormAI($db);
348
349 $formmail->withfckeditor = 1;
350 //$formmail->withlayout = 'email';
351 $formmail->withaiprompt = (isModEnabled('ai') ? 'html' : '');
352
353 $showlinktolayout = (getDolGlobalInt('MAIN_EMAIL_USE_LAYOUT') ? $formmail->withlayout : '');
354 $showlinktolayoutlabel = $langs->trans("FillMessageWithALayout");
355 $showlinktoai = ($formmail->withaiprompt ? 'textgenerationemail' : '');
356 $showlinktoailabel = $langs->trans("FillMessageWithAIContent");
357 $htmlname = 'answer';
358
359 include DOL_DOCUMENT_ROOT.'/core/tpl/formlayoutai.tpl.php';
360 print $out;
361 print '</td></tr>';
362
363 print '</table>'."\n";
364
365 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
366 $doleditor = new DolEditor('answer', $object->answer, '', 200, 'dolibarr_notes', 'In', true, true, true, ROWS_9, '100%');
367 $out = $doleditor->Create(1);
368 print $out;
369
370 print dol_get_fiche_end();
371
372 print $form->buttonsSaveCancel();
373
374 print '</form>';
375}
376
377// Part to show record
378if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
379 $res = $object->fetch_optionals();
380
381 $head = knowledgerecordPrepareHead($object);
382 print dol_get_fiche_head($head, 'card', $langs->trans("KnowledgeRecord"), -1, $object->picto, 0, '', '', 0, '', 1);
383
384 $formconfirm = '';
385
386 // Confirmation to delete
387 if ($action == 'delete') {
388 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteKnowledgeRecord'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
389 }
390 // Confirmation to delete line
391 if ($action == 'deleteline') {
392 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
393 }
394 // Clone confirmation
395 if ($action == 'clone') {
396 // Create an array for form
397 $formquestion = array();
398 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
399 }
400
401 // Confirmation of action xxxx (You can use it for xxx = 'close', xxx = 'reopen', ...)
402 if ($action == 'close') {
403 $text = $langs->trans('ConfirmCloseKM', $object->ref);
404 /*if (isModEnabled('notification'))
405 {
406 require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
407 $notify = new Notify($db);
408 $text .= '<br>';
409 $text .= $notify->confirmMessage('MYOBJECT_CLOSE', $object->socid, $object);
410 }*/
411
412 $formquestion = array();
413 /*
414 $forcecombo=0;
415 if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
416 $formquestion = array(
417 // 'text' => $langs->trans("ConfirmClone"),
418 // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
419 // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
420 // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
421 );
422 */
423 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetObsolete'), $text, 'confirm_close', $formquestion, 0, 1, 220);
424 }
425
426 // Confirmation of action xxxx (You can use it for xxx = 'close', xxx = 'reopen', ...)
427 if ($action == 'reopen') {
428 $text = $langs->trans('ConfirmReopenKM', $object->ref);
429 /*if (isModEnabled('notification'))
430 {
431 require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
432 $notify = new Notify($db);
433 $text .= '<br>';
434 $text .= $notify->confirmMessage('MYOBJECT_CLOSE', $object->socid, $object);
435 }*/
436
437 $formquestion = array();
438 /*
439 $forcecombo=0;
440 if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
441 $formquestion = array(
442 // 'text' => $langs->trans("ConfirmClone"),
443 // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
444 // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
445 // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
446 );
447 */
448 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Re-Open'), $text, 'confirm_reopen', $formquestion, 0, 1, 220);
449 }
450
451 // Call Hook formConfirm
452 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
453 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
454 if (empty($reshook)) {
455 $formconfirm .= $hookmanager->resPrint;
456 } elseif ($reshook > 0) {
457 $formconfirm = $hookmanager->resPrint;
458 }
459
460 // Print form confirm
461 print $formconfirm;
462
463
464 // Object card
465 // ------------------------------------------------------------
466 $linkback = '<a href="'.DOL_URL_ROOT.'/knowledgemanagement/knowledgerecord_list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
467
468 $morehtmlref = '<div class="refidno">';
469 /*
470 // Ref customer
471 $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
472 $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
473 // Thirdparty
474 $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
475 // Project
476 if (isModEnabled('project')) {
477 $langs->load("projects");
478 $morehtmlref .= '<br>'.$langs->trans('Project') . ' ';
479 if ($permissiontoadd) {
480 //if ($action != 'classify') $morehtmlref.='<a class="editfielda" href="' . dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true) . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> ';
481 $morehtmlref .= ' : ';
482 if ($action == 'classify') {
483 //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 0, 1, '', 'maxwidth300');
484 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
485 $morehtmlref .= '<input type="hidden" name="action" value="classin">';
486 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
487 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
488 $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
489 $morehtmlref .= '</form>';
490 } else {
491 $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
492 }
493 } else {
494 if (!empty($object->fk_project)) {
495 $proj = new Project($db);
496 $proj->fetch($object->fk_project);
497 $morehtmlref .= ': '.$proj->getNomUrl();
498 } else {
499 $morehtmlref .= '';
500 }
501 }
502 }*/
503 $morehtmlref .= '</div>';
504
505
506 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
507
508
509 print '<div class="fichecenter">';
510 print '<div class="fichehalfleft">';
511 print '<div class="underbanner clearboth"></div>';
512 print '<table class="border centpercent tableforfield">'."\n";
513
514 // Common attributes
515 $keyforbreak = 'fk_c_ticket_category'; // We change column just before this field
516 //unset($object->fields['fk_project']); // Hide field already shown in banner
517 //unset($object->fields['fk_soc']); // Hide field already shown in banner
518 $object->fields['answer']['enabled'] = 0;
519 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
520 $object->fields['answer']['enabled'] = 1;
521
522 // Categories
523 if (isModEnabled('category')) {
524 print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
525 print $form->showCategories($object->id, Categorie::TYPE_KNOWLEDGEMANAGEMENT, 1);
526 print "</td></tr>";
527 }
528
529 // Other attributes. Fields from hook formObjectOptions and Extrafields.
530 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
531
532 print '</table>';
533
534 print '</div>';
535 print '</div>';
536
537 print '<div class="clearboth"></div>';
538
539 // Add field answer
540 print '<br>';
541 print load_fiche_titre($langs->trans($object->fields['answer']['label']), '', '');
542 if ($action == 'edit') {
543 // Add layout and AI tools for answer
544 $out = '';
545 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
546 $formmail = new FormMail($db);
547 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formai.class.php';
548 $formai = new FormAI($db);
549
550 $formmail->withfckeditor = 1;
551 $formmail->withlayout = 'email';
552 $formmail->withaiprompt = (isModEnabled('ai') ? 'html' : '');
553
554 $showlinktolayout = (getDolGlobalInt('MAIN_EMAIL_USE_LAYOUT') ? $formmail->withlayout : '');
555 $showlinktolayoutlabel = $langs->trans("FillMessageWithALayout");
556 $showlinktoai = ($formmail->withaiprompt ? 'textgenerationemail' : '');
557 $showlinktoailabel = $langs->trans("FillMessageWithAIContent");
558 $htmlname = 'answer';
559
560 include DOL_DOCUMENT_ROOT.'/core/tpl/formlayoutai.tpl.php';
561 print $out;
562 print '<br>';
563
564 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
565 $doleditor = new DolEditor('answer', $object->answer, '', 200, 'dolibarr_notes', 'In', true, true, true, ROWS_9, '100%', 1);
566 $out = $doleditor->Create(1);
567 } else {
568 $out = '<div class="content kmcontent">';
569 $out .= dol_htmlentitiesbr($object->answer);
570 $out .= '</div>';
571 }
572 print $out;
573 print dol_get_fiche_end();
574
575
576 // Buttons for actions
577
578 if ($action != 'presend' && $action != 'editline') {
579 print '<div class="tabsAction">'."\n";
580 $parameters = array();
581 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
582 if ($reshook < 0) {
583 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
584 }
585
586 if (empty($reshook)) {
587 // Send
588 //if (empty($user->socid)) {
589 //print dolGetButtonAction('', $langs->trans('SendMail'), 'email', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle');
590 //}
591
592 // Back to draft
593 if ($object->status == $object::STATUS_VALIDATED) {
594 print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd);
595 }
596 if (($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) && $permissiontovalidate) {
597 print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd);
598 }
599 // Validate
600 if ($object->status == $object::STATUS_DRAFT) {
601 if ((empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) && $permissiontovalidate) {
602 print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&token='.newToken().'&confirm=yes', '', $permissiontoadd);
603 } else {
604 $langs->load("errors");
605 //print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes', '', 0);
606 print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
607 }
608 }
609
610 // Clone
611 print dolGetButtonAction($langs->trans('ToClone'), $langs->trans('ToClone'), 'clone', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=clone&token='.newToken().'&object=scrumsprint', '', $permissiontoadd, array('attr' => array('class' => 'reposition')));
612
613 /*
614 if ($permissiontoadd) {
615 if ($object->status == $object::STATUS_ENABLED) {
616 print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=disable&token='.newToken().'">'.$langs->trans("Disable").'</a>'."\n";
617 } else {
618 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=enable&token='.newToken().'">'.$langs->trans("Enable").'</a>'."\n";
619 }
620 }
621 */
622 if ($permissiontoadd) {
623 if ($object->status == $object::STATUS_VALIDATED) {
624 print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken().'">'.$langs->trans("SetObsolete").'</a>'."\n";
625 } elseif ($object->status == $object::STATUS_CANCELED) {
626 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen&token='.newToken().'">'.$langs->trans("ReOpen").'</a>'."\n";
627 }
628 }
629
630 // Delete (need delete permission, or if draft, just need create/modify permission)
631 print dolGetButtonAction($langs->trans('Delete'), $langs->trans('Delete'), 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken(), '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd), array('attr' => array('class' => 'reposition')))."\n";
632 }
633 print '</div>'."\n";
634 }
635
636
637 // Select mail models is same action as presend
638 if (GETPOST('modelselected')) {
639 $action = 'presend';
640 }
641
642 if ($action != 'presend') {
643 print '<div class="fichecenter"><div class="fichehalfleft">';
644 print '<a name="builddoc"></a>'; // ancre
645
646 $includedocgeneration = 0;
647
648 // Documents
649 if ($includedocgeneration) {
650 $objref = dol_sanitizeFileName($object->ref);
651 $relativepath = $objref.'/'.$objref.'.pdf';
652 $filedir = $conf->knowledgemanagement->dir_output.'/'.$object->element.'/'.$objref;
653 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
654 $genallowed = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'read'); // If you can read, you can build the PDF to read content
655 $delallowed = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // If you can create/edit, you can remove a file on card
656 print $formfile->showdocuments('knowledgemanagement:KnowledgeRecord', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
657 }
658
659 // Show links to link elements
660 $tmparray = $form->showLinkToObjectBlock($object, array(), array('knowledgerecord'), 1);
661 $linktoelem = $tmparray['linktoelem'];
662 $htmltoenteralink = $tmparray['htmltoenteralink'];
663 print $htmltoenteralink;
664
665 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
666
667
668 print '</div><div class="fichehalfright">';
669
670 $MAXEVENT = 10;
671
672 $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/knowledgemanagement/knowledgerecord_agenda.php?id='.$object->id);
673
674 // List of actions on element
675 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
676 $formactions = new FormActions($db);
677 $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
678
679 print '</div></div>';
680 }
681
682 //Select mail models is same action as presend
683 if (GETPOST('modelselected')) {
684 $action = 'presend';
685 }
686
687 // Presend form
688 $modelmail = 'knowledgerecord';
689 $defaulttopic = 'InformationMessage';
690 $diroutput = $conf->knowledgemanagement->dir_output;
691 $trackid = 'knowledgerecord'.$object->id;
692
693 include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
694}
695
696// End of page
697llxFooter();
698$db->close();
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.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition propal.php:281
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
print $object position
Definition edit.php:206
$object ref
Definition info.php:90
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage a WYSIWYG editor.
Class to manage standard extra fields.
Class to generate HTML forms for single email Usage: $formai = new FormAI($db) $formai->proprietes=1 ...
Class to generate html code for admin pages.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage a HTML form to send a unitary email Usage: $formail = new FormMail($db) $formmail->pr...
Class to manage building of HTML components.
Class for KnowledgeRecord.
Class to manage projects.
Class toolbox to validate values.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
Definition html.lib.php:542
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:165
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.
treeview li table
No Email.