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