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