dolibarr 24.0.0-beta
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';
29
30require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
34require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/class/knowledgerecord.class.php';
35require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/lib/knowledgemanagement_knowledgerecord.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
37
46// Load translation files required by the page
47$langs->loadLangs(array("knowledgemanagement", "ticket", "other"));
48
49// Get parameters
50$id = GETPOSTINT('id');
51$ref = GETPOST('ref', 'alpha');
52$action = GETPOST('action', 'aZ09');
53$confirm = GETPOST('confirm', 'alpha');
54$cancel = GETPOST('cancel');
55$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'knowledgerecordcard'; // To manage different context of search
56$backtopage = GETPOST('backtopage', 'alpha');
57$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
58$lineid = GETPOSTINT('lineid');
59
60// Initialize a technical objects
62$extrafields = new ExtraFields($db);
63$diroutputmassaction = $conf->knowledgemanagement->dir_output.'/temp/massgeneration/'.$user->id;
64$hookmanager->initHooks(array('knowledgerecordcard', 'globalcard')); // Note that conf->hooks_modules contains array
65
66// Fetch optionals attributes and labels
67$extrafields->fetch_name_optionals_label($object->table_element);
68
69$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
70
71// Initialize array of search criteria
72$search_all = GETPOST("search_all", 'alpha');
73$search = array();
74foreach ($object->fields as $key => $val) {
75 if (GETPOST('search_'.$key, 'alpha')) {
76 $search[$key] = GETPOST('search_'.$key, 'alpha');
77 }
78}
79
80if (empty($action) && empty($id) && empty($ref)) {
81 $action = 'view';
82}
83
84// Load object
85include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
86
87
88$permissiontoread = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'read');
89$permissiontoadd = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
90$permissiontodelete = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
91$permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $permissiontoadd) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('knowledgemanagement', 'knowledgerecord_advance', 'validate')));
92$permissionnote = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_setnotes.inc.php
93$permissiondellink = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_dellink.inc.php
94$upload_dir = $conf->knowledgemanagement->multidir_output[isset($object->entity) ? $object->entity : 1];
95
96// Security check - Protection if external user
97//if ($user->socid > 0) accessforbidden();
98//if ($user->socid > 0) $socid = $user->socid;
99$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
100restrictedArea($user, $object->module, $object->id, $object->table_element.'&'.$object->element, $object->element, '', 'rowid', $isdraft);
101//if (empty($conf->knowledgemanagement->enabled)) accessforbidden();
102//if (empty($permissiontoread)) accessforbidden();
103
104
105/*
106 * Actions
107 */
108
109$parameters = array();
110$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
111if ($reshook < 0) {
112 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
113}
114
115if (empty($reshook)) {
116 $error = 0;
117
118 $backurlforlist = DOL_URL_ROOT.'/knowledgemanagement/knowledgerecord_list.php';
119
120 if (empty($backtopage) || ($cancel && empty($id))) {
121 if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
122 if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
123 $backtopage = $backurlforlist;
124 } else {
125 $backtopage = DOL_URL_ROOT.'/knowledgemanagement/knowledgerecord_card.php?id='.($id > 0 ? $id : '__ID__');
126 }
127 }
128 }
129
130 $triggermodname = 'KNOWLEDGERECORD_MODIFY'; // Name of trigger action code to execute when we modify record
131
132 // Update / add for lang
133 if (($action == 'update' || $action == 'add') && !empty($permissiontoadd)) {
134 $object->lang = (GETPOSTISSET('langkm') ? GETPOST('langkm', 'aZ09') : $object->lang);
135 }
136
137 // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
138 include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
139
140 // Actions when linking object each other
141 include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
142
143 // Actions when printing a doc from card
144 include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
145
146 // Action to move up and down lines of object
147 //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
148
149 // Action to build doc
150 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
151
152 if ($action == 'set_thirdparty' && $permissiontoadd) {
153 $object->setValueFrom('fk_soc', GETPOSTINT('fk_soc'), '', null, 'date', '', $user, $triggermodname);
154 }
155 if ($action == 'classin' && $permissiontoadd) {
156 $object->setProject(GETPOSTINT('projectid'));
157 }
158
159 // Actions to send emails
160 $triggersendname = 'KNOWLEDGEMANAGEMENT_KNOWLEDGERECORD_SENTBYMAIL';
161 $autocopy = 'MAIN_MAIL_AUTOCOPY_KNOWLEDGERECORD_TO';
162 $trackid = 'knowledgerecord'.$object->id;
163 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
164}
165if ($action == 'confirm_validate') { // Test on permission already done into actions_addupdatedelete.inc.php
166 $action = 'edit';
167}
168
169
170/*
171 * View
172 */
173
174$form = new Form($db);
175$formfile = new FormFile($db);
176$formproject = new FormProjets($db);
177$formadmin = new FormAdmin($db);
178
179$title = $langs->trans("KnowledgeRecord");
180$help_url = '';
181llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-knowledgemanagement page-card');
182
183// Part to create
184if ($action == 'create') {
185 print load_fiche_titre($langs->trans("NewKnowledgeRecord"), '', 'object_'.$object->picto);
186
187 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
188 print '<input type="hidden" name="token" value="'.newToken().'">';
189 print '<input type="hidden" name="action" value="add">';
190 if (!empty($backtopage)) {
191 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
192 }
193 if (!empty($backtopageforcancel)) {
194 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
195 }
196
197 print dol_get_fiche_head(array(), '', '', -3);
198
199 print '<table class="border centpercent tableforfieldcreate">'."\n";
200
201 // Common attributes
202 $object->fields['answer']['enabled'] = 0;
203 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
204 $object->fields['answer']['enabled'] = 1;
205
206 if (isModEnabled('category')) {
207 $cate_arbo = $form->select_all_categories(Categorie::TYPE_KNOWLEDGEMANAGEMENT, '', 'parent', 64, 0, 3);
208 // $output_mode is 3, so fix return type:
209 '@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';
210
211 if (count($cate_arbo)) {
212 // Categories
213 print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
214 print $form->selectCategories(Categorie::TYPE_KNOWLEDGEMANAGEMENT, 'categories', $object);
215 print "</td></tr>";
216 }
217 }
218
219 // Other attributes
220 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
221
222 print '</table>'."\n";
223
224 // Add field answer
225 print '<br>';
226 print $langs->trans($object->fields['answer']['label']).'<br>';
227 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
228 $doleditor = new DolEditor('answer', $object->answer, '', 200, 'dolibarr_notes', 'In', true, true, true, ROWS_9, '100%');
229 $out = $doleditor->Create(1);
230 print $out;
231
232 print dol_get_fiche_end();
233
234 print $form->buttonsSaveCancel('Create');
235
236 print '</form>';
237
238 //dol_set_focus('input[name="ref"]');
239}
240
241// Part to edit record
242if (($id || $ref) && $action == 'edit') {
243 print load_fiche_titre($langs->trans("KnowledgeRecord"), '', 'object_'.$object->picto);
244
245 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
246 print '<input type="hidden" name="token" value="'.newToken().'">';
247 print '<input type="hidden" name="action" value="update">';
248 print '<input type="hidden" name="id" value="'.$object->id.'">';
249 if (!empty($backtopage)) {
250 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
251 }
252 if (!empty($backtopageforcancel)) {
253 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
254 }
255
256 print dol_get_fiche_head(array(), '', '', -3);
257
258 print '<table class="border centpercent tableforfieldedit">'."\n";
259
260 // Common attributes
261 $object->fields['answer']['enabled'] = 0;
262 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
263 $object->fields['answer']['enabled'] = 1;
264
265 if (isModEnabled('category')) {
266 $cate_arbo = $form->select_all_categories(Categorie::TYPE_KNOWLEDGEMANAGEMENT, '', 'parent', 64, 0, 3);
267 // $output_mode is 3, so fix return type:
268 '@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';
269
270 if (count($cate_arbo)) {
271 // Categories
272 print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
273 print $form->selectCategories(Categorie::TYPE_KNOWLEDGEMANAGEMENT, 'categories', $object);
274 print "</td></tr>";
275 }
276 }
277
278 // Other attributes
279 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
280
281 print '</table>';
282
283 // Add field answer
284 print '<br>';
285 print $langs->trans($object->fields['answer']['label']).'<br>';
286 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
287 $doleditor = new DolEditor('answer', $object->answer, '', 200, 'dolibarr_notes', 'In', true, true, true, ROWS_9, '100%');
288 $out = $doleditor->Create(1);
289 print $out;
290
291 print dol_get_fiche_end();
292
293 print $form->buttonsSaveCancel();
294
295 print '</form>';
296}
297
298// Part to show record
299if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
300 $res = $object->fetch_optionals();
301
302 $head = knowledgerecordPrepareHead($object);
303 print dol_get_fiche_head($head, 'card', $langs->trans("KnowledgeRecord"), -1, $object->picto);
304
305 $formconfirm = '';
306
307 // Confirmation to delete
308 if ($action == 'delete') {
309 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteKnowledgeRecord'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
310 }
311 // Confirmation to delete line
312 if ($action == 'deleteline') {
313 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
314 }
315 // Clone confirmation
316 if ($action == 'clone') {
317 // Create an array for form
318 $formquestion = array();
319 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
320 }
321
322 // Confirmation of action xxxx (You can use it for xxx = 'close', xxx = 'reopen', ...)
323 if ($action == 'close') {
324 $text = $langs->trans('ConfirmCloseKM', $object->ref);
325 /*if (isModEnabled('notification'))
326 {
327 require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
328 $notify = new Notify($db);
329 $text .= '<br>';
330 $text .= $notify->confirmMessage('MYOBJECT_CLOSE', $object->socid, $object);
331 }*/
332
333 $formquestion = array();
334 /*
335 $forcecombo=0;
336 if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
337 $formquestion = array(
338 // 'text' => $langs->trans("ConfirmClone"),
339 // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
340 // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
341 // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
342 );
343 */
344 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetObsolete'), $text, 'confirm_close', $formquestion, 0, 1, 220);
345 }
346
347 // Confirmation of action xxxx (You can use it for xxx = 'close', xxx = 'reopen', ...)
348 if ($action == 'reopen') {
349 $text = $langs->trans('ConfirmReopenKM', $object->ref);
350 /*if (isModEnabled('notification'))
351 {
352 require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
353 $notify = new Notify($db);
354 $text .= '<br>';
355 $text .= $notify->confirmMessage('MYOBJECT_CLOSE', $object->socid, $object);
356 }*/
357
358 $formquestion = array();
359 /*
360 $forcecombo=0;
361 if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
362 $formquestion = array(
363 // 'text' => $langs->trans("ConfirmClone"),
364 // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
365 // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
366 // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
367 );
368 */
369 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Re-Open'), $text, 'confirm_reopen', $formquestion, 0, 1, 220);
370 }
371
372 // Call Hook formConfirm
373 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
374 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
375 if (empty($reshook)) {
376 $formconfirm .= $hookmanager->resPrint;
377 } elseif ($reshook > 0) {
378 $formconfirm = $hookmanager->resPrint;
379 }
380
381 // Print form confirm
382 print $formconfirm;
383
384
385 // Object card
386 // ------------------------------------------------------------
387 $linkback = '<a href="'.DOL_URL_ROOT.'/knowledgemanagement/knowledgerecord_list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
388
389 $morehtmlref = '<div class="refidno">';
390 /*
391 // Ref customer
392 $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
393 $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
394 // Thirdparty
395 $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
396 // Project
397 if (isModEnabled('project')) {
398 $langs->load("projects");
399 $morehtmlref .= '<br>'.$langs->trans('Project') . ' ';
400 if ($permissiontoadd) {
401 //if ($action != 'classify') $morehtmlref.='<a class="editfielda" href="' . dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true) . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> ';
402 $morehtmlref .= ' : ';
403 if ($action == 'classify') {
404 //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 0, 1, '', 'maxwidth300');
405 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
406 $morehtmlref .= '<input type="hidden" name="action" value="classin">';
407 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
408 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
409 $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
410 $morehtmlref .= '</form>';
411 } else {
412 $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
413 }
414 } else {
415 if (!empty($object->fk_project)) {
416 $proj = new Project($db);
417 $proj->fetch($object->fk_project);
418 $morehtmlref .= ': '.$proj->getNomUrl();
419 } else {
420 $morehtmlref .= '';
421 }
422 }
423 }*/
424 $morehtmlref .= '</div>';
425
426
427 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
428
429
430 print '<div class="fichecenter">';
431 print '<div class="fichehalfleft">';
432 print '<div class="underbanner clearboth"></div>';
433 print '<table class="border centpercent tableforfield">'."\n";
434
435 // Common attributes
436 $keyforbreak = 'fk_c_ticket_category'; // We change column just before this field
437 //unset($object->fields['fk_project']); // Hide field already shown in banner
438 //unset($object->fields['fk_soc']); // Hide field already shown in banner
439 $object->fields['answer']['enabled'] = 0;
440 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
441 $object->fields['answer']['enabled'] = 1;
442
443 // Categories
444 if (isModEnabled('category')) {
445 print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
446 print $form->showCategories($object->id, Categorie::TYPE_KNOWLEDGEMANAGEMENT, 1);
447 print "</td></tr>";
448 }
449
450 // Other attributes. Fields from hook formObjectOptions and Extrafields.
451 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
452
453 print '</table>';
454
455 print '</div>';
456 print '</div>';
457
458 print '<div class="clearboth"></div>';
459
460 // Add field answer
461 print '<br>';
462 print load_fiche_titre($langs->trans($object->fields['answer']['label']), '', '');
463 if ($action == 'edit') {
464 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
465 $doleditor = new DolEditor('answer', $object->answer, '', 200, 'dolibarr_notes', 'In', true, true, true, ROWS_9, '100%', 1);
466 $out = $doleditor->Create(1);
467 } else {
468 $out = '<div class="content">';
469 $out .= $object->answer;
470 $out .= '</div>';
471 }
472 print $out;
473 print dol_get_fiche_end();
474
475
476 // Buttons for actions
477
478 if ($action != 'presend' && $action != 'editline') {
479 print '<div class="tabsAction">'."\n";
480 $parameters = array();
481 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
482 if ($reshook < 0) {
483 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
484 }
485
486 if (empty($reshook)) {
487 // Send
488 //if (empty($user->socid)) {
489 //print dolGetButtonAction('', $langs->trans('SendMail'), 'email', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle');
490 //}
491
492 // Back to draft
493 if ($object->status == $object::STATUS_VALIDATED) {
494 print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd);
495 }
496 if (($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) && $permissiontovalidate) {
497 print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd);
498 }
499 // Validate
500 if ($object->status == $object::STATUS_DRAFT) {
501 if ((empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) && $permissiontovalidate) {
502 print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&token='.newToken().'&confirm=yes', '', $permissiontoadd);
503 } else {
504 $langs->load("errors");
505 //print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes', '', 0);
506 print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
507 }
508 }
509
510 // Clone
511 print dolGetButtonAction('', $langs->trans('ToClone'), 'clone', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=clone&token='.newToken().'&object=scrumsprint', '', $permissiontoadd);
512
513 /*
514 if ($permissiontoadd) {
515 if ($object->status == $object::STATUS_ENABLED) {
516 print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=disable&token='.newToken().'">'.$langs->trans("Disable").'</a>'."\n";
517 } else {
518 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=enable&token='.newToken().'">'.$langs->trans("Enable").'</a>'."\n";
519 }
520 }
521 */
522 if ($permissiontoadd) {
523 if ($object->status == $object::STATUS_VALIDATED) {
524 print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken().'">'.$langs->trans("SetObsolete").'</a>'."\n";
525 } elseif ($object->status == $object::STATUS_CANCELED) {
526 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen&token='.newToken().'">'.$langs->trans("ReOpen").'</a>'."\n";
527 }
528 }
529
530 // Delete (need delete permission, or if draft, just need create/modify permission)
531 print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken(), '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd));
532 }
533 print '</div>'."\n";
534 }
535
536
537 // Select mail models is same action as presend
538 if (GETPOST('modelselected')) {
539 $action = 'presend';
540 }
541
542 if ($action != 'presend') {
543 print '<div class="fichecenter"><div class="fichehalfleft">';
544 print '<a name="builddoc"></a>'; // ancre
545
546 $includedocgeneration = 0;
547
548 // Documents
549 if ($includedocgeneration) {
550 $objref = dol_sanitizeFileName($object->ref);
551 $relativepath = $objref.'/'.$objref.'.pdf';
552 $filedir = $conf->knowledgemanagement->dir_output.'/'.$object->element.'/'.$objref;
553 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
554 $genallowed = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'read'); // If you can read, you can build the PDF to read content
555 $delallowed = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // If you can create/edit, you can remove a file on card
556 print $formfile->showdocuments('knowledgemanagement:KnowledgeRecord', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
557 }
558
559 // Show links to link elements
560 $tmparray = $form->showLinkToObjectBlock($object, array(), array('knowledgerecord'), 1);
561 $linktoelem = $tmparray['linktoelem'];
562 $htmltoenteralink = $tmparray['htmltoenteralink'];
563 print $htmltoenteralink;
564
565 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
566
567
568 print '</div><div class="fichehalfright">';
569
570 $MAXEVENT = 10;
571
572 $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/knowledgemanagement/knowledgerecord_agenda.php?id='.$object->id);
573
574 // List of actions on element
575 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
576 $formactions = new FormActions($db);
577 $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
578
579 print '</div></div>';
580 }
581
582 //Select mail models is same action as presend
583 if (GETPOST('modelselected')) {
584 $action = 'presend';
585 }
586
587 // Presend form
588 $modelmail = 'knowledgerecord';
589 $defaulttopic = 'InformationMessage';
590 $diroutput = $conf->knowledgemanagement->dir_output;
591 $trackid = 'knowledgerecord'.$object->id;
592
593 include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
594}
595
596// End of page
597llxFooter();
598$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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
Class to manage a WYSIWYG editor.
Class to manage standard extra fields.
Class to manage building of HTML components.
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 building of HTML components.
Class for KnowledgeRecord.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
knowledgerecordPrepareHead($object)
Prepare array of tabs for KnowledgeRecord.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.