dolibarr 20.0.0
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
25require '../main.inc.php';
26
27require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
28require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
29require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
30require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
31require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/class/knowledgerecord.class.php';
32require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/lib/knowledgemanagement_knowledgerecord.lib.php';
33require_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 = GETPOSTINT('id');
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 = GETPOSTINT('lineid');
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 criteria
61$search_all = GETPOST("search_all", 'alpha');
62$search = array();
63foreach ($object->fields as $key => $val) {
64 if (GETPOST('search_'.$key, 'alpha')) {
65 $search[$key] = GETPOST('search_'.$key, 'alpha');
66 }
67}
68
69if (empty($action) && empty($id) && empty($ref)) {
70 $action = 'view';
71}
72
73// Load object
74include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
75
76
77$permissiontoread = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'read');
78$permissiontovalidate = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write');
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$permissionnote = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // Used by the include of actions_setnotes.inc.php
82$permissiondellink = $user->hasRight('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);
89restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, '', '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
100if ($reshook < 0) {
101 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
102}
103
104if (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 = 'KNOWLEDGERECORD_MODIFY'; // Name of trigger action code to execute when we modify record
120
121 // Update / 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', GETPOSTINT('fk_soc'), '', '', 'date', '', $user, $triggermodname);
143 }
144 if ($action == 'classin' && $permissiontoadd) {
145 $object->setProject(GETPOSTINT('projectid'));
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}
154if ($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 = '';
169llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-knowledgemanagement page-card');
170
171// Part to create
172if ($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(), '', '', -3);
186
187 print '<table class="border centpercent tableforfieldcreate">'."\n";
188
189 // Common attributes
190 $object->fields['answer']['enabled'] = 0;
191 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
192 $object->fields['answer']['enabled'] = 1;
193
194 if (isModEnabled('category')) {
195 $cate_arbo = $form->select_all_categories(Categorie::TYPE_KNOWLEDGEMANAGEMENT, '', 'parent', 64, 0, 3);
196
197 if (count($cate_arbo)) {
198 // Categories
199 print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
200 print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
201 print "</td></tr>";
202 }
203 }
204
205 // Other attributes
206 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
207
208 print '</table>'."\n";
209
210 // Add field answer
211 print '<br>';
212 print $langs->trans($object->fields['answer']['label']).'<br>';
213 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
214 $doleditor = new DolEditor('answer', $object->answer, '', 200, 'dolibarr_notes', 'In', true, true, true, ROWS_9, '100%');
215 $out = $doleditor->Create(1);
216 print $out;
217
218 print dol_get_fiche_end();
219
220 print $form->buttonsSaveCancel('Create');
221
222 print '</form>';
223
224 //dol_set_focus('input[name="ref"]');
225}
226
227// Part to edit record
228if (($id || $ref) && $action == 'edit') {
229 print load_fiche_titre($langs->trans("KnowledgeRecord"), '', 'object_'.$object->picto);
230
231 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
232 print '<input type="hidden" name="token" value="'.newToken().'">';
233 print '<input type="hidden" name="action" value="update">';
234 print '<input type="hidden" name="id" value="'.$object->id.'">';
235 if (!empty($backtopage)) {
236 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
237 }
238 if (!empty($backtopageforcancel)) {
239 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
240 }
241
242 print dol_get_fiche_head(array(), '', '', -3);
243
244 print '<table class="border centpercent tableforfieldedit">'."\n";
245
246 // Common attributes
247 $object->fields['answer']['enabled'] = 0;
248 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
249 $object->fields['answer']['enabled'] = 1;
250
251 if (isModEnabled('category')) {
252 $cate_arbo = $form->select_all_categories(Categorie::TYPE_KNOWLEDGEMANAGEMENT, '', 'parent', 64, 0, 3);
253
254 if (count($cate_arbo)) {
255 // Categories
256 print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
257 $c = new Categorie($db);
258 $cats = $c->containing($object->id, Categorie::TYPE_KNOWLEDGEMANAGEMENT);
259 $arrayselected = array();
260 if (is_array($cats)) {
261 foreach ($cats as $cat) {
262 $arrayselected[] = $cat->id;
263 }
264 }
265 print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
266 print "</td></tr>";
267 }
268 }
269
270 // Other attributes
271 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
272
273 print '</table>';
274
275 // Add field answer
276 print '<br>';
277 print $langs->trans($object->fields['answer']['label']).'<br>';
278 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
279 $doleditor = new DolEditor('answer', $object->answer, '', 200, 'dolibarr_notes', 'In', true, true, true, ROWS_9, '100%');
280 $out = $doleditor->Create(1);
281 print $out;
282
283 print dol_get_fiche_end();
284
285 print $form->buttonsSaveCancel();
286
287 print '</form>';
288}
289
290// Part to show record
291if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
292 $res = $object->fetch_optionals();
293
294 $head = knowledgerecordPrepareHead($object);
295 print dol_get_fiche_head($head, 'card', $langs->trans("KnowledgeRecord"), -1, $object->picto);
296
297 $formconfirm = '';
298
299 // Confirmation to delete
300 if ($action == 'delete') {
301 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteKnowledgeRecord'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
302 }
303 // Confirmation to delete line
304 if ($action == 'deleteline') {
305 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
306 }
307 // Clone confirmation
308 if ($action == 'clone') {
309 // Create an array for form
310 $formquestion = array();
311 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
312 }
313
314 // Confirmation of action xxxx (You can use it for xxx = 'close', xxx = 'reopen', ...)
315 if ($action == 'close') {
316 $text = $langs->trans('ConfirmCloseKM', $object->ref);
317 /*if (isModEnabled('notification'))
318 {
319 require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
320 $notify = new Notify($db);
321 $text .= '<br>';
322 $text .= $notify->confirmMessage('MYOBJECT_CLOSE', $object->socid, $object);
323 }*/
324
325 $formquestion = array();
326 /*
327 $forcecombo=0;
328 if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
329 $formquestion = array(
330 // 'text' => $langs->trans("ConfirmClone"),
331 // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
332 // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
333 // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
334 );
335 */
336 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetObsolete'), $text, 'confirm_close', $formquestion, 0, 1, 220);
337 }
338
339 // Confirmation of action xxxx (You can use it for xxx = 'close', xxx = 'reopen', ...)
340 if ($action == 'reopen') {
341 $text = $langs->trans('ConfirmReopenKM', $object->ref);
342 /*if (isModEnabled('notification'))
343 {
344 require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
345 $notify = new Notify($db);
346 $text .= '<br>';
347 $text .= $notify->confirmMessage('MYOBJECT_CLOSE', $object->socid, $object);
348 }*/
349
350 $formquestion = array();
351 /*
352 $forcecombo=0;
353 if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
354 $formquestion = array(
355 // 'text' => $langs->trans("ConfirmClone"),
356 // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
357 // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
358 // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
359 );
360 */
361 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Re-Open'), $text, 'confirm_reopen', $formquestion, 0, 1, 220);
362 }
363
364 // Call Hook formConfirm
365 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
366 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
367 if (empty($reshook)) {
368 $formconfirm .= $hookmanager->resPrint;
369 } elseif ($reshook > 0) {
370 $formconfirm = $hookmanager->resPrint;
371 }
372
373 // Print form confirm
374 print $formconfirm;
375
376
377 // Object card
378 // ------------------------------------------------------------
379 $linkback = '<a href="'.DOL_URL_ROOT.'/knowledgemanagement/knowledgerecord_list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
380
381 $morehtmlref = '<div class="refidno">';
382 /*
383 // Ref customer
384 $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
385 $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
386 // Thirdparty
387 $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
388 // Project
389 if (isModEnabled('project')) {
390 $langs->load("projects");
391 $morehtmlref .= '<br>'.$langs->trans('Project') . ' ';
392 if ($permissiontoadd) {
393 //if ($action != 'classify') $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> ';
394 $morehtmlref .= ' : ';
395 if ($action == 'classify') {
396 //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 0, 1, '', 'maxwidth300');
397 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
398 $morehtmlref .= '<input type="hidden" name="action" value="classin">';
399 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
400 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
401 $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
402 $morehtmlref .= '</form>';
403 } else {
404 $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300');
405 }
406 } else {
407 if (!empty($object->fk_project)) {
408 $proj = new Project($db);
409 $proj->fetch($object->fk_project);
410 $morehtmlref .= ': '.$proj->getNomUrl();
411 } else {
412 $morehtmlref .= '';
413 }
414 }
415 }*/
416 $morehtmlref .= '</div>';
417
418
419 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
420
421
422 print '<div class="fichecenter">';
423 print '<div class="fichehalfleft">';
424 print '<div class="underbanner clearboth"></div>';
425 print '<table class="border centpercent tableforfield">'."\n";
426
427 // Common attributes
428 $keyforbreak='fk_c_ticket_category'; // We change column just before this field
429 //unset($object->fields['fk_project']); // Hide field already shown in banner
430 //unset($object->fields['fk_soc']); // Hide field already shown in banner
431 $object->fields['answer']['enabled'] = 0;
432 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
433 $object->fields['answer']['enabled'] = 1;
434
435 // Categories
436 if (isModEnabled('category')) {
437 print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
438 print $form->showCategories($object->id, Categorie::TYPE_KNOWLEDGEMANAGEMENT, 1);
439 print "</td></tr>";
440 }
441
442 // Other attributes. Fields from hook formObjectOptions and Extrafields.
443 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
444
445 print '</table>';
446
447 print '</div>';
448 print '</div>';
449
450 print '<div class="clearboth"></div>';
451
452 // Add field answer
453 print '<br>';
454 print $langs->trans($object->fields['answer']['label']).'<br>';
455 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
456 $doleditor = new DolEditor('answer', $object->answer, '', 200, 'dolibarr_notes', 'In', true, true, true, ROWS_9, '100%', 1);
457 $out = $doleditor->Create(1);
458 print $out;
459
460 print dol_get_fiche_end();
461
462
463 // Buttons for actions
464
465 if ($action != 'presend' && $action != 'editline') {
466 print '<div class="tabsAction">'."\n";
467 $parameters = array();
468 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
469 if ($reshook < 0) {
470 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
471 }
472
473 if (empty($reshook)) {
474 // Send
475 if (empty($user->socid)) {
476 //print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle');
477 }
478
479 // Back to draft
480 if ($object->status == $object::STATUS_VALIDATED) {
481 print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd);
482 }
483 if (($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) && $permissiontovalidate) {
484 print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd);
485 }
486 // Validate
487 if ($object->status == $object::STATUS_DRAFT) {
488 if ((empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) && $permissiontovalidate) {
489 print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&token='.newToken().'&confirm=yes', '', $permissiontoadd);
490 } else {
491 $langs->load("errors");
492 //print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes', '', 0);
493 print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Reply").'</a>';
494 }
495 }
496
497 // Clone
498 print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=clone&token='.newToken().'&object=scrumsprint', '', $permissiontoadd);
499
500 /*
501 if ($permissiontoadd) {
502 if ($object->status == $object::STATUS_ENABLED) {
503 print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=disable&token='.newToken().'">'.$langs->trans("Disable").'</a>'."\n";
504 } else {
505 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=enable&token='.newToken().'">'.$langs->trans("Enable").'</a>'."\n";
506 }
507 }
508 */
509 if ($permissiontoadd) {
510 if ($object->status == $object::STATUS_VALIDATED) {
511 print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken().'">'.$langs->trans("SetObsolete").'</a>'."\n";
512 } else {
513 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen&token='.newToken().'">'.$langs->trans("Re-Open").'</a>'."\n";
514 }
515 }
516
517 // Delete (need delete permission, or if draft, just need create/modify permission)
518 print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken(), '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd));
519 }
520 print '</div>'."\n";
521 }
522
523
524 // Select mail models is same action as presend
525 if (GETPOST('modelselected')) {
526 $action = 'presend';
527 }
528
529 if ($action != 'presend') {
530 print '<div class="fichecenter"><div class="fichehalfleft">';
531 print '<a name="builddoc"></a>'; // ancre
532
533 $includedocgeneration = 0;
534
535 // Documents
536 if ($includedocgeneration) {
537 $objref = dol_sanitizeFileName($object->ref);
538 $relativepath = $objref.'/'.$objref.'.pdf';
539 $filedir = $conf->knowledgemanagement->dir_output.'/'.$object->element.'/'.$objref;
540 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
541 $genallowed = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'read'); // If you can read, you can build the PDF to read content
542 $delallowed = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); // If you can create/edit, you can remove a file on card
543 print $formfile->showdocuments('knowledgemanagement:KnowledgeRecord', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
544 }
545
546 // Show links to link elements
547 $linktoelem = $form->showLinkToObjectBlock($object, null, array('knowledgerecord'));
548 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
549
550
551 print '</div><div class="fichehalfright">';
552
553 $MAXEVENT = 10;
554
555 $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/knowledgemanagement/knowledgerecord_agenda.php?id='.$object->id);
556
557 // List of actions on element
558 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
559 $formactions = new FormActions($db);
560 $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
561
562 print '</div></div>';
563 }
564
565 //Select mail models is same action as presend
566 if (GETPOST('modelselected')) {
567 $action = 'presend';
568 }
569
570 // Presend form
571 $modelmail = 'knowledgerecord';
572 $defaulttopic = 'InformationMessage';
573 $diroutput = $conf->knowledgemanagement->dir_output;
574 $trackid = 'knowledgerecord'.$object->id;
575
576 include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
577}
578
579// End of page
580llxFooter();
581$db->close();
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()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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.