26require
'../main.inc.php';
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';
37$langs->loadLangs(array(
"knowledgemanagement",
"ticket",
"other"));
42$action =
GETPOST(
'action',
'aZ09');
43$confirm =
GETPOST(
'confirm',
'alpha');
44$cancel =
GETPOST(
'cancel',
'aZ09');
45$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'knowledgerecordcard';
46$backtopage =
GETPOST(
'backtopage',
'alpha');
47$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
53$diroutputmassaction = $conf->knowledgemanagement->dir_output.
'/temp/massgeneration/'.$user->id;
54$hookmanager->initHooks(array(
'knowledgerecordcard',
'globalcard'));
57$extrafields->fetch_name_optionals_label(
$object->table_element);
59$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
62$search_all =
GETPOST(
"search_all",
'alpha');
64foreach (
$object->fields as $key => $val) {
65 if (
GETPOST(
'search_'.$key,
'alpha')) {
66 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
70if (empty($action) && empty($id) && empty($ref)) {
75include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
78$permissiontoread = $user->hasRight(
'knowledgemanagement',
'knowledgerecord',
'read');
79$permissiontoadd = $user->hasRight(
'knowledgemanagement',
'knowledgerecord',
'write');
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');
83$permissiondellink = $user->hasRight(
'knowledgemanagement',
'knowledgerecord',
'write');
84$upload_dir = $conf->knowledgemanagement->multidir_output[isset(
$object->entity) ?
$object->entity : 1];
89$isdraft = ((
$object->status == $object::STATUS_DRAFT) ? 1 : 0);
100$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
105if (empty($reshook)) {
108 $backurlforlist = DOL_URL_ROOT.
'/knowledgemanagement/knowledgerecord_list.php';
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;
115 $backtopage = DOL_URL_ROOT.
'/knowledgemanagement/knowledgerecord_card.php?id='.(
$id > 0 ?
$id :
'__ID__');
120 $triggermodname =
'KNOWLEDGERECORD_MODIFY';
123 if (($action ==
'update' || $action ==
'add') && !empty($permissiontoadd)) {
128 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
131 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
134 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
140 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
142 if ($action ==
'set_thirdparty' && $permissiontoadd) {
143 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
145 if ($action ==
'classin' && $permissiontoadd) {
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';
155if ($action ==
'confirm_validate') {
163$form =
new Form($db);
168$title = $langs->trans(
"KnowledgeRecord");
170llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-knowledgemanagement page-card');
173if ($action ==
'create') {
174 print
load_fiche_titre($langs->trans(
"NewKnowledgeRecord"),
'',
'object_'.$object->picto);
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.
'">';
182 if (!empty($backtopageforcancel)) {
183 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
188 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
191 $object->fields[
'answer'][
'enabled'] = 0;
192 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
193 $object->fields[
'answer'][
'enabled'] = 1;
195 if (isModEnabled(
'category')) {
196 $cate_arbo = $form->select_all_categories(Categorie::TYPE_KNOWLEDGEMANAGEMENT,
'',
'parent', 64, 0, 3);
198 if (count($cate_arbo)) {
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);
207 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
209 print
'</table>'.
"\n";
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);
221 print $form->buttonsSaveCancel(
'Create');
229if (($id || $ref) && $action ==
'edit') {
230 print
load_fiche_titre($langs->trans(
"KnowledgeRecord"),
'',
'object_'.$object->picto);
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.
'">';
239 if (!empty($backtopageforcancel)) {
240 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
245 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
248 $object->fields[
'answer'][
'enabled'] = 0;
249 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
250 $object->fields[
'answer'][
'enabled'] = 1;
252 if (isModEnabled(
'category')) {
253 $cate_arbo = $form->select_all_categories(Categorie::TYPE_KNOWLEDGEMANAGEMENT,
'',
'parent', 64, 0, 3);
255 if (count($cate_arbo)) {
257 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
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;
266 print $form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
272 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
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);
286 print $form->buttonsSaveCancel();
292if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
293 $res =
$object->fetch_optionals();
301 if ($action ==
'delete') {
302 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteKnowledgeRecord'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
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);
309 if ($action ==
'clone') {
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);
316 if ($action ==
'close') {
317 $text = $langs->trans(
'ConfirmCloseKM',
$object->ref);
326 $formquestion = array();
337 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'SetObsolete'), $text,
'confirm_close', $formquestion, 0, 1, 220);
341 if ($action ==
'reopen') {
342 $text = $langs->trans(
'ConfirmReopenKM',
$object->ref);
351 $formquestion = array();
362 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'Re-Open'), $text,
'confirm_reopen', $formquestion, 0, 1, 220);
366 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
367 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
368 if (empty($reshook)) {
369 $formconfirm .= $hookmanager->resPrint;
370 } elseif ($reshook > 0) {
371 $formconfirm = $hookmanager->resPrint;
380 $linkback =
'<a href="'.DOL_URL_ROOT.
'/knowledgemanagement/knowledgerecord_list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
382 $morehtmlref =
'<div class="refidno">';
417 $morehtmlref .=
'</div>';
420 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
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";
429 $keyforbreak =
'fk_c_ticket_category';
432 $object->fields[
'answer'][
'enabled'] = 0;
433 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
434 $object->fields[
'answer'][
'enabled'] = 1;
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);
444 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
451 print
'<div class="clearboth"></div>';
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);
466 if ($action !=
'presend' && $action !=
'editline') {
467 print
'<div class="tabsAction">'.
"\n";
468 $parameters = array();
469 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
474 if (empty($reshook)) {
476 if (empty($user->socid)) {
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);
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);
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);
492 $langs->load(
"errors");
494 print
'<a class="butActionRefused" href="" title="'.$langs->trans(
"ErrorAddAtLeastOneLineFirst").
'">'.$langs->trans(
"Reply").
'</a>';
499 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=clone&token='.
newToken().
'&object=scrumsprint',
'', $permissiontoadd);
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";
514 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=reopen&token='.
newToken().
'">'.$langs->trans(
"Re-Open").
'</a>'.
"\n";
519 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'', $permissiontodelete || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd));
526 if (
GETPOST(
'modelselected')) {
530 if ($action !=
'presend') {
531 print
'<div class="fichecenter"><div class="fichehalfleft">';
532 print
'<a name="builddoc"></a>';
534 $includedocgeneration = 0;
537 if ($includedocgeneration) {
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');
543 $delallowed = $user->hasRight(
'knowledgemanagement',
'knowledgerecord',
'write');
544 print $formfile->showdocuments(
'knowledgemanagement:KnowledgeRecord',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
548 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'knowledgerecord'), 1);
549 $linktoelem = $tmparray[
'linktoelem'];
550 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
551 print $htmltoenteralink;
553 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
556 print
'</div><div class="fichehalfright">';
560 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/knowledgemanagement/knowledgerecord_agenda.php?id='.
$object->id);
563 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
565 $somethingshown = $formactions->showactions($object,
$object->element.
'@'.
$object->module, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
567 print
'</div></div>';
571 if (
GETPOST(
'modelselected')) {
576 $modelmail =
'knowledgerecord';
577 $defaulttopic =
'InformationMessage';
578 $diroutput = $conf->knowledgemanagement->dir_output;
579 $trackid =
'knowledgerecord'.$object->id;
581 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
Class to manage categories.
Class to manage a WYSIWYG editor.
Class for KnowledgeRecord.
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.