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